From 51a2ddbab9ae6f28de98061045199a9142588c4d Mon Sep 17 00:00:00 2001 From: Gary Miguel Date: Wed, 17 Jan 2024 21:31:27 -0800 Subject: [PATCH] only write to cache from master (#128) this save disk space and should help cache hit rates --- .bazelrc | 4 +++ .github/workflows/check.yml | 64 +++++++++++++++++++++++++----------- .github/workflows/ci.bazelrc | 7 +++- 3 files changed, 54 insertions(+), 21 deletions(-) diff --git a/.bazelrc b/.bazelrc index 16d1e55..f4d24a0 100644 --- a/.bazelrc +++ b/.bazelrc @@ -35,3 +35,7 @@ coverage --combined_report=lcov coverage --experimental_generate_llvm_lcov # Needed because our tests are in a different package than the code they test. coverage --instrumentation_filter='//.*' + +# buildbuddy suggestions. Doesn't hurt to have them always. +build --nolegacy_important_outputs +build --remote_cache_compression diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 84f728f..cbdb894 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -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 @@ -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. @@ -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" @@ -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 @@ -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 diff --git a/.github/workflows/ci.bazelrc b/.github/workflows/ci.bazelrc index 52e7b72..99b0425 100644 --- a/.github/workflows/ci.bazelrc +++ b/.github/workflows/ci.bazelrc @@ -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.