Skip to content

[go] keep CI build caches warm - #1541

Merged
bgentry merged 1 commit into
masterfrom
bg/improve-go-ci-cache
Oct 25, 2026
Merged

bgentry merged 1 commit into
masterfrom
bg/improve-go-ci-cache

Conversation

@bgentry

@bgentry bgentry commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Go verification, benchmark, and test jobs currently share an immutable setup-go cache. In the baseline CI run, the Postgres race job restores a 9 MB archive, downloads dependencies again, and cannot save its new builds because the cache key already exists. CLI, lint, and submodule checks also install Go before checkout, so dependency-cache lookup reports missing files.

Centralize the policy in a documented “Set up Go for CI” composite action. Share module downloads across Go versions and workloads, with the primary full suite as the Linux writer and the CLI as the only Windows workload. Give build archives separate runner, toolchain, workload, database-version, and race scopes. Hash all modules' manifests/checksums, workspace metadata, and relevant source/configuration inputs so immutable archives can refresh. Restore compatible earlier builds as a fallback. Race and standard artifacts can safely coexist in Go's own cache; separate archives keep both workloads warm. Database-version scopes also prevent reusing test results against a different external server.

Use the action for Go CI and the Go helpers in port workflows, after checkout. Comments explain the inputs, key components, restore order, and why only cache paths need the job environment for nested post-job saves. Existing monthly Dependabot scans cover local actions, including underlying major action updates; filtered workflows now run when this action changes. Test concurrency, selection, and timeouts remain unchanged.

Measured on hosted runners using the same Go/test sources, Go 1.27.3, and Ubuntu image 20261012.334.1: compare the baseline with the warm rerun. Whole-job durations include runner/service setup and cache restore/post steps.

Workload Whole job: before → warm Main step: before → warm
Postgres 18, race 3m50s → 49s 3m24s → 7s
Postgres 17, standard 2m42s → 42s 2m19s → 4s
SQLite, race 1m32s → 19s 1m18s → 1s
Benchmark 1m54s → 1m10s 1m25s → 33s
Lint 1m45s → 51s 1m26s → 28s
CLI, Linux 1m15s → 47s 32s → 1s

The initial race cache fill takes 3m21s, with a 2m46s test step, and successfully saves both archives. Its warm rerun has 53 cached package results and no dependency downloads. These are warm, unchanged-source results: changed packages and their dependents still rebuild/rerun. The benchmark step executes its benchmarks on every run, so its improvement demonstrates compilation/download reuse separately from cached test results.

The Linux module archive is about 182 MiB compressed, stored once rather than copied into each build archive. Representative build archives are about 94–104 MiB. More workload/source-specific archives consume additional cache capacity and remain subject to GitHub's normal eviction policy.

The Java workflow failure is caused by stale Maven Central prefix metadata restored from its immutable dependency cache. PR #1542 refreshes only that auto-discovered index, preserving dependency artifacts, repository filters, and the strict warning policy. It reproduces the failure and verifies the fix separately from this Go caching change.

Verification and test jobs share an immutable dependency-keyed cache.
Small verification builds can freeze that archive without the artifacts
needed by the full suites, so later jobs repeat downloads and compilation.

Separate shared module downloads from workload-specific build caches.
Include workspace and module metadata in dependency keys, and refresh
build archives after Go, SQL, fixture, and CI input changes. Retain exact
toolchain, runner, database version, and race scopes when restoring older
builds. Let only the primary full suite publish module downloads.

Use the documented setup action across Go jobs and port fixture helpers.
Check out sources before setup so local action loading and dependency
hashing work. Include the action in filtered workflows and the existing
monthly Dependabot coverage.
@bgentry
bgentry force-pushed the bg/improve-go-ci-cache branch from c2c274f to e2b499e Compare October 25, 2026 13:59
@bgentry
bgentry marked this pull request as ready for review October 25, 2026 14:17
@bgentry
bgentry merged commit de19057 into master Oct 25, 2026
74 of 82 checks passed
@bgentry
bgentry deleted the bg/improve-go-ci-cache branch October 25, 2026 14:52
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.

2 participants