Repository navigation
Conversation
Add trusted-main serialized maintenance with baseline-aware eviction and dry-run regression coverage. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Port cache selection, GitHub API integration and regression tests to Python standard library; update workflow and documentation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Share the 30 GB archived-storage cap across all main sccache-v1 OS, architecture and build identities. Run generic hourly maintenance independently of specific build workflows and exclude legacy pilot caches. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Aggregate architectures and build variants within each OS, preserve independent OS budgets during eviction and post-cleanup checks, and report per-OS storage. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Pagination by mutable access time can skip caches during concurrent restores, undercounting storage and allowing cleanup to succeed while an OS remains over budget.
1 open issue
What changed in this PR
Adds independent 150 GB soft storage caps per OS for archived snapshots produced by the shared sccache actions, without changing local cache limits or build behavior.
Changes:
- Adds scoped cache inventory and eviction logic that preferentially preserves each compatibility prefix’s newest snapshot.
- Introduces hourly maintenance with trusted-main write permissions, read-only PR tests, and manual dry runs by default.
- Adds regression tests and documents per-OS budgets, exclusions, and concurrency limitations.
| File | Description |
|---|---|
.github/workflows/sccache-maintenance.yml |
Schedules cleanup and separates read-only tests from privileged maintenance. |
.github/scripts/test_prune_sccache.py |
Tests budgets, eviction selection, scope guards, pagination, and failures. |
.github/scripts/prune_sccache.py |
Implements inventory, per-OS eviction plans, deletion, and post-cleanup checks. |
.github/actions/setup-sccache/README.md |
Documents retention policy, soft-cap guarantees, and preview usage. |
Review effort: Balanced
Refactor cache listing to handle pagination and sorting. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This branch has not been deployed
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.

Description
Add a separate 150,000,000,000-byte archived-storage budget per OS for sccache using the shared cache actions. Each OS's architectures and build variants share that OS's budget. Unused capacity cannot be borrowed across OSes, and total managed storage can exceed 150 GB when multiple OSes participate. The existing per-run 10G local cache, build matrices/tests/Metal coverage, vcpkg, and other cache namespaces are unchanged.
sccache-maintenance.ymlhourly, independently of any specific build workflow. Future OS/build callers participate automatically through the shared key format; no workflow-name registration or OS allowlist is needed. Manual dispatch defaults to dry run.sccache-v1-namespace. Only well-formedsccache-v1-<OS>-<arch>-<identity>-<commit>snapshots onrefs/heads/maincount toward the corresponding OS's budget. Legacymacos-sccache-v1-/v2-pilot snapshots and all other refs/namespaces are excluded and untouched; there are no pilot-branch special cases.actions: writeisolated to the trusted-main scheduled/manual maintenance job. PRs run regression tests with read-only permissions and cannot run cleanup.ghCLI; no runtime package installation.Guarantee: these are soft caps, not atomic GitHub storage quotas. Uploads can run concurrently with cleanup, and scheduled runs can be delayed. An OS's storage can temporarily exceed 150 GB between hourly maintenance runs; an over-budget post-cleanup inventory fails visibly, identifies the affected OSes, and subsequent maintenance retries.
Validation (Windows, isolated Python 3.13 environment):
python -m unittest discover -s .github\scripts -p test_prune_sccache.py -v— passed, 18 tests. Coverage includes the exact 150,000,000,000-byte default; independent OS budgets; combining architectures/builds within an OS; multiple simultaneously over-budget OSes; preserving healthy OSes; allowing combined storage above 150 GB when every OS is within budget; scope/ref guards; aggregate limits; generations; pagination/deduplication; ordering; oversized baselines; dry runs; API failures; concurrent uploads; and subprocess error propagation.python -m ruff check .github\scripts\prune_sccache.py .github\scripts\test_prune_sccache.py— passed.python -m ruff format --check .github\scripts\prune_sccache.py .github\scripts\test_prune_sccache.py— passed.actionlint .github\workflows\sccache-maintenance.yml— passed with actionlint 1.7.12 on the unchanged workflow in the preceding per-OS update.git diff --checkandgit diff --cached --check— passed before commit.$env:GITHUB_REPOSITORY='microsoft/onnxruntime'; python .github\scripts\prune_sccache.py | Select-Object -First 2— read-only live dry run passed: macOS has 99,564,983,312 bytes scoped; zero proposed evictions at the 150 GB per-OS budget. These totals exclude legacy pilot snapshots.No live caches were deleted and no workflows were manually triggered. Native builds/tests were not run because build behavior is unchanged.
Motivation and Context
The shared sccache actions from #33811 publish immutable snapshots of the whole local cache on successful main builds. The local size bound does not bound aggregate GitHub archived storage, so unchanged compatibility prefixes accumulate generations. This adds a temporary 150 GB per-OS retention budget that supports both today's macOS builds and future OS/build adopters without platform-specific cleanup logic.