Skip to content

Prune older ccaches in a dedicated workflow - #304

Merged
zfergus merged 2 commits into
mainfrom
chore/prune-ccache
Nov 10, 2026
Merged

zfergus merged 2 commits into
mainfrom
chore/prune-ccache

Conversation

@zfergus

@zfergus zfergus commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Description

Adds a Prune Caches workflow (.github/workflows/prune-caches.yml) that deletes older ccaches, keeping only the newest per key prefix and ref. No existing workflow changes.

Mechanism:

  • Triggers on workflow_run (completed) of Build, Python, Coverage, CUDA, Docs and ODR Check, plus a daily schedule and workflow_dispatch.
  • Lists all caches, groups them by ref and by key minus the trailing run ID (-ccache-[0-9]+$ only, so PantheonSim's toolkit cache is untouched), and deletes all but the newest in each group.
  • Keeps the newest by creation time, so a cache saved during a prune is never deleted.
  • concurrency: prune-caches collapses a burst of triggers into one running and one pending run.

Security

  • Only this job holds actions: write. The build jobs keep the repo's read-only default token.
  • This matters because the build jobs run third-party actions referenced by mutable tags (SimenB/github-actions-cpu-cores@v2, ilammy/msvc-dev-cmd@v1, Jimver/cuda-toolkit, codecov/codecov-action, JamesIves/github-pages-deploy-action) and compile dependencies downloaded through CPM. With actions: write, compromised code there could delete caches and logs, cancel runs, or dispatch docs.yml, which deploys to gh-pages without approval.
  • The prune job never checks out the repository and runs only gh, so PR code never sees its token, including when a fork's PR triggers workflow_run.

Impact:

  • A dry run of the exact --jq query against the current caches deletes 44 older copies (6.0 GB) and keeps 29 ccaches plus PantheonSim's, leaving about 4.1 GB.
  • Old copies on PR refs (e.g. Rigid and Affine Body Dynamics #184's ODR caches) are pruned too.

Type of change

  • Enhancement (non-breaking change which improves existing functionality)

How Has This Been Tested?

  • Ran the workflow's gh cache list --jq query (gh's built-in jq) against the live cache list: 44 deletions, 43 on main and 1 on refs/pull/184/merge, with the newest kept in each of the 29 groups.
  • The workflow parses as YAML, and the workflow_run names match the name: of all six workflows.
  • workflow_run, schedule and workflow_dispatch only use the workflow file from the default branch, so this can't run before merge. After merge, it runs on the next CI completion or by manual dispatch.

Checklist

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings

zfergus and others added 2 commits November 10, 2026 10:41
Each push to main saved a new copy of every ccache, pushing the
repository past its 10 GB cache limit. A shared composite action now
keeps only the newest cache per key prefix on the current ref.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only the prune job now holds actions: write. The build jobs, which run
third-party actions and downloaded dependencies, keep the repository's
read-only default token.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zfergus zfergus changed the title Prune older ccaches after each save Prune older ccaches in a dedicated workflow Nov 10, 2026
@zfergus
zfergus merged commit 7d66802 into main Nov 10, 2026
@zfergus
zfergus deleted the chore/prune-ccache branch November 10, 2026 15:53
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