@@ -10,6 +10,8 @@ inputs:
1010runs :
1111 using : composite
1212 steps :
13+ # cache ref https://github.com/conda-incubator/setup-miniconda#caching-packages
14+
1315 - name : Setup conda-forge
1416 uses : conda-incubator/setup-miniconda@v2
1517 with :
@@ -18,23 +20,26 @@ runs:
1820 activate-environment : mpi-tutorial
1921 python-version : ${{ inputs.python-version }}
2022 use-mamba : true
21- environment-file : environment.yml
23+ # uncomment to install env in one go (without caching)
24+ # environment-file: environment.yml
25+ # needed for caching
26+ use-only-tar-bz2 : true
2227
23- # - name: Prepare cache
24- # shell: bash -el {0}
25- # run: |
26- # if [[ $CONDA != /opt/conda ]]; then
27- # mkdir -p /opt/conda/
28- # ln -s $CONDA/envs /opt/conda/envs
29- # fi
30- # echo CONDA=$CONDA
31- # mamba env list
32-
33- # - name: Environment cache
34- # uses: actions/cache@v3
35- # with:
36- # path: /opt/conda/envs/mpi-tutorial
37- # key: env-conda-mpi-tutorial-${{ inputs.python-version }}-${{ hashFiles('.github/actions/install-dependencies/*') }}
38- # id: cache
28+ - name : Get Date
29+ id : get-date
30+ run : echo "today=$(/bin/date -u '+%Y%m%d')" >> "$GITHUB_OUTPUT"
31+ shell : bash
3932
33+ - name : Cache conda env
34+ uses : actions/cache@v3
35+ id : cache-env
36+ with :
37+ path : ${{ env.CONDA }}/envs/mpi-tutorial
38+ key :
39+ conda-env-${{ steps.get-date.outputs.today }}-${{ inputs.python-version }}-${{ hashFiles('environment.yml') }}
4040
41+ - name : Update environment
42+ if : steps.cache-env.outputs.cache-hit != 'true'
43+ run :
44+ mamba env update -n mpi-tutorial -f environment.yml
45+ shell : bash -el {0}
0 commit comments