diff --git a/.github/ci.bazelrc b/.github/ci.bazelrc deleted file mode 100644 index 7f03bcd..0000000 --- a/.github/ci.bazelrc +++ /dev/null @@ -1,13 +0,0 @@ -# SPDX-License-Identifier: BSD-2-Clause - -# This file adjusts Bazel's configuration for CI jobs. - -# Dump configuration details to the log. -common --announce_rc=yes - -# Put the Bazel caches somewhere the CI runner will preserve them from one run -# to the next. (All of ~/.cache/bazel_ci/ is preserved.) -fetch --repository_cache /home/runner/.cache/bazel_ci/externals -build --repository_cache /home/runner/.cache/bazel_ci/externals -fetch --disk_cache /home/runner/.cache/bazel_ci/local_disk -build --disk_cache /home/runner/.cache/bazel_ci/local_disk diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 38c0e2a..cf6c910 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,64 +13,31 @@ on: jobs: bazel_test: runs-on: ubuntu-latest - env: - # This is where bazelisk caches its downloads of Bazel. - BAZELISK_HOME: /home/runner/.cache/bazel_ci/bazelisk steps: - uses: actions/checkout@v6 - name: Install Ubuntu dependencies run: .github/ci_setup.bash - # Restore the most appropriate caches. - # - # In the below: `github.ref` will be either "refs/pull//merge" - # or "refs/heads/main"; `github.run_number` is a monotonically increasing - # serial number; and `github.run_attempt` is a typically 1. - # - # The `key` declared here will never match (since it encodes the current - # run_number) but illustrates the name we'll use to save the caches when - # we're done. - # - # However, one of the `restore-keys` patterns *should* always match. The - # effects we should see from the `restore-keys` patterns are: - # - # * When building the `main` branch, we'll always pull the most recently - # updated main caches. Both restore keys say "pip-refs/heads/main-" and - # the prior archives are named, e.g., "pip-refs/heads/main-####-#". - # GitHub will use the *most recently saved* archive name that matches - # the restore key prefix (no matter the lexicographic ordering of - # the ####-# part). - # - # * Ditto for the first build of a PR; the first restore key will not - # match anything, so it falls back to the main caches. - # - # * For subsequent builds of a PR, the first restore key, e.g., - # "pip-refs/pull/###/merge-" should match the most recently saved PR key - # "pip-refs/pull/###/merge-####-#". - - uses: actions/cache/restore@v5 + # Use setup-bazel for disk and repository caching. + - uses: bazel-contrib/setup-bazel@0.15.0 with: - path: ~/.cache/pip - # N.B. The "-mumble" suffix below will never match; it's a placeholder - # for the nonce appended to the cache key. Instead, the restore-keys - # will always be used for restoring. - key: pip-${{ github.ref }}-${{ github.run_number }}-${{ github.run_attempt }} - restore-keys: | - pip-${{ github.ref }}- - pip-refs/heads/main- - - uses: actions/cache/restore@v5 - with: - path: ~/.cache/bazel_ci - key: bazel_ci-${{ github.ref }}-${{ github.run_number }}-${{ github.run_attempt }} - restore-keys: | - bazel_ci-${{ github.ref }}- - bazel_ci-refs/heads/main- - - name: Report cache sizes - run: | - du -ms ~/.cache/pip || true - du -ms ~/.cache/bazel_ci/* || true + # Use the cached Bazelisk version, or download if not found. + bazelisk-cache: true + # Enable the disk cache and share it across all workflows + # (i.e., across master and pull requests). + # We want all builds to start from a warm cache, and we're not too + # concerend about pull request builds "polluting" master builds. + disk-cache: true + # Share repository cache globally as well. If repository-cache is set to true, + # it uses the hash of a few bazel files as the key for the cache. You can set + # your own list of files to use to calculate the key by passing them below. + # Passing an empty string tells setup-bazel to use the same key + # every time, regardless of any changes to any files. + repository-cache: "" + # This dumps configuration details to the log. + bazelrc: common --announce_rc=yes # Actual testing. - name: Bazel Test run: | - ln -s .github/ci.bazelrc user.bazelrc ./bazel test //... # Save the test outputs to allow for eyeball verification when relevant. - name: Archive test outputs @@ -79,20 +46,6 @@ jobs: name: test_outputs path: | .bazel/testlogs/examples/ball_bin_test/test.outputs/outputs.zip - # Save the updated cache snapshots, so we never do the same work twice. - # By default, actions/cache only saves after a successful workflow, but - # our caches are bags of files where we only ever add new files (not change - # an existing files), so it's always safe to snapshot. - - uses: actions/cache/save@v5 - if: always() - with: - path: ~/.cache/pip - key: pip-${{ github.ref }}-${{ github.run_number }}-${{ github.run_attempt }} - - uses: actions/cache/save@v5 - if: always() - with: - path: ~/.cache/bazel_ci - key: bazel_ci-${{ github.ref }}-${{ github.run_number }}-${{ github.run_attempt }} install_test: runs-on: ubuntu-latest strategy: