Skip to content

workflows: improve Bazel CI caching#134

Open
copybara-service[bot] wants to merge 1 commit intomainfrom
copybara/904309390
Open

workflows: improve Bazel CI caching#134
copybara-service[bot] wants to merge 1 commit intomainfrom
copybara/904309390

Conversation

@copybara-service
Copy link
Copy Markdown

@copybara-service copybara-service Bot commented Apr 23, 2026

workflows: improve Bazel CI caching

The Bazel workflows use setup-bazel's built-in disk-cache feature,
which includes a hash of all BUILD files in the GitHub Actions cache
key. Since Bazel's disk cache is already content-addressed, this hash
is redundant: Bazel itself ignores stale entries whose action hashes no
longer match. The effect is that the entire disk cache (~258 MB on
Linux, ~1.7 GB on Windows) is re-uploaded whenever any BUILD file
changes, quickly exhausting GitHub's 10 GB per-repository cache limit
and evicting older entries.

Replace setup-bazel's disk-cache with a manual actions/cache@v4 step
using stable, branch-based keys. Because actions/cache entries are
immutable (a matching primary key is never re-uploaded), include the
ISO week number in the key so the cache rotates weekly. On a miss,
restore-keys prefix matching falls back to the previous week's cache
or the main branch's cache, avoiding a fully cold build.

See: bazel-contrib/setup-bazel#18

@copybara-service copybara-service Bot force-pushed the copybara/904309390 branch 2 times, most recently from e0b9cbd to 420e527 Compare April 23, 2026 16:20
The Bazel workflows use setup-bazel's built-in disk-cache feature,
which includes a hash of all BUILD files in the GitHub Actions cache
key.  Since Bazel's disk cache is already content-addressed, this hash
is redundant: Bazel itself ignores stale entries whose action hashes no
longer match.  The effect is that the entire disk cache (~258 MB on
Linux, ~1.7 GB on Windows) is re-uploaded whenever any BUILD file
changes, quickly exhausting GitHub's 10 GB per-repository cache limit
and evicting older entries.

Replace setup-bazel's disk-cache with a manual actions/cache@v4 step
using stable, branch-based keys.  Because actions/cache entries are
immutable (a matching primary key is never re-uploaded), include the
ISO week number in the key so the cache rotates weekly.  On a miss,
restore-keys prefix matching falls back to the previous week's cache
or the main branch's cache, avoiding a fully cold build.

See: bazel-contrib/setup-bazel#18
PiperOrigin-RevId: 904309390
@copybara-service copybara-service Bot changed the title workflows: improve CI caching and local build performance workflows: improve Bazel CI caching Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant