Skip to content

Commit

Permalink
Improve caching
Browse files Browse the repository at this point in the history
use buildbuddy for build cache
only write to non-build caches from master, which should save cache
space and increase hit rates.

Change-Id: I33464f548bd63ae790f328c58be767f48e62568b
  • Loading branch information
garymm committed Jan 18, 2024
1 parent 69f50ff commit 2501c9f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 21 deletions.
64 changes: 44 additions & 20 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: mount bazel disk cache
uses: actions/cache@v3
with:
path: "~/.cache/bazel_disk_cache"
key: bazel-disk-test-${{ matrix.toolchain }}-${{ matrix.feature }}
- name: set buildbuddy-api-key
run: |
echo 'build --remote_header=x-buildbuddy-api-key=${{ secrets.BUILDBUDDY_API_KEY }}' >> .bazelrc
- name: set bazel upload flags
if: github.ref != 'refs/heads/master'
run: |
echo 'build --noremote_upload_local_results' >> .bazelrc
- name: mount bazel other caches
# restore only on these jobs because GitHub free doesn't
Expand Down Expand Up @@ -57,11 +60,14 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: muont bazel disk cache
uses: actions/cache@v3
with:
path: "~/.cache/bazel_disk_cache"
key: bazel-disk-coverage
- name: set buildbuddy-api-key
run: |
echo 'build --remote_header=x-buildbuddy-api-key=${{ secrets.BUILDBUDDY_API_KEY }}' >> .bazelrc
- name: set bazel upload flags
if: github.ref != 'refs/heads/master'
run: |
echo 'build --noremote_upload_local_results' >> .bazelrc
- name: mount bazel other caches
# This is the only one that writes to the cache, not restore.
Expand All @@ -71,6 +77,18 @@ jobs:
# just taking advantage of the fact that this one is
# not a matrix and so only has one job.
uses: actions/cache@v3
if: github.ref == 'refs/heads/master'
with:
path: |
"~/.cache/bazel_install_base"
"~/.cache/bazel_output_base/external"
"~/.cache/bazel_repository_cache"
"~/.cache/bazelisk"
key: bazel-other

- name: mount bazel other caches
uses: actions/cache/restore@v3
if: github.ref != 'refs/heads/master'
with:
path: |
"~/.cache/bazel_install_base"
Expand Down Expand Up @@ -116,11 +134,14 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: muont bazel disk cache
uses: actions/cache@v3
with:
path: "~/.cache/bazel_disk_cache"
key: bazel-disk-build-${{ matrix.flag }}
- name: set buildbuddy-api-key
run: |
echo 'build --remote_header=x-buildbuddy-api-key=${{ secrets.BUILDBUDDY_API_KEY }}' >> .bazelrc
- name: set bazel upload flags
if: github.ref != 'refs/heads/master'
run: |
echo 'build --noremote_upload_local_results' >> .bazelrc
- name: mount bazel other caches
uses: actions/cache/restore@v3
Expand Down Expand Up @@ -152,11 +173,14 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: muont bazel disk cache
uses: actions/cache@v3
with:
path: "~/.cache/bazel_disk_cache"
key: bazel-disk-buildifier
- name: set buildbuddy-api-key
run: |
echo 'build --remote_header=x-buildbuddy-api-key=${{ secrets.BUILDBUDDY_API_KEY }}' >> .bazelrc
- name: set bazel upload flags
if: github.ref != 'refs/heads/master'
run: |
echo 'build --noremote_upload_local_results' >> .bazelrc
- name: mount bazel other caches
uses: actions/cache/restore@v3
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/ci.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ build --color=yes
build --show_timestamps
build --terminal_columns=120

common --disk_cache=/home/runner/.cache/bazel_disk_cache
# remote cache through buildbuddy
build --bes_results_url=https://app.buildbuddy.io/invocation/
build --bes_backend=grpcs://remote.buildbuddy.io
build --remote_cache=grpcs://remote.buildbuddy.io
build --remote_timeout=3600

common --repository_cache=/home/runner/.cache/bazel_repository_cache

startup --host_jvm_args=-Xmx2500m # avoid blowing up the RAM usage.
Expand Down

0 comments on commit 2501c9f

Please sign in to comment.