Skip to content

ci: seed pnpm cache on main so PR branches get cache hits#1331

Merged
sorccu merged 1 commit into
mainfrom
simo/ci-seed-pnpm-cache-on-main
May 29, 2026
Merged

ci: seed pnpm cache on main so PR branches get cache hits#1331
sorccu merged 1 commit into
mainfrom
simo/ci-seed-pnpm-cache-on-main

Conversation

@sorccu
Copy link
Copy Markdown
Member

@sorccu sorccu commented May 29, 2026

Problem

The test workflow only triggered on pull_request, so the default branch (main) never ran an install job and never populated a pnpm store cache. GitHub only lets branches inherit caches created on the default branch, so every PR branch started cold and re-downloaded all dependencies from scratch.

Confirmed in CI logs for a recent PR — every job reported a miss and a full download:

pnpm cache is not found
Progress: resolved 631, reused 0, downloaded 631, added 631, done

The caching mechanics were already configured correctly in every job (pnpm/action-setup@v5actions/setup-node@v4 with cache: "pnpm"); the issue was purely that there was no default-branch cache to inherit.

Change

  • Add a push: branches: [main] trigger so lint + test run on main and seed the per-OS pnpm store cache. test runs on both ubuntu-latest and windows-latest-x64, so both the Linux-x64 and Windows-x64 caches that PR jobs (including the Windows e2e jobs) restore get warmed.
  • Gate the two e2e jobs to if: github.event_name == 'pull_request'. They hit the live Checkly API and consume secrets/quota, so they shouldn't run on every push to main — the cache is already seeded by lint + test.

After one main run lands, PRs that don't change pnpm-lock.yaml get a cache hit on their first run. (PRs that change the lockfile still cold-start, since the cache key is the lockfile hash — unavoidable.)

Notes

If the e2e - * jobs are configured as required status checks on main, this is still safe: a skipped required check counts as passing on push events.

🤖 Generated with Claude Code

The test workflow only ran on pull_request, so the default branch never
populated a pnpm store cache. GitHub only lets branches inherit caches
created on the default branch, so every PR branch started cold and
re-downloaded all dependencies from scratch ("pnpm cache is not found").

Add a push trigger on main so lint + test seed the per-OS pnpm store
cache (Linux-x64 and Windows-x64) that PR jobs inherit. The e2e jobs hit
the live Checkly API, so gate them to pull_request only.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sorccu sorccu merged commit 3f29011 into main May 29, 2026
7 checks passed
@sorccu sorccu deleted the simo/ci-seed-pnpm-cache-on-main branch May 29, 2026 06:50
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