Skip to content

Commit

Permalink
Cache conda environment between CI test runs (#6855)
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesbluca authored Sep 2, 2022
1 parent 6da758b commit 7f83c7b
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
# run: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]

env:
CONDA_FILE: continuous_integration/environment-${{ matrix.python-version }}.yaml
TEST_ID: ${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.partition-label }}
# TEST_ID: ${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.partition-label }}-${{ matrix.run }}

Expand All @@ -60,14 +61,39 @@ jobs:
miniforge-version: latest
condarc-file: continuous_integration/condarc
use-mamba: true
python-version: ${{ matrix.python-version }}
environment-file: continuous_integration/environment-${{ matrix.python-version }}.yaml
activate-environment: dask-distributed

- name: Show conda options
shell: bash -l {0}
run: conda config --show

- name: Check if caching is enabled
uses: xarray-contrib/[email protected]
id: skip-caching
with:
keyword: "[skip-caching]"

- name: Get Date
if: steps.skip-caching.outputs.trigger-found != 'true'
id: get-date
run: echo "::set-output name=today::$(/bin/date -u '+%Y%m%d')"
shell: bash

- name: Cache Conda env
if: steps.skip-caching.outputs.trigger-found != 'true'
uses: actions/cache@v2
with:
path: ${{ env.CONDA }}/envs
key: conda-${{ matrix.os }}-${{ steps.get-date.outputs.today }}-${{ hashFiles(env.CONDA_FILE) }}-${{ env.CACHE_NUMBER }}
env:
# Increase this value to reset cache if continuous_integration/environment-${{ matrix.python-version }}.yaml has not changed
CACHE_NUMBER: 0
id: cache

- name: Update environment
run: mamba env update -n dask-distributed -f ${{ env.CONDA_FILE }}
if: steps.skip-caching.outputs.trigger-found == 'true' || steps.cache.outputs.cache-hit != 'true'

- name: Install
shell: bash -l {0}
run: |
Expand Down

0 comments on commit 7f83c7b

Please sign in to comment.