Skip to content

Commit

Permalink
Simplify caching setup
Browse files Browse the repository at this point in the history
  • Loading branch information
tayden committed Feb 15, 2023
1 parent 2c0cc67 commit de76149
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,6 @@ jobs:
matrix:
os: [ "ubuntu-latest", "windows-latest", "macos-latest" ]
python-version: [ "3.7", "3.8", "3.9", "3.10" ]
include:
- os: ubuntu-latest
label: linux-64
prefix: /usr/share/miniconda3/envs/my-env

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

- os: macos-latest
label: macos-64
prefix: /usr/local/miniconda3/envs/my-env

runs-on: ${{ matrix.os }}
defaults:
Expand All @@ -49,13 +37,21 @@ jobs:
activate-environment: my-env
use-mamba: true

- name: Set cache date
run: echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV
- name: Get Date
id: get-date
run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT
shell: bash

- uses: actions/cache@v3
- name: Cache Conda env
uses: actions/cache@v3
with:
path: ${{ matrix.prefix }}
key: ${{ matrix.label }}-py${{ matrix.python-version }}-conda-${{ hashFiles('environment.yml') }}-${{ env.DATE }}-${{ env.CACHE_NUMBER }}
path: ${{ env.CONDA }}/envs
key:
conda-${{ runner.os }}--${{ runner.arch }}--py${{ matrix.python-version }}--${{
steps.get-date.outputs.today }}-${{hashFiles('environment.yml') }}-${{ env.CACHE_NUMBER}}
env:
# Increase this value to reset cache if environment.yml has not changed
CACHE_NUMBER: 0
id: cache

- name: Update environment
Expand Down

0 comments on commit de76149

Please sign in to comment.