ci: seed pnpm cache on main so PR branches get cache hits#1331
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
testworkflow only triggered onpull_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:
The caching mechanics were already configured correctly in every job (
pnpm/action-setup@v5→actions/setup-node@v4withcache: "pnpm"); the issue was purely that there was no default-branch cache to inherit.Change
push: branches: [main]trigger solint+testrun onmainand seed the per-OS pnpm store cache.testruns on bothubuntu-latestandwindows-latest-x64, so both the Linux-x64 and Windows-x64 caches that PR jobs (including the Windows e2e jobs) restore get warmed.e2ejobs toif: github.event_name == 'pull_request'. They hit the live Checkly API and consume secrets/quota, so they shouldn't run on every push tomain— the cache is already seeded bylint+test.After one
mainrun lands, PRs that don't changepnpm-lock.yamlget 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 onmain, this is still safe: a skipped required check counts as passing onpushevents.🤖 Generated with Claude Code