ci: rotate bazel cache keys on module bumps - #366
Merged
Merged
Conversation
setup-bazel derives the cache key hash for both the repository cache and the disk cache from the `repository-cache` file list -- config.js spreads repositoryCacheFiles into diskCache.files, which the README does not mention. The default list covers only MODULE.bazel and WORKSPACE*, and neither changes when a module is bumped in known_good.json or in bazel_common/*.MODULE.bazel. So the key never rotated. post.js returns early when the restored key matches exactly, which means that after the very first save no run ever wrote a cache again: the disk cache kept serving the results of whatever module states happened to be current when it was created, and the repository cache rotated three times in three months while module states changed twenty times. Nothing ever failed, because Bazel addresses its entries by action key -- stale entries are simply never hit. List the files that actually invalidate action keys or the set of fetched module sources. Saving stays gated on push-to-main, so only the merge run pays the additional upload; measured against the existing repository cache that is roughly 90 seconds for 3.3 GB.
antonkri
requested review from
AlexanderLanin,
FScholPer,
MaximilianSoerenPollak,
PiotrKorkus,
dcalavrezo-qorix,
lurtz,
nradakovic,
opajonk and
pawelrutkaq
as code owners
September 24, 2026 10:42
|
The created documentation from the pull request is available at: docu-html |
Contributor
|
Are you aware that @AlexanderLanin is currently reworking bazel and caching with https://github.com/eclipse-score/cicd-actions/tree/main/setup-bazel-cache ? You might want to try and test that. |
PiotrKorkus
approved these changes
Sep 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
setup-bazelderives the cache key hash for both the repository cache and the disk cache from therepository-cachefile list. Fromconfig.jsin 0.18.0:The README describes this input as the repository-cache key only; the coupling to the disk-cache key exists in code but is undocumented.
Why the caches went stale
Neither
MODULE.bazelnorWORKSPACE*changes when we bump a module inknown_good.jsonorbazel_common/*.MODULE.bazel, so the key does not rotate on a module bump. Andpost.jsskips the save whenever the restored key was an exact match:Taken together: after the very first save, no run writes a cache again. The entry persists, keeps serving whatever module states happened to be current when it was created, and never fails - Bazel addresses its entries by action key, so stale content is simply never hit. The failure mode is a silent loss of reuse, not a wrong result.
Concrete evidence: the kyron bump in #364 produced disk-cache key
...4477fe5d..., byte-identical to the key in use before the bump. Over the last three months the repository cache rotated 3 times while module states changed 23 times.Change
List the files that actually invalidate Bazel action keys or the set of fetched module sources:
known_good.jsonandbazel_common/*.MODULE.bazel- module states and toolchain depspatches/**- patch contents alter module sources viabazel_patcheswithout necessarily touchingknown_good.json.bazelrc- build and test flags feed action keysWORKSPACE*is dropped because this repository has no such file under Bzlmod.**/BUILD.bazeland**/BUILDare appended by the action itself and remain in effect.No cold start on merge: the restore-key prefix is unchanged, so the first run still restores the existing content by prefix match and re-saves it under the new key.
Effect
Measured on run
35980109957, after the stale entry had been refreshed once by hand, against a re-run of an older PR on the same day and the same cache entry:baselibs, identical process totals in both runs:
Cost
Rotations on main over the last three months: 29 instead of 3. Saving stays gated on
pushtomain, so no PR run pays for it. The additional repository-cache upload measured roughly 90 seconds for 3.3 GB on the merge run.