Skip to content

chore: CI: reuse the Lake artifact cache in non-release builds - #14665

Open
Kha wants to merge 4 commits into
masterfrom
pr-ci-no-release-stamp
Open

chore: CI: reuse the Lake artifact cache in non-release builds#14665
Kha wants to merge 4 commits into
masterfrom
pr-ci-no-release-stamp

Conversation

@Kha

@Kha Kha commented Aug 3, 2026

Copy link
Copy Markdown
Member

This PR speeds up pull request, merge queue and master builds by having them make full use of the artifact cache. Nightlies and tagged releases keep (re)building exactly as shipped.

Those builds could not use the caches because they were configured as release builds, which pass CHECK_OLEAN_VERSION=ON. That option is forwarded to stage 0, so every stage 1 .olean is stamped with the commit githash and lean rejects any carrying a different one, making the artifacts commit-specific. The stamp is now applied only from check level 2 up, where CI actually produces a toolchain to distribute (with PR releases intentionally ignored here as they are developer-facing). Lake keys its traces on the stage 0 tree hash, so they already accept .oleans built at another commit, and the published lean binary reports the commit githash either way because stage 1 keeps USE_GITHASH at its default, leaving downstream traces commit-specific.

With the stamp gone below that level, the Linux Lake (Cached) job that existed to exercise the cache alongside the release job is redundant and is removed; its cache download becomes a lake-cache matrix entry, kept as the exact complement of release because a stamped build would reject what the cache serves it. The Actions cache of stage 1 build outputs is redundant too, since everything it stored lives under the stage 1 lib directory that Verify Lake Cache already restores from the Lake cache on every run, and being content-addressed and global rather than scoped to the branch the Lake cache should hit more often. Dropping it also stops writing a copy of the library per commit into the repository's Actions cache quota, which ccache (itself unchanged) shares.

Kha and others added 3 commits July 26, 2026 15:11
This PR makes CI reuse cached `.olean`s below the level at which it produces a distributable toolchain, cutting build time for pull requests, the merge queue and master. Nightlies and tagged releases keep building exactly as shipped.

A release build passes `CHECK_OLEAN_VERSION=ON`, which is forwarded to stage 0 and so stamps the commit githash into every stage 1 `.olean` and makes `lean` reject `.olean`s carrying any other. That makes the artifacts commit-specific, which is why such a build replaces the system-wide Lake cache with a job-level one and why its stage 1 Actions cache has no cross-commit fallback. Stamping only from check level 2 up makes both usable everywhere below: Lake traces are keyed on the stage 0 tree hash, so they already accept `.olean`s from another commit. The published `lean` still reports the commit githash either way, because stage 1 keeps `USE_GITHASH` at its default, so downstream Lake traces stay commit-specific.

`release` also gated the artifact upload that `pr-release.yml` and `grove.yml` consume, so that moves to a separate `upload` matrix entry. The shell tests on `matrix.release` now compare against `true` rather than testing for non-emptiness, which a `false` entry would have passed. Finally, the cache round trip in `Verify Lake Cache` gets a throwaway cache directory, as its `lake cache clean` would otherwise delete the shared system-wide cache that a build without the stamp now uses.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This PR has CI download the Lake artifact cache wherever it builds without the release githash stamp, and removes the `Linux Lake (Cached)` job that existed to try that out alongside the release job.

The download and the git depth it needs to resolve a cached ancestor revision were gated on that job's name; they now key off a `lake-cache` matrix entry, which is exactly the complement of `release` because a stamped build cannot load what the cache holds from other commits. The dropped job duplicated the release job's build and test run, so removing it also frees the capacity it took.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This PR drops the Actions cache of stage 1 build outputs, which the Lake artifact cache now supersedes, and has `update-stage0.yml` fetch that cache instead.

The two covered the same ground: everything the Actions cache stored lives under the stage 1 `lib` directory, which `Verify Lake Cache` already deletes and restores from the Lake cache on every run. Being content-addressed and global rather than scoped to the branch, the Lake cache should also hit more often, and not saving a copy of the stdlib per commit leaves the repository's Actions cache quota to `ccache`.

`update-stage0.yml` built without `USE_LAKE_CACHE` and relied on the release job's Actions cache, so it gains the option and the `cache-get` target. That target already configures stage 1 for itself, and needs no `LEAN_GITHASH` override because this build sets no `CHECK_OLEAN_VERSION`, leaving stage 0's own githash equal to the stage 0 tree hash Lake keys its traces on. It may therefore also reuse `.olean`s stamped with another commit's githash.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Kha
Kha requested a review from tydeu August 3, 2026 14:21
@Kha
Kha requested a review from kim-em as a code owner August 3, 2026 14:22
@github-actions github-actions Bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Aug 3, 2026
@mathlib-lean-pr-testing

mathlib-lean-pr-testing Bot commented Aug 3, 2026

Copy link
Copy Markdown

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 3b7f37725bc34d8903342666fc4a400f723d78a1 --onto 110db9cb751afaee8b2ac344887d6c7e632f77b4. You can force Mathlib CI using the force-mathlib-ci label. (2026-08-03 14:40:11)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 3b7f37725bc34d8903342666fc4a400f723d78a1 --onto 945e78b86645b179655123cd2fdba83d89d28d07. You can force Mathlib CI using the force-mathlib-ci label. (2026-08-05 09:46:39)

@leanprover-bot

Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 3b7f37725bc34d8903342666fc4a400f723d78a1 --onto 23393b959b33e3a8d15796b2397f8a04c315b9f4. You can force reference manual CI using the force-manual-ci label. (2026-08-03 14:40:13)

Comment thread .github/workflows/update-stage0.yml
This PR makes Lake recompile a bootstrapping package's object files when the Lean runtime headers they are compiled against change, and makes the build refresh its copy of those headers. Previously, editing `src/include/lean/lean.h` left both the copy in the build tree and the stdlib's `.o` files stale.

Lake identifies the headers a module's C file includes via its Lean trace, but the core build pins that trace to the stage 0 tree hash and overrides the include directory to the current source tree's headers, so header changes went unnoticed. `buildLeanO` now mixes a trace over the headers in `leanIncludeDir?` into the object file's trace whenever that override is in effect, which is exactly the bootstrapping case. Non-bootstrap packages are unaffected, as their headers are already identified by the toolchain githash.

The headers are copied into the build tree, where both the C++ sources and the C files generated by `lean` include them from, by a `lean-headers` build target rather than by a configure-time `file(COPY)`. Editing a header now refreshes the copy during the build instead of requiring a CMake reconfiguration.

Note that the Lake change only takes effect for the stage 1 build after `make update-stage0`, since stage 1 is built by stage 0's `lake`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Kha
Kha force-pushed the pr-ci-no-release-stamp branch from a6df594 to 133a88a Compare August 5, 2026 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants