@@ -10,6 +10,16 @@ inputs:
1010runs :
1111 using : composite
1212 steps :
13+ # cache ref https://github.com/conda-incubator/setup-miniconda#caching-packages
14+
15+ # caching conda packages saves download time, but not unpack / solve
16+ # - name: Cache conda packages
17+ # uses: actions/cache@v2
18+ # with:
19+ # path: ~/conda_pkgs_dir
20+ # key:
21+ # conda-pkgs-${{ inputs.python-version }}-${{ hashFiles('.github/actions/install-dependencies/*') }}-${{ hashFiles('environment.yml') }}
22+
1323 - name : Setup conda-forge
1424 uses : conda-incubator/setup-miniconda@v2
1525 with :
@@ -18,23 +28,26 @@ runs:
1828 activate-environment : mpi-tutorial
1929 python-version : ${{ inputs.python-version }}
2030 use-mamba : true
21- environment-file : environment.yml
31+ # uncomment to install env in one go (without caching)
32+ # environment-file: environment.yml
33+ # needed for caching
34+ use-only-tar-bz2 : true
2235
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
36+ - name : Get Date
37+ id : get-date
38+ run : echo "today=$(/bin/date -u '+%Y%m%d')" >> "$GITHUB_OUTPUT"
39+ shell : bash
3940
41+ - name : Cache conda env
42+ uses : actions/cache@v3
43+ id : cache-env
44+ with :
45+ path : ${{ env.CONDA }}/envs/mpi-tutorial
46+ key :
47+ conda-env-${{ steps.get-date.outputs.today }}-${{ inputs.python-version }}-${{ hashFiles('environment.yml') }}
4048
49+ - name : Update environment
50+ if : steps.cache-env.outputs.cache-hit != 'true'
51+ run :
52+ mamba env update -n mpi-tutorial -f environment.yml
53+ shell : bash -el {0}
0 commit comments