Repository navigation
ci: save Go caches only from main and stop cancelled Test runs - #2440
Merged
Merged
Conversation
PR runs saved 1-2 GB setup-go entries whenever their go.sum hash was absent on main (k8s e2e, standalone modules, any dependency bump). Those PR-scoped entries are readable by that PR alone and pushed the repository past its 10 GB cache quota, evicting the main entries every PR restores, including the Test (race) cache. Replace setup-go's built-in cache in ci, k8s-e2e, microvm-e2e and perf with two local composite actions: go-cache-restore restores a <family>-<os>-<arch>-<go>-<go.sum hash> key with a family-prefix fallback, and go-cache-save saves it only on main when the exact key missed. Families stay distinct where build flags or modules differ. The Test job now uses !cancelled() instead of always(). It still runs when the classifier fails, so the required context reports and fails, but a superseded run no longer keeps testing and holding the concurrency group. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merged
2 tasks
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.
Why
Since the CI speed-ups merged, PR CI wall-clock went up, not down. Every post-merge PR run missed the Test (race) cache (16-24 min instead of ~6.5 min warm). Two causes:
setup-gowithcache: truerestores and saves in one step. So every PR whosego.sumhash had no main entry saved a 1-2 GB PR-scoped entry that only that PR can read. Under the quota, GitHub evicted main's entries, includinggo-race-*.if: always(), so a superseded run kept testing after it was cancelled and held theci-…-<ref>concurrency group.Cache inventory (2026-10-20, 21 entries, ~10.7 GB)
setup-go-Linux-x64-…-8b77bd…k8s e2e (kind)setup-go-Linux-x64-…-8b77bd…k8s e2e (kind)go-race-Linux-X64-go1.27.2-<sha>Test (race)setup-go-Linux-x64-…-5b6cf4…setup-go-Linux-x64-…-d3475a…setup-go-Linux-x64-…-6fb876…Doc validationsetup-go-Linux-x64-…-ab8010…MicroVM module (standalone)setup-go-macOS-arm64-…-d3475a…setup-go-Linux-x64-…-5682b5…playwright-*(3)node-cache-*(6)setup-go-…-e165b7…,…-5ba07b…bun-*,golangci-lint.cache-*PR-scoped Go entries: 4.6 GB of the 10.7 GB. The biggest per-PR savers are k8s-e2e's
k8s e2e (kind)job (no main entry exists for its key) and the standalone-module jobs. Any PR that changes ago.summakes all ~8 setup-go key groups miss, and each one saves.What changed
.github/actions/go-cache-restore(new composite): restoresGOMODCACHEandGOCACHEunder<family>-<os>-<arch>-<go version>-<hash of every tracked go.sum>. On an exact miss it falls back to the newest entry with the same family prefix, which the old setup-go key could not do..github/actions/go-cache-save(new composite): saves only outside pull requests onrefs/heads/main, and only when the exact key missed. This is the same rule ci: restore the race test cache by prefix and save it only from main #2437 uses for Test (race).setup-go … cache: truejob inci.yml,k8s-e2e.yml,microvm-e2e.ymlandperf.ymlnow usescache: false+ restore + save (20 + 1 + 3 + 2 jobs). Families stay distinct where flags or modules differ:go-sdk,go-build,go-analysis,go-docs,go-{engine,microvm,provider}-standalone,go-k8s-e2e(non-trimpath, separate from the execution job's-trimpathk8s-execution-go-*),go-microvm-e2e,go-perf. Thego-race-*andk8s-execution-go-*caches are unchanged.if: always()→if: ${{ !cancelled() }}.always()was there so the requiredTest (race)context reports even whenchangesfails.!cancelled()keeps that: the job still runs whenchangesfails, and its first step (test "$CHANGES_RESULT" = success) fails it. Only a cancelled run now skips it. Thelint,studio-gateanduser-docs-gateaggregators keepalways(): they only report a result and finish in seconds. Step-levelalways()uses (artifact uploads, credential cleanup) are not changed.microvm-ci-release_test.shrequired the stringenvironment/microvm/go.sumin ci.yml as a stand-in for "the cache key covers the nested module". The key now hashes every go.sum, so the check now requires the nested module'sgo-version-fileinstead.Release, continuous, e2e-live and the mecatequi workflows don't run on pull requests, so they are not changed.
Evidence
Before (cancelled run kept running): On PR 2439, run 39423538370 was cancelled at 12:38:55. Its Test job kept running until 12:49:02. The next run (39423848832, created 12:38:37) only started its jobs at 12:49:17, about 10.5 minutes blocked.
After (this PR's runs):
Restore Go race cacheloggedCache restored from key: go-race-Linux-X64-go1.27.2-fa79be7…(1.9 GB, 35 s). 145 of 193 packages were(cached)and Test (race) took 8.2 min.go-race-*entry at all. Between 13:00 and 13:09, PR 2435 saved ~5.6 GB of PR-scopedsetup-go-*entries, total cache hit ~15 GB, and main'sgo-race-…cc34286entry was evicted. The next main entry landed at 13:10:16.refs/pull/2440/mergeholds only setup-node/bun entries (~274 MB, not changed here). EverySave Go cachesstep was skipped on the PR. The new families missed on this PR as expected, because main has no entries for them until this merges.Prune candidates (not deleted; your call)
refs/pull/2439/merge…8b77bd…(1.86 GB) and…ab8010…(0.97 GB),refs/pull/1935/merge…8b77bd…(1.76 GB), andrefs/pull/2439/merge…5ba07b…. No other ref can read them.setup-go-*entry on main (about 5 GB). Nothing will restore those keys any more, so they age out after 7 days anyway, but they hold quota until then.go-race-…-<old sha>entries on main. Prefix restore always picks the newest.Follow-ups (not in this PR)
go-racealso saves 1.7 GB per merge because its key is per-SHA. Keying it per go.sum plus a daily rotation, or merginggo-docsintogo-analysis, would leave headroom.Checks
actionlint(pinned v1.7.7) passes.GOOS=linux task lintpasses. On macOS,task lintflags gosec G703 inenvironment/microvm/launch_ownership_darwin.go, a darwin-only file not changed here.task lint:actions: everyrequireinmicrovm-ci-release_test.shpasses. Its darwin-arm64 host-entrypoint step fails locally on the macOS release-defaults check, which this PR doesn't touch. CI runs it on Linux.🤖 Generated with Claude Code