Skip to content

ci(ENG-440): Populate main cache scope and add cargo restore-keys#76

Merged
alnoki merged 1 commit into
mainfrom
eng-440
Jun 12, 2026
Merged

ci(ENG-440): Populate main cache scope and add cargo restore-keys#76
alnoki merged 1 commit into
mainfrom
eng-440

Conversation

@alnoki

@alnoki alnoki commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Problem

The Tests CI job (.github/workflows/test.yml) spends ~6.5 min of its ~11 min on essentially every PR's first run installing Solana and building anchor-cli from source, before make test starts.

Root cause

A workflow run can only restore caches created on its own ref or on the repo's default branch (main) — never on a different PR's ref. test.yml triggered only on: pull_request, so the job never ran on a push to main and the main cache scope — the only scope every PR can read — was never populated. Every PR's caches lived on refs/pull/<N>/merge, invisible to other PRs, so each new PR missed and rebuilt the toolchain.

Secondary: the cargo cache key embedded hashFiles('Cargo.lock') with no restore-keys fallback, so any Cargo.lock change cold-compiled all deps.

Fix

  1. Run the job on push to main so a post-merge run saves both the toolchain cache (install-toolchain, key toolchain-solana-<ver>-anchor-<rev>-<platform>) and the cargo cache into the main scope that every subsequent PR inherits — eliminating the repeated ~6.5 min Anchor builds.
  2. Add restore-keys to the cargo cache so a dep bump restores the nearest prior cache and compiles incrementally instead of cold.

No new cache step or change to install-toolchain/action.yml needed — its key is already stable/version-pinned; it just needed the main scope populated, which fix #1 provides.

Verification

After this merges to main and a main run completes:

  1. On a throwaway PR, confirm the install-toolchain step logs a cache hit for toolchain-solana-... (no install-tools.sh run) and the cargo step hits or restores via restore-keys.
  2. gh cache list --json key,ref shows entries with ref: refs/heads/main.
  3. Total Tests wall-clock drops by roughly the ~6.5 min toolchain build.

@linear

linear Bot commented Jun 12, 2026

Copy link
Copy Markdown

ENG-440

@vercel

vercel Bot commented Jun 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dropset Ready Ready Preview, Comment Jun 12, 2026 12:12am

@alnoki alnoki changed the title ENG-440 ci(ENG-440): Populate main cache scope and add cargo restore-keys Jun 12, 2026
@alnoki alnoki marked this pull request as ready for review June 12, 2026 00:03
The Tests job triggers only on pull_request, so it never runs on push
to main and never populates the main cache scope — the only scope every
PR can read. Each PR's toolchain/cargo caches live on its own
refs/pull/<N>/merge ref, invisible to other PRs, so every new PR misses
and rebuilds anchor-cli from source (~6.5 min).

Add a push trigger on main so a post-merge run saves the toolchain and
cargo caches into the main scope that all subsequent PRs inherit.

Also add restore-keys to the cargo cache so a Cargo.lock change restores
the nearest prior cache and compiles incrementally instead of cold.
@alnoki alnoki merged commit 2bd50d5 into main Jun 12, 2026
5 checks passed
@alnoki alnoki deleted the eng-440 branch June 12, 2026 00:24
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