Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
goanpeca committed May 26, 2022
2 parents 401a96d + e81abac commit fa5fe79
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 81 deletions.
29 changes: 8 additions & 21 deletions .github/workflows/caching-envs-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,6 @@ jobs:
(github.event_name == 'schedule' && github.repository ==
'conda-incubator/setup-miniconda') || (github.event_name != 'schedule')

strategy:
matrix:
include:
- os: ubuntu-latest
label: linux-64
prefix: /usr/share/miniconda3/envs/anaconda-client-env

- os: macos-latest
label: osx-64
prefix: /Users/runner/miniconda3/envs/anaconda-client-env

- os: windows-latest
label: win-64
prefix: C:\Miniconda3\envs\anaconda-client-env

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
Expand All @@ -46,15 +31,17 @@ jobs:
miniforge-version: latest
activate-environment: anaconda-client-env
use-mamba: true

- name: Get Date
id: get-date
run: echo "::set-output name=today::$(/bin/date -u '+%Y%m%d')"
shell: bash

- name: Set cache date
run: echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV

- name: Cache conda env
- name: Cache Conda env
uses: actions/cache@v2
with:
path: ${{ matrix.prefix }}
key: ${{ matrix.label }}-conda-${{ hashFiles('etc/example-environment-caching.yml') }}-${{ env.DATE }}-${{ env.CACHE_NUMBER }}
path: ${{ env.CONDA }}/envs
key: conda-${{ runner.os }}--${{ runner.arch }}--${{ steps.get-date.outputs.today }}-${{ hashFiles('etc/example-environment-caching.yml') }}-${{ env.CACHE_NUMBER }}
env:
# Increase this value to reset cache if etc/example-environment.yml has not changed
CACHE_NUMBER: 0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/example-5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- uses: actions/checkout@v2
- uses: ./
with:
installer-url: https://github.com/conda-forge/miniforge/releases/download/4.9.0-3/Miniforge-pypy3-4.9.0-3-MacOSX-x86_64.sh?foo=bar&baz
installer-url: https://github.com/conda-forge/miniforge/releases/download/4.11.0-0/Miniforge-pypy3-4.11.0-0-MacOSX-x86_64.sh?foo=bar&baz
allow-softlinks: true
show-channel-urls: true
use-only-tar-bz2: true
Expand Down
46 changes: 13 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -604,31 +604,7 @@ as they are not included in the conda package cache.

### Caching environments

A Miniforge variant is recommended to cache deployed environments, since the
Miniconda installation path requires succesive changes of folder ownership in
order to work with the `cache` action.

Every operating system use a different Miniforge `prefix`, so if you want to
cache the environment on all of them you must use a `matrix` strategy.

```yaml
strategy:
matrix:
include:
- os: ubuntu-latest
label: linux-64
prefix: /usr/share/miniconda3/envs/anaconda-client-env

- os: macos-latest
label: osx-64
prefix: /Users/runner/miniconda3/envs/anaconda-client-env

- os: windows-latest
label: win-64
prefix: C:\Miniconda3\envs\anaconda-client-env
```

Then, the first installation step should setup a Miniconda variant without
The first installation step should setup a Miniconda variant without
specifying a environment file.

```yaml
Expand All @@ -642,18 +618,22 @@ specifying a environment file.
```

It's a good idea to refresh the cache every 24 hours to avoid inconsistencies
of package versions between the CI pipeline and local installations. You can
skip that step if you use a resolved environment file product of
of package versions between the CI pipeline and local installations.
Here we ensure that this happens by adding the current date to the cache key.
You can remove the "Get Date" step below if you use a resolved environment file product of
`conda env export` or `conda list --explicit`.

```yaml
- name: Set cache date
run: echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV

- uses: actions/cache@v2
- name: Get Date
id: get-date
run: echo "::set-output name=today::$(/bin/date -u '+%Y%m%d')"
shell: bash

- name: Cache Conda env
uses: actions/cache@v2
with:
path: ${{ matrix.prefix }}
key: ${{ matrix.label }}-conda-${{ hashFiles('etc/example-environment-caching.yml') }}-${{ env.DATE }}-${{ env.CACHE_NUMBER }}
path: ${{ env.CONDA }}/envs
key: conda-${{ runner.os }}--${{ runner.arch }}--${{ steps.get-date.outputs.today }}-${{ hashFiles('etc/example-environment-caching.yml') }}-${{ env.CACHE_NUMBER }}
env:
# Increase this value to reset cache if etc/example-environment.yml has not changed
CACHE_NUMBER: 0
Expand Down
79 changes: 53 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fa5fe79

Please sign in to comment.