Repository navigation
fix: ci: early exit rebootstrap on no change to stage0 - #14575
Merged
Merged
Conversation
|
Mathlib CI status (docs):
|
Collaborator
|
Reference manual CI status:
|
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
LEAN_GITHASH in rebootstrap
tydeu
force-pushed
the
tydeu/unset-lean-githash
branch
from
July 28, 2026 02:43
1bd7952 to
1b2fb9f
Compare
tydeu
marked this pull request as ready for review
July 28, 2026 02:52
wkrozowski
pushed a commit
to marcelolynch/lean4
that referenced
this pull request
Jul 29, 2026
) This PR early exits "Check rebootstrap" when a rebootstrap does not change stage0 (e.g., in the CI job for an `update-stage0` commit or for a subsequent commit that makes no core changes). After leanprover#14486, an empty commit changes `Lean.githash` without changing the stage0 tree hash that keys Lake's traces, leaving stage 1 `.olean`s stale with respect to the rebuilt binaries. This leads to an incompatible header failure when attempting to read the old oleans with the new `lean`. This is solved by aborting the "Check rebootstrap" when the commit would be empty. If stage0 did not change, there is nothing to rebootstrap anyway, so running it previously was just a waste of time. The PR also sets the `LEAN_GITHASH` on a rebootstrap to the new stage0 hash, ensuring any `lake` invocations in the tests invalidate leftover stale builds keyed on the old githash. This should not occur (tests should clear previous outputs before running). Nonetheless, a failure here is hard to diagnose, so this is done defensively. 🤖 Prepared with Claude Code --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
robsimmons
pushed a commit
that referenced
this pull request
Jul 29, 2026
This PR early exits "Check rebootstrap" when a rebootstrap does not change stage0 (e.g., in the CI job for an `update-stage0` commit or for a subsequent commit that makes no core changes). After #14486, an empty commit changes `Lean.githash` without changing the stage0 tree hash that keys Lake's traces, leaving stage 1 `.olean`s stale with respect to the rebuilt binaries. This leads to an incompatible header failure when attempting to read the old oleans with the new `lean`. This is solved by aborting the "Check rebootstrap" when the commit would be empty. If stage0 did not change, there is nothing to rebootstrap anyway, so running it previously was just a waste of time. The PR also sets the `LEAN_GITHASH` on a rebootstrap to the new stage0 hash, ensuring any `lake` invocations in the tests invalidate leftover stale builds keyed on the old githash. This should not occur (tests should clear previous outputs before running). Nonetheless, a failure here is hard to diagnose, so this is done defensively. 🤖 Prepared with Claude Code --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
legion-implementer Bot
added a commit
to sjawhar/lean4
that referenced
this pull request
Nov 28, 2026
…LEAN_GITHASH (#6) * ci: tag-build dispatch, no fork release assets, tests without LEAN_GITHASH This member changes only `.github/`. A dispatch of `ci.yml` with the new input `release_tag` builds as the run on that tag would, before the tag exists: gh workflow run ci.yml --ref <branch> -f release_tag=v4.36-machcsl-r21 The step "Check for custom releases" of `configure` gives the input as its output, so the run has check level 3, `stamped` builds, the job matrix and target stage of the tag's run, and the same CMake options: a fork's tag gives the build no `RELEASE_TAG` and no special version, so in both runs the version stamp is the commit's githash. "Pack" compresses as on a tag. `IS_NIGHTLY` is false whenever `release_tag` is set: the `action` input defaults to "release nightly", and a dispatch with `release_tag` must take no nightly path. The `release` job runs only on a tag push to leanprover/lean4. On a fork it attached the CI's build artifacts to the tag's release. A fork's release holds only the files that are published by hand (on theorem-labs/lean4, the measured tarball and its `.sha256`), so the job no longer runs there. A dispatch is no tag push, so it publishes nothing. The steps "Test" and "Check rebootstrap" run the tests without `LEAN_GITHASH`. The step "Build Stage 0 & Configure Stage 1" writes it to `GITHUB_ENV` (line 158 of build-template.yml at the trunk, line 163 in v4.36-machcsl-r20) from `build/stage1/lake-githash`: the stage0 tree hash. `stdlib.make` passes that value to the core build itself; the Lake cache steps (Download, Upload and Verify Lake Cache, which run `build/stage0/bin/lake`) take it from the job's environment (leanprover#14486). A stamped build runs none of these cache steps (`lake-cache` is `!stamped`). The tests of stage 2 (and of stage 1) do not need it: they run that stage's own Lake and Lean, and with no override Lake takes the githash of that Lean (`lean --githash`), as it does outside CI. Both stages are built with `USE_GITHASH`, so that githash is the commit's, and the override names another Lean. Under it, Lake scopes its remote cache by the override and queues, claims and reads nothing remote (`remoteCacheQueueService?` in `Lake/Config/Env.lean`). That failed the Lake tests inputLockClaims (cases 9a and 9b), remoteCacheClaim, remoteCacheRead, remoteCacheRefused, remoteCachePush and usageCutoffRemote in the job "build / Linux release" on the tag v4.36-machcsl-r20. Outside CI, the runner's value of the variable gives the same failures, and without it the tests pass (remoteCachePush's failing check needs a CMake build to reach). The tests ran without the variable before leanprover#14486. "Check rebootstrap" (which the Linux release job runs at check level 1 and up, so on a tag, after "Test") exported the new stage0 hash for its stage 1 tests as a defensive measure against stale builds (leanprover#14575). Without the override Lake still keys every trace by the githash of the Lean it runs, which the update-stage0 commit changes, so no test reuses a stale build. Part of LINUX-1736. Omp-Session: 01a21fea-50cc-71ef-b840-72b8c7ab62bb Legion-Role: implementer * ci: validate release_tag, keep it out of shell source, fork-only Review of the previous commit found that the `release_tag` input reached `GITHUB_OUTPUT` as typed, and that "Set check level" put that output into its Bash source: a line break could change the step's outputs, and shell metacharacters could change what Bash runs. "Check for custom releases", the only step that reads the input, now takes it as environment data and refuses it unless it is a tag name: `v` and then letters, digits, `.`, `_` or `-` (`^v[0-9A-Za-z._-]+$`). The error names the rule and prints the refused value escaped with `printf %q`, on one line. "Set check level" no longer reads the tag text: it reads whether that step gave a tag, as the Boolean `CUSTOM_RELEASE`. This also covers a fork's tag push, whose name the step passed into Bash source in the same way. The other places that read the input (`IS_NIGHTLY` in `configure`, "Pack" in build-template.yml) use it only in a Boolean expression. The input is for forks. On leanprover/lean4 the step refuses it with an error, where before such a dispatch silently built at check level 1; the input's description says so. A dispatch with `release_tag` has a concurrency group of its own (the group gets the suffix `-release-tag`), so that it and a nightly re-release dispatch on the same ref no longer cancel each other. Part of LINUX-1736. Omp-Session: 01a21fea-50cc-71ef-b840-72b8c7ab62bb Legion-Role: implementer * ci: fork tag build without macOS aarch64 and Windows tests, tsanitize on 64 GB The decision on the jobs of the fork's tag build other than Linux release (LINUX-1736, E3(5)), applied in the build matrix of `configure`. "The fork's tag build" is a fork's tag push or a dispatch with `release_tag`: the runs in which "Check for custom releases" gives a tag, which the matrix script now reads as the Boolean `forkTag`. On every other event (pull_request, merge_group, a push to master, schedule, a nightly, leanprover/lean4's own tags) the matrix is unchanged. - macOS aarch64 and Windows: not tested in the fork's tag build; they still build there, as a compile check. With `test` false their Test step does not run, nor the steps that only read its results (Protect and Unprotect Source Tree, Check Source Tree Clean, Embed Test Output, Test Summary, Check Test Binary, all conditioned on `matrix.test` or on the Test step's conclusion in build-template.yml, which is unchanged). The fork publishes no macOS or Windows build. On r20's tag 27 Lake tests and elab/openssl.lean failed on macOS aarch64: the fork's Lake tests assume GNU tools and a newer bash than macOS's bash 3.2, and the runner's OpenSSL is 4. The fork's tests assume a POSIX system, so Windows failed 40 tests in a rehearsal of r21's tag build; #12 keeps its build working. - Linux tsanitize: in theorem-labs/lean4's tag build it runs on the GitHub larger runner `ubuntu-24.04-16core` (16 CPUs, 64 GB). On ubuntu-latest the runner was lost about 39 s into elab/async_http_h1_incremental.lean, on r20's tag and on the rehearsal; upstream gives this job 32 CPUs and 64 GB. A probe run on theorem-labs/lean4 (run 46126841398, 2026-11-28) got that label in the organization's runner group `proofs`, with 16 CPUs and 62 GiB as `free -g` counts. Elsewhere (sjawhar/lean4, where the label does not exist) the job keeps ubuntu-latest. Its `-j2` stays: the bound is the memory of the TSAN tests, and 64 GB is upstream's memory too. The job has no `timeout-minutes` of its own (GitHub's 360 minutes); it built in about 54 minutes on the 4-CPU hosted runner. - Linux aarch64 and Linux fsanitize are unchanged. Part of LINUX-1736. Omp-Session: 01a21fea-50cc-71ef-b840-72b8c7ab62bb Legion-Role: implementer * ci: fork tag build only on a tag push or a release_tag dispatch Review of the previous commit found that a `workflow_dispatch` from a tag ref without `release_tag` (for example a nightly re-release, the `action` input's default) also counted as the fork's tag build: "Check for custom releases" runs on any tag ref of a fork and gives the ref's tag name, so `forkTag` was true, and that dispatch lost the tests of macOS aarch64 and Windows and, on theorem-labs/lean4, moved Linux tsanitize to the larger runner. `forkTag` now also requires a tag push (`push` of a `refs/tags/` ref) or a dispatch whose `release_tag` is not empty. The check level is selected as before. The comment on Linux tsanitize now says only what is known: on ubuntu-latest the runner was lost about 39 s into elab/async_http_h1_incremental.lean (on r20's tag and on a rehearsal of r21's), the larger runner is for its memory, the probe run 46126841398 got `ubuntu-24.04-16core` on theorem-labs/lean4, so the workflow selects it only there, and the job keeps upstream's `-j2`, which upstream uses on 64 GB, the same memory. It no longer says that the label exists nowhere else, nor that memory bounds the tests. Rendered with the matrix script of `configure`: a tag push on theorem-labs/lean4, a `release_tag` dispatch on sjawhar/lean4 and a pull request give the same matrix as with the previous commit; a dispatch from a tag ref without `release_tag`, on either repository, gives the matrix of the commit before it again. Part of LINUX-1736. Omp-Session: 01a21fea-50cc-71ef-b840-72b8c7ab62bb Legion-Role: implementer * ci: no Lake cache upload where the repository has no cache endpoint The pull requests within the fork failed at `Upload Lake Cache`, before their tests ran. The step's condition leaves out only pull requests from other repositories, but the fork has neither the secret LAKE_CACHE_KEY nor the variable LAKE_CACHE_ENDPOINT. So `lake cache put` ran with an empty key and the endpoint `/a1`, and stopped with "curl produced invalid JSON ... Enter host password" and "URL using bad/illegal format", exit 1. The step now also needs `vars.LAKE_CACHE_ENDPOINT != ''`. Where the variable is set, as on leanprover/lean4, nothing changes. `Verify Lake Cache` and `Restore Build` run only after a successful upload, so they are skipped too. `Download Lake Cache` stays as it is: it reads Reservoir, not that endpoint, and it is `continue-on-error` (on the fork it stops in about two seconds with "no outputs found for any revision"). Part of LINUX-1736. Omp-Session: 01a21fea-50cc-71ef-b840-72b8c7ab62bb Legion-Role: implementer --------- Co-authored-by: legion-implementer[bot] <343353655+legion-implementer[bot]@users.noreply.github.com>
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.
This PR early exits "Check rebootstrap" when a rebootstrap does not change stage0 (e.g., in the CI job for an
update-stage0commit or for a subsequent commit that makes no core changes).After #14486, an empty commit changes
Lean.githashwithout changing the stage0 tree hash that keys Lake's traces, leaving stage 1.oleans stale with respect to the rebuilt binaries. This leads to an incompatible header failure when attempting to read the old oleans with the newlean.This is solved by aborting the "Check rebootstrap" when the commit would be empty. If stage0 did not change, there is nothing to rebootstrap anyway, so running it previously was just a waste of time.
The PR also sets the
LEAN_GITHASHon a rebootstrap to the new stage0 hash, ensuring anylakeinvocations in the tests invalidate leftover stale builds keyed on the old githash. This should not occur (tests should clear previous outputs before running). Nonetheless, a failure here is hard to diagnose, so this is done defensively.🤖 Prepared with Claude Code