Skip to content

Commit

Permalink
Cache conda environment instead of packages
Browse files Browse the repository at this point in the history
  • Loading branch information
naegelejd committed Nov 22, 2023
1 parent c1a2c99 commit 2b87898
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
35 changes: 26 additions & 9 deletions .github/actions/configure-environment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,35 @@ runs:
/#.*arch=/ && $0 ~ "arch="arch { print }
' environment.yml > ci-environment.yml
- uses: actions/cache@v2
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v2
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ hashFiles('ci-environment.yml') }}
restore-keys: |
${{ runner.os }}-conda-
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: yardl
# environment-file: ci-environment.yml
use-mamba: true

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

- uses: conda-incubator/setup-miniconda@v2
- name: Cache Conda Env
uses: actions/cache@v2
with:
activate-environment: yardl
environment-file: ci-environment.yml
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
path: ${{ env.CONDA }}/envs
key:
conda-${{ runner.os }}--${{ runner.arch }}--${{
steps.get-date.outputs.today }}-${{
hashFiles('ci-environment.yml') }}-${{
env.CONDA_CACHE_NUMBER }}
# key: ${{ runner.os }}-conda-${{ hashFiles('ci-environment.yml') }}
id: cache

- name: Update Environment
run: mamba env update -n yardl -f ci-environment.yml
if: steps.cache.outputs.cache-hit != 'true'


- uses: actions/setup-go@v4
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ defaults:
# See https://github.com/marketplace/actions/setup-miniconda#important
shell: bash -el {0}

env:
# Increase this to reset cache manually
CONDA_CACHE_NUMBER: 0

jobs:
validate:
strategy:
Expand All @@ -39,7 +43,7 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: "1.21.3"
cache-dependency-path: tooling/go.sum
Expand Down Expand Up @@ -137,7 +141,7 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: "1.21.3"
cache-dependency-path: tooling/go.sum
Expand Down

0 comments on commit 2b87898

Please sign in to comment.