Skip to content

ci(cache): prune Actions cache entries nothing can restore - #853

Merged
gHashTag merged 1 commit into
mainfrom
ci/actions-cache-prune
Oct 4, 2026
Merged

gHashTag merged 1 commit into
mainfrom
ci/actions-cache-prune

Conversation

@gHashTag

@gHashTag gHashTag commented Oct 4, 2026

Copy link
Copy Markdown
Owner

Part of #851 and #844. It works together with #852: that PR makes the chipdb cache able to hit, and this one makes room so the entry survives.

What was wrong

Live read of actions/caches on 2026-10-04:

What this adds

actions-cache-prune.yml runs hourly, when a pull request closes, and on demand. On demand it is a dry run by default. It deletes two kinds of entry:

  1. Every entry on the merge ref of a closed pull request, or on a branch that no longer exists.
  2. For keys that end in a run id, every entry except the newest of its series on the same ref. setup-zig restores by prefix, which takes the newest match, so the older entries are never read.

It keeps fixed keys (setup-zig-tarball-*, the chipdb keyed on part and image from #852) and the newest entry of each series on every live ref.

The rules live in .github/scripts/cache-prune.js. The job checks out the default branch, runs the rules' tests, and only then deletes anything. It does not use the closed pull request's merge ref, because that ref may already be gone and should not decide what gets deleted. actions-cache-prune-test.yml runs the same tests on any pull request that changes the rules.

Evidence

Not measured

🤖 Generated with Claude Code

The repository's Actions cache sat at its 10 GB limit with Zig caches that can
never be read again, and evicted every chipdb (#843). Two kinds of entry are
dead weight:

- entries saved on a closed pull request's merge ref (or a deleted branch):
  only that ref could restore them;
- older entries of a key that ends in the run id. mlugg/setup-zig saves one per
  run and restores by prefix, which takes the newest, so the older ones in the
  same series on the same ref are never read.

actions-cache-prune runs hourly, when a pull request closes, and on demand
(dry run by default). The rules are a plain function in
.github/scripts/cache-prune.js; the job runs its 14 node tests before it
deletes anything, and actions-cache-prune-test runs them on any pull request
that changes them. 12 of 12 mutants of the rules are killed by the tests.

Dry run against the live repository on 2026-10-04: 161 entries, 10.73 GB;
it would drop 139 (9.00 GB) and keep 22 (1.73 GB). 100 of the dropped belong
to the closed pull requests #828, #839, #840 and #841; 39 are superseded
setup-zig entries on main.

Part of #851 and #844.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown

X Brain Health Check

Score: 100.0/100
Status: 🟢 HEALTHY
Threshold: 80/100

X Brain is above merge threshold

@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown

🧪 Brain Stress Test Results

Score: not measured (no stress test prints a Score: line)
Status: 🟢 PASS
Threshold: 270/300

X Stress test passed

@gHashTag
gHashTag merged commit e57c154 into main Oct 4, 2026
50 checks passed
dmitrii-f-t27 pushed a commit that referenced this pull request Oct 10, 2026
The prune from #853 keeps the newest entry of every series on every live
ref. On 2026-10-05 that alone came to 7.97 GB (130 entries), and the
saves between two prunes took the repository past 10 GB, where GitHub
evicts by last read, fixed keys included. The chipdb saved on
fix/ci-chipdb-cache on 2026-10-04 was gone by the next morning, and the
LED one-hot run on #852 rebuilt it (2 m 54 s).

Two changes:

- cache-prune.js: after the existing rules, while the kept entries are
  over BUDGET_BYTES (8e9), drop setup-zig's per-run entries on refs
  other than main, least recently read first. Nothing else is dropped
  for the budget: not a fixed key, not main, and not a chipdb whose key
  ends in a run id (one branch saves chipdb-...-regymm-<run id>). A
  chipdb hit saves about three minutes; a Zig cache hit tens of seconds
  at most.
- actions-cache-prune.yml: also run on workflow_run after brain-ci and
  CI complete. The hourly schedule started 2 runs in 9 slots between
  18:41Z and 03:46Z. brain-ci's jobs hold 8.59 GB and CI's 1.85 GB of
  10.84 GB.

Eight new tests (22 in all); 13 of 13 mutants of the budget rule are
killed. On the 162-entry list of 2026-10-05 the plan drops 43 entries
(3.06 GB), 10 of them (0.72 GB) for the budget, and keeps 119 (7.78 GB),
including all 5 chipdb entries and all 9 entries on main.

Refs #844

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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