Repository navigation
setup: share one go mod cache per OS/arch, and keep it complete - #168
Merged
Merged
Conversation
- new `mod-cache-key-prefix` input, defaulting to `cache-key-prefix`, so a job with its own build cache (snapshot, race builds) can still restore the same mod cache as everything else - on a mod cache miss on the default branch, `go mod download` runs before the job so the saved cache is complete whichever job saves it first Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
`mod-cache-key-prefix` now defaults to `v1` rather than following `cache-key-prefix`, so every job on an OS/arch shares one mod cache with no caller changes. The download-on-miss step is what keeps that safe: whichever job saves the shared key leaves a complete cache. Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
wagoodman
marked this pull request as ready for review
October 23, 2026 16:55
spiffcs
approved these changes
Oct 23, 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.
The mod cache is keyed on
cache-key-prefix, the same prefix as the build cache, and any job on main can save it. Two problems come out of that, both visible across the org's repos today:go.sumchanges. In chronicle, a dependabot burst put four main runs in flight at once; Static analysis savedv1-X64-Linux-go-modwith 421 modules, that entry was gone minutes later (the repo sits at ~9.8/10GB), and Acceptance tests (Linux) re-saved the same key after downloading 4 modules. That 1MB entry has been live for six days, so every Linux job restores it, downloads everything, and fails to savesnapshotin most repos) also saves its own mod cache holding the same modules, ~0.8-0.9GB pergo.sumgeneration in grype, chronicle and grantWhat changes:
mod-cache-key-prefixinput, defaultv1, used for the mod cache instead ofcache-key-prefix. Every job on an OS/arch now shares one mod cache whatever its build prefix. Jobs already onv1keep their exact keys;snapshotjobs start reading the existingv1entrygo mod download(root and.make) runs before the job, so whichever job saves the shared key, including after an eviction, leaves a complete cacheWhat stays the same:
bootstrapwrappersTradeoffs:
go.sumchange. PRs never pay itcache-save: falseon that job is the opt-outcache-key-prefixno longer resets the mod cache; bumpmod-cache-key-prefixfor thatNot covered here, per repo and optional: a
concurrencygroup on validations so a dependabot burst leaves one run writing instead of several, and aligning the Go version between syft's/grype'sbootstrapwrappers and their directsetupcalls (grype has two Linux build caches per generation from that split). Stuck entries like chronicle's clear on the repo's nextgo.sumchange, or by deleting them.