Repository navigation
CI: main reuses its own build cache, with --prune and a nightly run from nothing - #2402
Merged
Merged
Conversation
…m nothing A pull request reuses main's newest cache, but main built from nothing, so during a landing burst its saves fell several commits behind and one shared-source commit in between undid most of the reuse. Main now restores its newest cache like a pull request and saves it again, and zig_cache_restat --prune deletes the entries a checkout can't hit (a changed or missing file, or another dead entry's output), so the saved cache stays about one build. A nightly run skips every restore, so a pass reuse could hide, such as a test reading a file the build doesn't know of, fails within a day, and its cache starts the next day clean.
ashhart
force-pushed
the
lead/ci-main-reuse
branch
from
November 7, 2026 01:40
734eefa to
78efd62
Compare
4 tasks done
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.
Pull requests already restore main's newest build cache, but main itself built from nothing on every push. During a landing burst its saves fell several commits behind, and one shared-source commit in between undid most of a pull request's reuse.
What changes
zigandzig-windowsjobs on main restore main's newest cache, like a pull request, and save it again. So each push compiles and runs only what changed since the last save.zig_cache_restat --prunekeeps the cache to about one build. It deletes the entries a checkout can't hit: an entry whose recorded file changed or can't be read, and any entry that uses a deleted entry's output folder. Without it, a cache that is restored and saved again keeps growing. All four restat steps pass--prune, including release-paths and macOS dev-tools, which already restored on main and were growing.-nightlykey, so it doesn't collide with the push run for the same commit. On the nightly run, release-paths checks all three platforms, as on main's pushes. The lean check is skipped because a scheduled run has no base to compare against.If restat fails, the job just rebuilds more than it needs to. It never skips a check.
Tests
tools/zig/zig_cache_restat_test.pywith Zig 0.17.0: both tests pass. The newtest_prune_keeps_one_buildlinks a C object into the executable.zig fmt --checkis clean, the lean check finds nothing new, and the workflow parses.