Skip to content

ci: keep the Go build cache current - #3139

Merged
vishr merged 3 commits into
masterfrom
ci/go-cache
Oct 1, 2026
Merged

vishr merged 3 commits into
masterfrom
ci/go-cache

Conversation

@vishr

@vishr vishr commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

actions/setup-go keys its cache on the Go version and go.sum only. The first job to finish after a new Go release or a go.sum change saves the entry, and every later run hits that key and skips saving. Master CI is still restoring the entries saved on 2026-09-11 (Go 1.27.1, 54 MB on Linux), so everything that changed since then, including the router and middleware fixes in the September releases, recompiles in every run.

This replaces it with actions/cache restore and save, keyed per OS, architecture, Go version and job:

  • Each run restores the newest cache saved for its key prefix.
  • Runs other than pull requests (pushes to master, manual runs) save a new entry for the commit, so the cache follows master.
  • Pull requests only restore, which keeps cache storage bounded. A full race build cache compresses to about 80 MB.

Measured on this branch with two manual runs (first run cold, second run restoring):

Job Cold Warm (restore + step)
ubuntu-latest, Run Tests 26–34 s 1–2 s + 5–10 s
macos-latest, Run Tests 19–37 s 3–4 s + 6–11 s
windows-latest, Run Tests 52–108 s 6–12 s + 10–55 s
check, staticcheck 26 s 3 s + 5 s

For reference, the Run Tests steps on master's last push run took 8–32 s with the September cache.

The benchmark job doesn't use the cache: since #3140 it runs only on pull requests, which never save one.

https://claude.ai/code/session_01QKDYQr53zNKkR7nif2CAAq

actions/setup-go keys its cache on the Go version and go.sum only. The
first job to finish after a new Go release or a go.sum change saves the
entry, and every later run hits that key and skips saving. Master CI is
still restoring the entries saved on 2026-09-11 (Go 1.27.1), so
everything that changed since then recompiles in every run.

Replace it with actions/cache restore/save, keyed per OS, architecture,
Go version and job. Each run restores the newest cache saved for its key
prefix, and runs other than pull requests save a new entry for the
commit, so the cache tracks master. Pull requests only restore, which
keeps the repository's cache storage bounded. A full race build cache
compresses to about 80 MB.

Claude-Session: https://claude.ai/code/session_01QKDYQr53zNKkR7nif2CAAq
vishr added 2 commits October 1, 2026 15:20
Since #3140 the benchmark job runs only on pull requests, which never save a
cache, so its restore would always miss.

Claude-Session: https://claude.ai/code/session_01QKDYQr53zNKkR7nif2CAAq
@vishr
vishr merged commit e6b10d9 into master Oct 1, 2026
11 checks passed
@vishr
vishr deleted the ci/go-cache branch October 1, 2026 22:27
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