This action sets up a Miniconda installation to use the Conda package and environment manager by either locating the Miniconda installation bundled with the available runners or by installing a specific Miniconda3 version. By default this action will also create a test environment.
Miniconda condabin/
folder is added to PATH
and conda is correctly initialized across all platforms.
This action correctly handles activation of conda environments and offers the possibility of automatically activating the test environment on all shells.
See the IMPORTANT notes on additional information on environment activation.
For a full list of available inputs for this action see action.yml.
This example shows how to set a basic python workflow with conda using the crossplatform available shells: bash
and pwsh
. On this example an environment named test
will be created with the specific python-version
installed for each opearating system, resulting on 6 build workers.
on:
push:
branches:
- '*'
pull_request:
branches:
- '*'
jobs:
example-1:
name: Ex1 (${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
python-version: ['3.7', '2.7']
steps:
- uses: goanpeca/setup-miniconda@v1
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
- name: Conda info
shell: bash -l {0}
run: conda info
- name: Conda list
shell: pwsh
run: conda list
This example shows how to use all other available shells for specific operating systems. On this example we select to download the latest anaconda version available and create and activate by default an environment named foo
.
on:
push:
branches:
- '*'
pull_request:
branches:
- '*'
jobs:
example-2-linux:
name: Ex2 Linux
runs-on: 'ubuntu-latest'
steps:
- uses: goanpeca/setup-miniconda@v1
with:
miniconda-version: 'latest'
activate-environment: foo
- name: Sh
shell: sh -l {0}
run: |
conda info
conda list
- name: Bash
shell: bash -l {0}
run: |
conda info
conda list
- name: PowerShell Core
shell: pwsh
run: |
conda info
conda list
example-2-mac:
name: Ex2 Mac
runs-on: 'macos-latest'
steps:
- uses: goanpeca/setup-miniconda@v1
with:
miniconda-version: 'latest'
activate-environment: foo
- name: Sh
shell: sh -l {0}
run: |
conda info
conda list
- name: Bash
shell: bash -l {0}
run: |
conda info
conda list
- name: PowerShell Core
shell: pwsh
run: |
conda info
conda list
example-2-win:
name: Ex2 Windows
runs-on: 'windows-latest'
steps:
- uses: goanpeca/setup-miniconda@v1
with:
miniconda-version: 'latest'
activate-environment: foo
- name: Bash
shell: bash -l {0}
run: |
conda info
conda list
- name: PowerShell
shell: powershell
run: |
conda info
conda list
- name: PowerShell Core
shell: pwsh
run: |
conda info
conda list
- name: Cmd.exe
shell: cmd /C CALL {0}
run: >-
conda info &&
conda list
This example shows how to use environment.yml for easier creation of test/build environments and .condarc files for fine grained configuration management. On this example we use a custom configuration file, install an environment from a yaml file and disable autoactivating the base environment before activating the anaconda-client-env
.
on:
push:
branches:
- '*'
pull_request:
branches:
- '*'
jobs:
example-3:
name: Ex3 Linux
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v2
- uses: goanpeca/setup-miniconda@v1
with:
activate-environment: anaconda-client-env
environment-file: etc/example-environment.yml
python-version: 3.5
condarc-file: etc/example-condarc.yml
auto-activate-base: false
- shell: bash -l {0}
run: |
conda info
conda list
This example shows how to use channels
option. The priority will be set by the order of the channels.
In this example it will result in:
- conda-forge
- spyder-ide
- defaults
on:
push:
branches:
- '*'
pull_request:
branches:
- '*'
jobs:
example-4:
name: Ex4 Linux
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v2
- uses: goanpeca/setup-miniconda@enh/channels
with:
activate-environment: foo
python-version: 3.6
channels: conda-forge,spyder-ide
- shell: bash -l {0}
run: |
conda info
conda list
conda config --show-sources
conda config --show
- Bash shells do not use
~/.profile
or~/.bashrc
so these shells need to be explicitely declared asshell: bash -l {0}
on steps that need to be properly activated. This is because bash shells are executed withbash --noprofile --norc -eo pipefail {0}
thus ignoring updated on bash profile files made byconda init bash
. See Github Actions Documentation and thread. - Sh shells do not use
~/.profile
or~/.bashrc
so these shells need to be explicitely declared asshell: sh -l {0}
on steps that need to be properly activated. This is because sh shells are executed withsh -e {0}
thus ignoring updated on bash profile files made byconda init bash
. See Github Actions Documentation. - Cmd shells do not run
Autorun
commands so these shells need to be explicitely declared asshell: cmd /C call {0}
on steps that need to be properly activated. This is because cmd shells are executed with%ComSpec% /D /E:ON /V:OFF /S /C "CALL "{0}""
and the/D
flag disabled execution ofCommand Processor/Autorun
windows registry keys, which is whatconda init cmd.exe
sets. See Github Actions Documentation.
The scripts and documentation in this project are released under the MIT License