Skip to content

ci: save Go caches only from main and stop cancelled Test runs - #2440

Merged
rdimitrov merged 2 commits into
mainfrom
claude/confident-hawking-22ef71
Oct 20, 2026
Merged

rdimitrov merged 2 commits into
mainfrom
claude/confident-hawking-22ef71

Conversation

@rdimitrov

@rdimitrov rdimitrov commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

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:

  1. Cache quota. The repository's Actions cache sat at 10.7 GB of its 10 GB limit. setup-go with cache: true restores and saves in one step. So every PR whose go.sum hash 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, including go-race-*.
  2. Cancelled runs kept running. The Test job used if: always(), so a superseded run kept testing after it was cancelled and held the ci-…-<ref> concurrency group.

Cache inventory (2026-10-20, 21 entries, ~10.7 GB)

Size Ref Key prefix Saved by
1.86 GB PR 2439 setup-go-Linux-x64-…-8b77bd… k8s-e2e k8s e2e (kind)
1.76 GB PR 1935 setup-go-Linux-x64-…-8b77bd… k8s-e2e k8s e2e (kind)
1.70 GB main go-race-Linux-X64-go1.27.2-<sha> ci Test (race)
1.23 GB main setup-go-Linux-x64-…-5b6cf4… main-only setup-go job
1.13 GB main setup-go-Linux-x64-…-d3475a… ci SDK/Studio jobs
0.98 GB main setup-go-Linux-x64-…-6fb876… ci Doc validation
0.97 GB PR 2439 setup-go-Linux-x64-…-ab8010… ci MicroVM module (standalone)
0.91 GB main setup-go-macOS-arm64-…-d3475a… ci macOS jobs
0.71 GB main setup-go-Linux-x64-…-5682b5… ci Analysis/lint/fuzz/vuln/api-compat
0.47 GB main playwright-* (3) ci SDK browser jobs
0.50 GB PR + main node-cache-* (6) setup-node (pnpm/npm)
0.14 GB PR + main setup-go-…-e165b7…, …-5ba07b… ci provider/engine standalone
0.07 GB PR + main bun-*, golangci-lint.cache-* ci

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 a go.sum makes all ~8 setup-go key groups miss, and each one saves.

What changed

  • .github/actions/go-cache-restore (new composite): restores GOMODCACHE and GOCACHE under <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 on refs/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).
  • Every setup-go … cache: true job in ci.yml, k8s-e2e.yml, microvm-e2e.yml and perf.yml now uses cache: 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 -trimpath k8s-execution-go-*), go-microvm-e2e, go-perf. The go-race-* and k8s-execution-go-* caches are unchanged.
  • Test job: if: always() → if: ${{ !cancelled() }}. always() was there so the required Test (race) context reports even when changes fails. !cancelled() keeps that: the job still runs when changes fails, and its first step (test "$CHANGES_RESULT" = success) fails it. Only a cancelled run now skips it. The lint, studio-gate and user-docs-gate aggregators keep always(): they only report a result and finish in seconds. Step-level always() uses (artifact uploads, credential cleanup) are not changed.
  • microvm-ci-release_test.sh required the string environment/microvm/go.sum in 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's go-version-file instead.

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):

  • Cancellation. Run 39427961805's Test (race) was in progress when the empty commit landed at 13:09:59. The job was cancelled at 13:10:20 and the run closed at 13:11:00. The superseding run 39428090001 started its jobs at 13:11:01, so it waited about 1 minute instead of 10.5.
  • Race cache reaches the PR. In run 39428090001, Restore Go race cache logged Cache 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.
  • The failure, live. The earlier run (13:09:40) found no go-race-* entry at all. Between 13:00 and 13:09, PR 2435 saved ~5.6 GB of PR-scoped setup-go-* entries, total cache hit ~15 GB, and main's go-race-…cc34286 entry was evicted. The next main entry landed at 13:10:16.
  • No PR-scoped Go entries. After CI, k8s-e2e, MicroVM E2E and perf all finished green, refs/pull/2440/merge holds only setup-node/bun entries (~274 MB, not changed here). Every Save Go caches step 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)

  • PR-scoped setup-go entries: refs/pull/2439/merge …8b77bd… (1.86 GB) and …ab8010… (0.97 GB), refs/pull/1935/merge …8b77bd… (1.76 GB), and refs/pull/2439/merge …5ba07b…. No other ref can read them.
  • After this merges and one green main run seeds the new families: every 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.
  • Superseded go-race-…-<old sha> entries on main. Prefix restore always picks the newest.

Follow-ups (not in this PR)

  • Even when only main saves, main's families total about 10 GB once k8s and microVM entries exist. go-race also saves 1.7 GB per merge because its key is per-SHA. Keying it per go.sum plus a daily rotation, or merging go-docs into go-analysis, would leave headroom.

Checks

  • actionlint (pinned v1.7.7) passes.
  • GOOS=linux task lint passes. On macOS, task lint flags gosec G703 in environment/microvm/launch_ownership_darwin.go, a darwin-only file not changed here.
  • task lint:actions: every require in microvm-ci-release_test.sh passes. 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

rdimitrov and others added 2 commits October 20, 2026 16:08
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]>
@rdimitrov
rdimitrov merged commit 8ae7d90 into main Oct 20, 2026
47 checks passed
@rdimitrov
rdimitrov deleted the claude/confident-hawking-22ef71 branch October 20, 2026 15:23
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Oct 23, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant