GitHub Action to provision a CI instance using micromamba.
provision-with-micromamba
requires the curl
and tar
programs (with bzip2
support).
They are preinstalled in the default GitHub Actions environments.
The environment.yml or .lock file for the conda environment. If 'false', no enviroment will be created (only Micromamba will be installed) and you should provide 'channels'.
(Optional) The name of the conda environment (defaults to name from the environment.yml file). Required if 'environment-file' is a '.lock' file or 'false'.
(Optional) Version of micromamba to use, eg. '0.20' (default 'latest').
(Optional) Additional specifications (packages) to install. Pretty useful when using matrix builds to pin versions of a test/run dependency. For multiple packages, use multiline syntax (see examples). Note that selectors (e.g. sel(linux): my-linux-package
, sel(osx): my-osx-package
, sel(win): my-win-package
) are available.
(Optional) Comma separated list of channels to use in order of priority (eg., conda-forge,my-private-channel
)
(Optional) If 'true', cache downloaded packages across calls to the provision-with-micromamba action. Cache invalidation can be controlled using the 'cache-downloads-key' option.
(Optional) Custom download cache key used with 'cache-downloads: true'. The default download cache key will invalidate the cache once per day.
(Optional) If 'true', cache installed environments across calls to the provision-with-micromamba action. Cache invalidation can be controlled using the 'cache-env-key' option.
(Optional) Custom environment cache key used with 'cache-env: true'. With the default environment cache key, separate caches will be created for each operating system (eg., Linux) and platform (eg., x64) and day (eg., 2022-01-31), and the cache will be invalidated whenever the contents of 'environment-file' or 'extra-specs' change.
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Conda environment from environment.yml
uses: mamba-org/provision-with-micromamba@main
# Linux and macOS
- name: Run Python
shell: bash -l {0}
run: |
python -c "import numpy"
# Windows
# With Powershell:
- name: Run Python
shell: powershell
run: |
python -c "import numpy"
# Or with cmd:
- name: Run cmd.exe
shell: cmd /C CALL {0}
run: >-
micromamba info && micromamba list
Please see the IMPORTANT notes on additional information on environment activation.
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
pytest: ["6.1", "6.2"]
steps:
- uses: actions/checkout@v2
- name: Install Conda environment with Micromamba
uses: mamba-org/provision-with-micromamba@main
with:
environment-file: myenv.yaml
environment-name: myenvname
extra-specs: |
python=3.7
pytest=${{ matrix.pytest }}
Use cache-downloads
to enable download caching across action runs (.tar.bz2
files).
By default the cache is invalidated once per day. See the cache-downloads-key
option for custom cache invalidation.
- name: Install Conda environment with Micromamba
uses: mamba-org/provision-with-micromamba@main
with:
cache-downloads: true
Use cache-env
to cache the entire Conda environment (envs/myenv
directory) across action runs.
By default the cache is invalidated whenever the contents of the environment-file
or extra-specs
change, plus once per day. See the cache-env-key
option for custom cache invalidation.
- name: Install Conda environment with Micromamba
uses: mamba-org/provision-with-micromamba@main
with:
cache-env: true
Due to a limitation of GitHub Actions any download or environment caches created on a branch will not be available on the main/parent branch after merging. This also applies to PRs.
In contrast, branches can use a cache created on the main/parent branch.
See also this thread.
Please see this comment for now.
Please see this comment for now.
More examples may be found in this repository's tests.
See action.yml.
Some shells require special syntax (e.g. bash -l {0}
). You can set this up with the default
option:
jobs:
myjob:
defaults:
run:
shell: bash -l {0}
# Or top-level:
defaults:
run:
shell: bash -l {0}
jobs:
...
Find the reasons below (taken from setup-miniconda):
- 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 (or use a default shell). 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. - 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 (or use a default shell). 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. sh
is not supported. Please usebash
.
When developing, you need to
- install
nodejs
- clone the repo
- run
npm install -y
- run
npm run build
after making changes