Skip to content

Commit

Permalink
build: fix ci build caching
Browse files Browse the repository at this point in the history
  • Loading branch information
kormide committed Jan 19, 2022
1 parent 08b3374 commit 7ca86a4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/ci.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,5 @@ build --announce_rc
# Don't rely on test logs being easily accessible from the test runner,
# though it makes the log noisier.
test --test_output=errors
# This directory is configured in GitHub actions to be persisted between runs.
build --disk_cache=$HOME/.cache/bazel
build --repository_cache=$HOME/.cache/bazel-repo
# Allows tests to run bazelisk-in-bazel, since this is the cache folder used
test --test_env=XDG_CACHE_HOME
23 changes: 14 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,23 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Mount bazel action cache
- 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.
XDG_CACHE_HOME: ~/.cache/bazel-repo
run: bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc test //...
run: |
bazel \
--bazelrc=.github/workflows/ci.bazelrc \
--bazelrc=.bazelrc \
test \
--disk_cache=${HOME}/.cache/bazel \
--repository_cache=${HOME}/.cache/bazel-repo \
//...
17 changes: 16 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,26 @@ 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
XDG_CACHE_HOME: ~/.cache/bazel-repo
run: bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc test //...
run: |
bazel \
--bazelrc=.github/workflows/ci.bazelrc \
--bazelrc=.bazelrc \
test \
--disk_cache=${HOME}/.cache/bazel \
--repository_cache=${HOME}/.cache/bazel-repo \
//...
- name: Prepare workspace snippet
run: .github/workflows/workspace_snippet.sh ${{ env.GITHUB_REF_NAME }} > release_notes.txt
- name: Release
Expand Down

0 comments on commit 7ca86a4

Please sign in to comment.