Repository navigation
ci: save pre-commit cache only from the default branch - #3047
Conversation
The single actions/cache step saved a ~260 MB copy of identical hook environments on every PR merge ref (refs/pull/N/merge), which GitHub scopes per ref so no other run can read them. Split the step into cache/restore + cache/save and gate the save to the default branch, so PRs restore the shared cache but stop creating per-PR duplicates. Keep the full Python patch version in the primary key and add a minor-version restore-key prefix so a runner-image patch bump warm-starts from the previous cache and re-saves once, instead of exact-hitting a stale entry and rebuilding every run. Add "ctk-next" to the push triggers so the save also runs on the private mirror's default branch, keeping this file byte-identical across both repositories.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review. 📝 SummarySummary by CodeRabbit
WalkthroughThe pre-commit workflow now runs on pushes to ChangesPre-commit workflow
Suggested reviewers: Priority: ⬇️ Low Change: Other Merge Risk: ⚪ Minimal · up to The workflow preserves the intended cache-refresh behavior while limiting writes to the repository’s default branch. No actionable merge-blocking risk remains.
Comment |
|
/ok to test 5aebb5e |
|
Description
This is a CI infrastructure change; there is no separate tracking issue.
.github/workflows/pre-commit.ymlused a singleactions/cachestep that both restored and saved. GitHub scopes caches by ref, so every PR merge ref (refs/pull/N/merge) saved its own ~260 MB copy of identical hook environments that no other run can read, steadily consuming the per-repository cache quota.Changes:
actions/cache/restoreandactions/cache/save(same pinned SHA). Gate the save withgithub.ref_name == github.event.repository.default_branchso pull requests restore the shared cache but stop creating per-PR duplicates.!cancelled()keeps a push that fails lint from discarding the valid hook environments, and the save is skipped on an exact key hit to avoid re-saving identical content.restore-keysprefix. A runner-image patch bump (3.14.7->3.14.8) then misses the exact key, warm-starts from the previous cache via the prefix, and re-saves once, instead of exact-hitting a stale minor-only entry and rebuilding the hook environments on every run.ctk-nextto thepushbranches. It is the default branch of the private mirror, so the save also refreshes there; the branch does not exist upstream, so the trigger never fires here and this file stays byte-identical across both repositories.Net effect: each repository keeps about one Linux + one Windows entry instead of a pair per pull request, and the Windows cache is preserved.
Checklist