-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add caching to CI workflow #109
Changes from all commits
727e531
c1a2c99
2b87898
7ad47a7
d5b64f4
6cf4150
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,11 +13,38 @@ runs: | |
/#.*arch=/ && $0 ~ "arch="arch { print } | ||
' environment.yml > ci-environment.yml | ||
|
||
- uses: conda-incubator/setup-miniconda@v2 | ||
- name: Setup Mambaforge | ||
uses: conda-incubator/setup-miniconda@v2 | ||
with: | ||
miniforge-variant: Mambaforge | ||
miniforge-version: latest | ||
# Do not specify environment file - see Cache step below | ||
activate-environment: yardl | ||
environment-file: ci-environment.yml | ||
use-mamba: true | ||
|
||
- name: Get Date | ||
id: get-date | ||
shell: bash | ||
run: echo "DATE=$(date -u +'%Y%m%d')" >> $GITHUB_ENV | ||
|
||
- name: Cache Conda Env | ||
id: cache-conda | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ env.CONDA }}/envs | ||
key: | ||
conda-${{ runner.os }}--${{ runner.arch }}--${{ | ||
hashFiles('ci-environment.yml') }}-${{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to throw the conda version in there too? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it's necessary. The cache is invalidated every 24 hours, so within that time period, if the conda version changes and somehow the resolved set of packages for our There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense. |
||
env.DATE }}-${{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we want the date to be in the cache key? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding the date ensure the cache is updated daily to account for any changes in conda package versions. See https://github.com/marketplace/actions/setup-miniconda#caching-environments, which I essentially copied here. |
||
env.CONDA_CACHE_NUMBER }} | ||
|
||
- name: Update Environment | ||
shell: bash | ||
run: mamba env update -n yardl -f ci-environment.yml | ||
if: steps.cache-conda.outputs.cache-hit != 'true' | ||
|
||
|
||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.21.3' | ||
cache-dependency-path: tooling/go.sum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So at this point, we have an empty environment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the env always be updated in the last step, whether the cache exists or not.