Skip to content

Commit

Permalink
build: fix ci cacheing to use recently built caches
Browse files Browse the repository at this point in the history
  • Loading branch information
kormide committed Jan 18, 2022
1 parent dec8cc5 commit c3adac5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
21 changes: 13 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,21 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Mount bazel action cache
# Cache build and external artifacts so that the next ci build is incremental.
# Because caches cannot be updated, create a new cache based on the contents of
# hashFiles (modify this to capture sources in your repo that would cause bazel
# to rebuild artifacts, but it doesn't have to be perfect). On a cache miss, the
# restore-keys prefix will load the most recent bazel cache for the current branch
# or its parent. After the build, the new cache will be stored which will be used
# on the next build, and so forth.
- name: Mount bazel caches
uses: actions/cache@v2
with:
path: "~/.cache/bazel"
key: bazel
- name: Mount bazel repo cache
uses: actions/cache@v2
with:
path: "~/.cache/bazel-repo"
key: bazel-repo
path: |
"~/.cache/bazel"
"~/.cache/bazel-repo"
key: bazel-cache-${{ hashFiles('**/BUILD.bazel', '**/*.bzl', 'WORKSPACE') }}
restore-keys: bazel-cache-
- name: bazel test //...
env:
# Bazelisk will download bazel to here, ensure it is cached between runs.
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Mount bazel caches
uses: actions/cache@v2
with:
path: |
"~/.cache/bazel"
"~/.cache/bazel-repo"
key: bazel-cache-${{ hashFiles('**/BUILD.bazel', '**/*.bzl', 'WORKSPACE') }}
restore-keys: bazel-cache-
- name: bazel test //...
env:
# Bazelisk will download bazel to here
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Ready to get started? Copy this repo, then
1. rename directory "mylang" similarly
1. run `pre-commit install` to get lints (see CONTRIBUTING.md)
1. if you don't need to fetch platform-dependent tools, then remove anything toolchain-related.
1. update the `actions/cache@v2` bazel cache key in [.github/workflows/ci.yaml](.github/workflows/ci.yaml) and [.github/workflows/release.yml](.github/workflows/release.yml) to be a hash of your source files.
1. delete this section of the README (everything up to the SNIP).

---- SNIP ----
Expand Down

0 comments on commit c3adac5

Please sign in to comment.