ci: pull request jobs restore caches and never save them

Closed
TE
2mo ago
+91-54

Summary

  • On Warp runners actions/cache writes to the GitHub cache store, which evicts above about 10 GB. ci.yml had 14 save+restore cache steps in pull request jobs. Each run saved 1 to 3 GB entries scoped to refs/pull/N/merge, which no other pull request can read.
  • Measured 2026-09-20 05:55 UTC: 37.5 GB in 27 entries, oldest macOS entry 5 minutes old, only the Zig and Bun entries on refs/heads/main. Compile admission logged Cache not found for the Debug compilation cache that nightly.yml seeds. Every compile ran cold: compile admission 18.3 min (compile 14.5), tests-build-and-lag 20.0 (build 12.9), release-build 29.9 (build 28.2).
  • All cache steps in ci.yml now use actions/cache/restore. Seeds come from the existing main-branch jobs in nightly.yml (Debug and Release compilation caches, spm- for both package paths, Zig).
  • tests-build-and-lag and release-build read the spm- key nightly.yml saves with the same path. Their old spm-build- and spm-release- families were written only by pull requests.
  • release-build drops the step that pruned and bounded the compilation cache before a save that no longer happens.
  • New guard tests/test_ci_pull_request_caches_are_read_only.py: no saving cache step in ci.yml, and every spm- restore has a nightly.yml save with the same key and path.

Known gaps

  • The two DerivedData restores (deriveddata-build-, deriveddata-release-v2-) have no main seeder, so they miss until one exists. They were 4.2 GB per pull request and the largest source of churn. Removing them or seeding them is a follow-up once a warm run is measured.
  • A re-push no longer reuses its own pull request cache. Under the churn above it could not anyway.
  • perf-activation.yml, ci-macos-compat.yml and test-e2e.yml still save from their own runs.

Testing

  • actionlint on ci.yml.
  • tests/test_ci_pull_request_caches_are_read_only.py fails on main (first commit) and passes here.
  • tests/test_ci_change_areas.py, tests/test_ci_self_hosted_guard.sh, tests/test_nightly_universal_build.sh, tests/test_ci_test_compilation_cache_seed.sh pass. Two assertions that required pull request Release builds to save were rewritten to require restore-only.
  • Warm numbers need a seed to survive first: after this merges and the next 17 */6 seed runs, read one compile admission and one release-build.

๐Ÿค– Generated with Claude Code


Summary by cubic

Pull request CI jobs now restore caches instead of saving them, so pull-request-only entries stop evicting the main-branch seeds that keep builds warm. Before, every pull request run saved 1โ€“3 GB entries that only that pull request could read, and the churn pushed the seeded caches out of the size-capped store.

  • All 14 actions/cache steps in ci.yml are now actions/cache/restore, and seeds come from existing main-branch jobs in nightly.yml.
  • tests-build-and-lag and release-build read the spm- cache with the same key and path nightly.yml saves; release-build also drops the compilation-cache prune-and-bound step that only existed before the removed save.
  • Adds tests/test_ci_pull_request_caches_are_read_only.py, which fails if ci.yml saves a cache or restores an spm- key that nightly.yml doesn't seed.
  • Known gaps: DerivedData restores have no main-branch seed yet, and a re-pushed branch no longer reuses its own earlier cache entry.

Summary by CodeRabbit

  • CI Improvements

    • Pull request workflows now restore caches without modifying or saving them.
    • Shared Swift package caches are used across applicable build jobs.
    • Removed automatic pruning and size enforcement for the release build compilation cache.
  • Tests

    • Added validation to ensure pull request caches remain read-only and correspond to nightly cache saves.
    • Updated regression checks to reflect the new cache restoration behavior.