Repository navigation
perf(ci): stop duplicating shared Linux download caches - #23578
Conversation
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Shared Electron archive for Linux PRs —
install-node-dependenciessplits the archive cache into a savingactions/cache@v5step (non-PR, or non-Linux) and a restore-onlyactions/cache/restore@v5step for Linux pull requests, so PRs reuse the archive warmed on main without uploading their own copy. - Warmup seeds the shared archive —
ci-cache-warmup.yml'swarmandwarm-linux-armjobs opt intocache-electron-packageand runinstall-electron-package-binary.mjs, producing the x64 and ARM64 keys. - Linux electron-builder PR cache is restore-only —
pr.yml's package job now restoreselectron-builder-linux-*with no post-job save;release-cutstays the writer. - Closed-PR cleanup workflow — new
pull_request_target: closedjob deletes only caches scoped torefs/pull/<n>/merge, runs trusted default-branch code without checkout, validates every returned ref, and tolerates 404 eviction races. - Contract tests updated — pinned
if:/usesassertions across four existing tests plus a newci-closed-pr-caches.test.mjsthat exercises exact-ref, default-branch-refusal, 404, and 403 cases.
I read the full diff, traced the touched actions/workflows, and ran the affected config/scripts contracts (41 files / 599 tests) — all pass. The security posture checks out: the cleanup never checks out or executes PR source, and deleting by refs/pull/<n>/merge cannot reach main caches. The Dependabot read-only token restriction applies to pull_request/push/review events, not pull_request_target, so the cleanup retains actions: write for fork and Dependabot closes.
ℹ️ Closed-PR cleanup is best-effort under in-flight runs
The cleanup runs at closed, but closing a PR does not cancel its running workflows. A run still finishing can execute its post-job cache save (the native-modules cache is still saved on PRs) after the deletion loop completes, leaving a fresh orphan under the same merge ref. I don't think this needs a change — the 7-day eviction catches it, and the strict ref check already favors safety over completeness — but it's worth knowing the cleanup is not a hard guarantee.
Technical details
# Closed-PR cleanup can be undone by an in-flight PR run
## Affected sites
- `.github/workflows/ci-closed-pr-caches.yml:16-33` — the deletion loop runs once, on the `closed` event.
- `.github/actions/install-node-dependencies/action.yml:218-227` — `Restore compiled native modules` (`actions/cache@v5`, `native-cache-restore`) still registers a post-job save for PR events (`persist-native-cache` defaults to `true`), so a mid-flight PR job can save after cleanup.
## Required outcome
- None required for this PR; documenting the race so future maintenance does not assume the sweep is exhaustive.
## Open questions for the human
- Is a follow-up sweep (or the existing 7-day eviction) considered sufficient for any residual merge-ref caches?DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

ELI5
CI keeps uploading copies of downloads that other PRs cannot use. Share the Linux downloads from main and remove disposable PR caches when the PR closes, freeing space for reusable caches.
What Changed
Why
A 193-entry snapshot on 2026-09-28 totaled 10.86 GB. The main pnpm stores accounted for 4.19 GB and were actively reused, so they are retained. The avoidable duplicates were:
The completed Linux package job restored the shared 78 MiB builder archive in two seconds, then spent three seconds uploading another PR copy. This change removes that upload and duplicate storage, rather than removing useful caching. Native builds, package checks, and tests remain intact. The audit also found 334 MB of Ruby caches and 294 MB of xterm inputs; those are not blanket-deleted while PRs are open.
Linked Issue
N/A — maintainer-requested CI capacity work. Follows #23568.
Visual Proof
N/A — CI and cache lifecycle only.
Testing
366 workflow tests passed across 21 files; 35 relevant tests passed again after limiting archive sharing to Linux. Actionlint passes for the warmup and cleanup workflows. Existing PR workflow extensions (
background/wait) are covered by repository tests because the installed actionlint does not support them. Cleanup tests cover the exact PR ref, refusal to delete a main cache, 404 races, and non-404 errors. Hosted warmup run: both Linux warmups passed. Populating the Electron archive took 2 seconds on x64 and 3 seconds on ARM in the existing jobs; the ARM job also passed its Node native-cache probe afterward. Main saves are not enabled on this PR validation run. Hosted Linux packaging job passed: shared archive restore took 1 second, with no post-job archive upload (baseline: 2-second restore + 3-second duplicate save). All normal CI checks passed before merge (full run).Review
Compared the merge result against main after #23568 merged: only the nine intended cache/workflow/test files change, and those files are byte-identical to the tested PR head. The parent commits may still appear in GitHub’s comparison because the parent was squash-merged.
Confirmed main and PR electron-builder entries have the same cache version (path/archive format), not merely similar keys. Archive keys remain platform/architecture/version-specific. The new cleanup token has only
actions: write; the workflow never checks out or executes PR source. No native ABI, runtime behavior, test coverage, SSH, folder-workspace, or mobile protocol changes.Agent skill upstream boundary
Checklist
Post-merge verification
Both Linux jobs in the main warmup passed. The missing main ARM Electron archive was published with the same key and cache-format version as the redundant PR copies. The production closed-PR cleanup passed and removed 11 caches for this PR.
Manual cleanup deleted 53 entries totaling 3,910,742,622 bytes (3.91 GB): 34 closed-PR entries, then 19 duplicate Electron archives only after the matching main archive existed. The active main pnpm stores and useful native caches were retained. Concurrent jobs can add entries, so this is the size deleted, not a claim that the live usage counter fell by exactly that amount.