Skip to content

ci: warm test-bench cache on push to main#19968

Merged
AskAlexSharov merged 1 commit intomainfrom
anacrolix/benchmark-workflow-caching
Mar 18, 2026
Merged

ci: warm test-bench cache on push to main#19968
AskAlexSharov merged 1 commit intomainfrom
anacrolix/benchmark-workflow-caching

Conversation

@anacrolix
Copy link
Copy Markdown
Contributor

Problem

test-bench only triggered on pull_request, so there was never a base-branch cache on main. GitHub's cache isolation allows workflow runs to fall back to the base branch — but not to other PRs or branches. Without a main cache:

  • Every new PR's first push starts completely cold (full module download + recompile)
  • Merge-queue runs (merge_group) also start cold — they can read from main but not from other PRs
  • Caches saved during merge-group runs are stored under the temporary gh-readonly-queue/... branch and become inaccessible once the merge group completes; they never contribute to main

Fix

Add push triggers for main and release/**. After each merge, a cache-warming run compiles all test binaries and saves them under the main branch scope. Future PR first-pushes and merge-queue runs restore from that warm cache.

On non-pull_request events, the benchmark execution step is replaced with go test -run=^$ ./... — this compiles every test binary (producing identical GOCACHE entries) but runs nothing. The job always succeeds on main because correctness is already guaranteed by the merge queue before the commit lands.

Also adds workflow_dispatch (required by project guidelines) and documents the cache isolation model and compile-only warming pattern in .github/README.md.

test-bench previously only triggered on pull_request, so there was never
a base-branch cache on main. Every new PR and merge-queue run started
cold, because GitHub's cache isolation only allows fallback to the base
branch — not to other PRs or branches.

Add push triggers for main and release/** so that after each merge a
cache-warming run compiles all test binaries (GOCACHE + GOMODCACHE) and
saves them under the main branch scope. PR first-pushes and merge-queue
runs can then restore from that warm cache instead of starting cold.

On non-pull_request events the benchmark step is skipped and replaced
with `go test -run=^$ ./...`, which compiles every test binary but runs
nothing. Correctness is already guaranteed by the merge queue before
commits land on main, so re-running benchmarks there is unnecessary.

Also add workflow_dispatch for manual triggering (required by project
guidelines), and document the cache isolation model and the
compile-only warming pattern in .github/README.md.
@AskAlexSharov AskAlexSharov enabled auto-merge (squash) March 18, 2026 04:32
@AskAlexSharov AskAlexSharov merged commit 1c416b3 into main Mar 18, 2026
34 checks passed
@AskAlexSharov AskAlexSharov deleted the anacrolix/benchmark-workflow-caching branch March 18, 2026 04:33
mh0lt pushed a commit that referenced this pull request Mar 18, 2026
## Problem

`test-bench` only triggered on `pull_request`, so there was never a
base-branch cache on `main`. GitHub's cache isolation allows workflow
runs to fall back to the base branch — but not to other PRs or branches.
Without a `main` cache:

- Every new PR's first push starts completely cold (full module download
+ recompile)
- Merge-queue runs (`merge_group`) also start cold — they can read from
`main` but not from other PRs
- Caches saved during merge-group runs are stored under the temporary
`gh-readonly-queue/...` branch and become inaccessible once the merge
group completes; they never contribute to `main`

## Fix

Add `push` triggers for `main` and `release/**`. After each merge, a
cache-warming run compiles all test binaries and saves them under the
`main` branch scope. Future PR first-pushes and merge-queue runs restore
from that warm cache.

On non-`pull_request` events, the benchmark execution step is replaced
with `go test -run=^$ ./...` — this compiles every test binary
(producing identical GOCACHE entries) but runs nothing. The job always
succeeds on `main` because correctness is already guaranteed by the
merge queue before the commit lands.

Also adds `workflow_dispatch` (required by project guidelines) and
documents the cache isolation model and compile-only warming pattern in
`.github/README.md`.
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