Skip to content

Commit b359794

Browse files
authored
Merge branch 'leanprover-community:master' into main
2 parents 02aa441 + 36a2b22 commit b359794

7,314 files changed

Lines changed: 100387 additions & 45138 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/build.in.yml

Lines changed: 72 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ env:
1515
concurrency:
1616
# label each workflow run; only the latest with each label will run
1717
# workflows on master get more expressive labels
18-
group: ${{ github.workflow }}-${{ github.ref }}-${{ (contains(fromJSON('["refs/heads/master", "refs/heads/staging"]'), github.ref) && github.run_id) || '' }}
18+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ (github.event_name == 'push' && contains(fromJSON('["refs/heads/master", "refs/heads/staging"]'), github.ref) && github.run_id) || '' }}
1919
# cancel any running workflow with the same label
2020
cancel-in-progress: true
2121

@@ -38,12 +38,23 @@ jobs:
3838
lint-outcome: ${{ steps.lint.outcome }}
3939
mk_all-outcome: ${{ steps.mk_all.outcome }}
4040
noisy-outcome: ${{ steps.noisy.outcome }}
41-
shake-outcome: ${{ steps.shake.outcome }}
41+
# shake-outcome: ${{ steps.shake.outcome }}
4242
test-outcome: ${{ steps.test.outcome }}
4343
defaults: # On Hoskinson runners, landrun is already installed.
44-
run:
44+
run: # note that .pr-branch/.lake must be created in a step below before we use this
4545
shell: landrun --rox /usr --ro /etc/timezone --rw /dev --rox /home/lean/.elan --rox /home/lean/actions-runner/_work --rox /home/lean/.cache/mathlib/ --rw pr-branch/.lake/ --env PATH --env HOME --env GITHUB_OUTPUT --env CI -- bash -euxo pipefail {0}
4646
steps:
47+
- name: job info
48+
env:
49+
WORKFLOW: ${{ github.workflow }}
50+
PR_NUMBER: ${{ github.event.pull_request.number }}
51+
REF: ${{ github.ref }}
52+
EVENT_NAME: ${{ github.event_name }}
53+
RUN_ID: ${{ github.run_id }}
54+
CONCURRENCY_GROUP: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ (github.event_name == 'push' && contains(fromJSON('["refs/heads/master", "refs/heads/staging"]'), github.ref) && github.run_id) || '' }}
55+
shell: bash # there is no script body, so this is safe to "run" outside landrun.
56+
run: |
57+
# We just populate the env vars for this step to make them viewable in the logs
4758
- name: cleanup
4859
shell: bash # This *just* deletes old files, so is safe to run outside landrun.
4960
run: |
@@ -227,6 +238,51 @@ jobs:
227238
echo "✅ All inputRevs in lake-manifest.json are valid"
228239
fi
229240
241+
- name: verify ProofWidgets lean-toolchain matches on versioned releases
242+
# Only enforce this on the main mathlib4 repository, not on nightly-testing
243+
if: github.repository == 'leanprover-community/mathlib4'
244+
shell: bash
245+
run: |
246+
cd pr-branch
247+
248+
# Read the lean-toolchain file
249+
TOOLCHAIN=$(cat lean-toolchain | tr -d '[:space:]')
250+
echo "Lean toolchain: $TOOLCHAIN"
251+
252+
# Check if toolchain matches the versioned release pattern: leanprover/lean4:vX.Y.Z (with optional suffix like -rc1)
253+
if [[ "$TOOLCHAIN" =~ ^leanprover/lean4:v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.-]+)?$ ]]; then
254+
echo "✓ Detected versioned Lean release: $TOOLCHAIN"
255+
echo "Verifying ProofWidgets lean-toolchain matches..."
256+
257+
# Check if ProofWidgets lean-toolchain exists
258+
if [ ! -f .lake/packages/proofwidgets/lean-toolchain ]; then
259+
echo "❌ Error: .lake/packages/proofwidgets/lean-toolchain does not exist"
260+
echo "This file should be created by 'lake env' during dependency download."
261+
exit 1
262+
fi
263+
264+
# Read ProofWidgets lean-toolchain
265+
PROOFWIDGETS_TOOLCHAIN=$(cat .lake/packages/proofwidgets/lean-toolchain | tr -d '[:space:]')
266+
echo "ProofWidgets toolchain: $PROOFWIDGETS_TOOLCHAIN"
267+
268+
# Compare the two
269+
if [ "$TOOLCHAIN" != "$PROOFWIDGETS_TOOLCHAIN" ]; then
270+
echo "❌ Error: Lean toolchain mismatch!"
271+
echo " Main lean-toolchain: $TOOLCHAIN"
272+
echo " ProofWidgets lean-toolchain: $PROOFWIDGETS_TOOLCHAIN"
273+
echo ""
274+
echo "When using a versioned Lean release (leanprover/lean4:vX.Y.Z),"
275+
echo "the ProofWidgets dependency must use the same toolchain."
276+
echo "Please update the ProofWidgets dependency to use $TOOLCHAIN"
277+
exit 1
278+
else
279+
echo "✅ ProofWidgets lean-toolchain matches: $TOOLCHAIN"
280+
fi
281+
else
282+
echo "ℹ Lean toolchain is not a versioned release (pattern: leanprover/lean4:vX.Y.Z)"
283+
echo "Skipping ProofWidgets toolchain verification."
284+
fi
285+
230286
- name: get cache (1/3 - setup and initial fetch)
231287
id: get_cache_part1_setup
232288
shell: bash # only runs `cache get` from `master-branch`, so doesn't need to be inside landrun
@@ -295,7 +351,7 @@ jobs:
295351
echo "::endgroup::"
296352
297353
../master-branch/scripts/lake-build-with-retry.sh Mathlib
298-
# results of build at pr-branch/.lake/build_summary_Mathlib*.json
354+
# results of build at pr-branch/.lake/build_summary_Mathlib.json
299355
- name: end gh-problem-match-wrap for build step
300356
uses: leanprover-community/gh-problem-matcher-wrap@20007cb926a46aa324653a387363b52f07709845 # 2025-04-23
301357
with:
@@ -364,15 +420,15 @@ jobs:
364420
run: |
365421
cd pr-branch
366422
../master-branch/scripts/lake-build-with-retry.sh Archive
367-
# results of build at pr-branch/.lake/build_summary_Archive*.json
423+
# results of build at pr-branch/.lake/build_summary_Archive.json
368424
369425
- name: build counterexamples
370426
id: counterexamples
371427
continue-on-error: true
372428
run: |
373429
cd pr-branch
374430
../master-branch/scripts/lake-build-with-retry.sh Counterexamples
375-
# results of build at pr-branch/.lake/build_summary_Counterexamples*.json
431+
# results of build at pr-branch/.lake/build_summary_Counterexamples.json
376432
377433
- name: Check if building Archive or Counterexamples failed
378434
if: steps.archive.outcome == 'failure' || steps.counterexamples.outcome == 'failure'
@@ -401,7 +457,7 @@ jobs:
401457
MATHLIB_CACHE_SAS_RAW: ${{ secrets.MATHLIB_CACHE_SAS }}
402458

403459
- name: Check {Mathlib, Tactic, Counterexamples, Archive}.lean
404-
if: always()
460+
if: ${{ always() && steps.mk_all.outcome != 'skipped' }}
405461
run: |
406462
if [[ "${{ steps.mk_all.outcome }}" != "success" ]]; then
407463
echo "Please run 'lake exe mk_all' to regenerate the import all files"
@@ -419,7 +475,7 @@ jobs:
419475
id: test
420476
run: |
421477
cd pr-branch
422-
lake --iofail test
478+
../master-branch/scripts/lake-build-wrapper.py .lake/build_summary_MathlibTest.json lake --iofail test
423479
- name: end gh-problem-match-wrap for test step
424480
uses: leanprover-community/gh-problem-matcher-wrap@20007cb926a46aa324653a387363b52f07709845 # 2025-04-23
425481
with:
@@ -432,18 +488,20 @@ jobs:
432488
action: add # In order to be able to run a multiline script, we need to add/remove the problem matcher before and after.
433489
linters: gcc
434490

435-
- name: check for unused imports
436-
id: shake
437-
run: |
438-
cd pr-branch
439-
env LEAN_ABORT_ON_PANIC=1 lake exe shake --gh-style
491+
# With the arrival of the module system, the old `shake` is no longer functional.
492+
# This will be replaced soon.
493+
# - name: check for unused imports
494+
# id: shake
495+
# run: |
496+
# cd pr-branch
497+
# env LEAN_ABORT_ON_PANIC=1 lake exe shake --gh-style
440498

441499
- name: lint mathlib
442500
if: ${{ always() && steps.build.outcome == 'success' || steps.build.outcome == 'failure' }}
443501
id: lint
444502
run: |
445503
cd pr-branch
446-
env LEAN_ABORT_ON_PANIC=1 lake exe runLinter Mathlib
504+
env LEAN_ABORT_ON_PANIC=1 ../master-branch/scripts/lake-build-wrapper.py .lake/build_summary_lint.json lake exe runLinter Mathlib
447505
448506
- name: end gh-problem-match-wrap for shake and lint steps
449507
uses: leanprover-community/gh-problem-matcher-wrap@20007cb926a46aa324653a387363b52f07709845 # 2025-04-23

.github/workflows/bors.yml

Lines changed: 72 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ env:
2525
concurrency:
2626
# label each workflow run; only the latest with each label will run
2727
# workflows on master get more expressive labels
28-
group: ${{ github.workflow }}-${{ github.ref }}-${{ (contains(fromJSON('["refs/heads/master", "refs/heads/staging"]'), github.ref) && github.run_id) || '' }}
28+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ (github.event_name == 'push' && contains(fromJSON('["refs/heads/master", "refs/heads/staging"]'), github.ref) && github.run_id) || '' }}
2929
# cancel any running workflow with the same label
3030
cancel-in-progress: true
3131

@@ -48,12 +48,23 @@ jobs:
4848
lint-outcome: ${{ steps.lint.outcome }}
4949
mk_all-outcome: ${{ steps.mk_all.outcome }}
5050
noisy-outcome: ${{ steps.noisy.outcome }}
51-
shake-outcome: ${{ steps.shake.outcome }}
51+
# shake-outcome: ${{ steps.shake.outcome }}
5252
test-outcome: ${{ steps.test.outcome }}
5353
defaults: # On Hoskinson runners, landrun is already installed.
54-
run:
54+
run: # note that .pr-branch/.lake must be created in a step below before we use this
5555
shell: landrun --rox /usr --ro /etc/timezone --rw /dev --rox /home/lean/.elan --rox /home/lean/actions-runner/_work --rox /home/lean/.cache/mathlib/ --rw pr-branch/.lake/ --env PATH --env HOME --env GITHUB_OUTPUT --env CI -- bash -euxo pipefail {0}
5656
steps:
57+
- name: job info
58+
env:
59+
WORKFLOW: ${{ github.workflow }}
60+
PR_NUMBER: ${{ github.event.pull_request.number }}
61+
REF: ${{ github.ref }}
62+
EVENT_NAME: ${{ github.event_name }}
63+
RUN_ID: ${{ github.run_id }}
64+
CONCURRENCY_GROUP: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ (github.event_name == 'push' && contains(fromJSON('["refs/heads/master", "refs/heads/staging"]'), github.ref) && github.run_id) || '' }}
65+
shell: bash # there is no script body, so this is safe to "run" outside landrun.
66+
run: |
67+
# We just populate the env vars for this step to make them viewable in the logs
5768
- name: cleanup
5869
shell: bash # This *just* deletes old files, so is safe to run outside landrun.
5970
run: |
@@ -237,6 +248,51 @@ jobs:
237248
echo "✅ All inputRevs in lake-manifest.json are valid"
238249
fi
239250
251+
- name: verify ProofWidgets lean-toolchain matches on versioned releases
252+
# Only enforce this on the main mathlib4 repository, not on nightly-testing
253+
if: github.repository == 'leanprover-community/mathlib4'
254+
shell: bash
255+
run: |
256+
cd pr-branch
257+
258+
# Read the lean-toolchain file
259+
TOOLCHAIN=$(cat lean-toolchain | tr -d '[:space:]')
260+
echo "Lean toolchain: $TOOLCHAIN"
261+
262+
# Check if toolchain matches the versioned release pattern: leanprover/lean4:vX.Y.Z (with optional suffix like -rc1)
263+
if [[ "$TOOLCHAIN" =~ ^leanprover/lean4:v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.-]+)?$ ]]; then
264+
echo "✓ Detected versioned Lean release: $TOOLCHAIN"
265+
echo "Verifying ProofWidgets lean-toolchain matches..."
266+
267+
# Check if ProofWidgets lean-toolchain exists
268+
if [ ! -f .lake/packages/proofwidgets/lean-toolchain ]; then
269+
echo "❌ Error: .lake/packages/proofwidgets/lean-toolchain does not exist"
270+
echo "This file should be created by 'lake env' during dependency download."
271+
exit 1
272+
fi
273+
274+
# Read ProofWidgets lean-toolchain
275+
PROOFWIDGETS_TOOLCHAIN=$(cat .lake/packages/proofwidgets/lean-toolchain | tr -d '[:space:]')
276+
echo "ProofWidgets toolchain: $PROOFWIDGETS_TOOLCHAIN"
277+
278+
# Compare the two
279+
if [ "$TOOLCHAIN" != "$PROOFWIDGETS_TOOLCHAIN" ]; then
280+
echo "❌ Error: Lean toolchain mismatch!"
281+
echo " Main lean-toolchain: $TOOLCHAIN"
282+
echo " ProofWidgets lean-toolchain: $PROOFWIDGETS_TOOLCHAIN"
283+
echo ""
284+
echo "When using a versioned Lean release (leanprover/lean4:vX.Y.Z),"
285+
echo "the ProofWidgets dependency must use the same toolchain."
286+
echo "Please update the ProofWidgets dependency to use $TOOLCHAIN"
287+
exit 1
288+
else
289+
echo "✅ ProofWidgets lean-toolchain matches: $TOOLCHAIN"
290+
fi
291+
else
292+
echo "ℹ Lean toolchain is not a versioned release (pattern: leanprover/lean4:vX.Y.Z)"
293+
echo "Skipping ProofWidgets toolchain verification."
294+
fi
295+
240296
- name: get cache (1/3 - setup and initial fetch)
241297
id: get_cache_part1_setup
242298
shell: bash # only runs `cache get` from `master-branch`, so doesn't need to be inside landrun
@@ -305,7 +361,7 @@ jobs:
305361
echo "::endgroup::"
306362
307363
../master-branch/scripts/lake-build-with-retry.sh Mathlib
308-
# results of build at pr-branch/.lake/build_summary_Mathlib*.json
364+
# results of build at pr-branch/.lake/build_summary_Mathlib.json
309365
- name: end gh-problem-match-wrap for build step
310366
uses: leanprover-community/gh-problem-matcher-wrap@20007cb926a46aa324653a387363b52f07709845 # 2025-04-23
311367
with:
@@ -374,15 +430,15 @@ jobs:
374430
run: |
375431
cd pr-branch
376432
../master-branch/scripts/lake-build-with-retry.sh Archive
377-
# results of build at pr-branch/.lake/build_summary_Archive*.json
433+
# results of build at pr-branch/.lake/build_summary_Archive.json
378434
379435
- name: build counterexamples
380436
id: counterexamples
381437
continue-on-error: true
382438
run: |
383439
cd pr-branch
384440
../master-branch/scripts/lake-build-with-retry.sh Counterexamples
385-
# results of build at pr-branch/.lake/build_summary_Counterexamples*.json
441+
# results of build at pr-branch/.lake/build_summary_Counterexamples.json
386442
387443
- name: Check if building Archive or Counterexamples failed
388444
if: steps.archive.outcome == 'failure' || steps.counterexamples.outcome == 'failure'
@@ -411,7 +467,7 @@ jobs:
411467
MATHLIB_CACHE_SAS_RAW: ${{ secrets.MATHLIB_CACHE_SAS }}
412468

413469
- name: Check {Mathlib, Tactic, Counterexamples, Archive}.lean
414-
if: always()
470+
if: ${{ always() && steps.mk_all.outcome != 'skipped' }}
415471
run: |
416472
if [[ "${{ steps.mk_all.outcome }}" != "success" ]]; then
417473
echo "Please run 'lake exe mk_all' to regenerate the import all files"
@@ -429,7 +485,7 @@ jobs:
429485
id: test
430486
run: |
431487
cd pr-branch
432-
lake --iofail test
488+
../master-branch/scripts/lake-build-wrapper.py .lake/build_summary_MathlibTest.json lake --iofail test
433489
- name: end gh-problem-match-wrap for test step
434490
uses: leanprover-community/gh-problem-matcher-wrap@20007cb926a46aa324653a387363b52f07709845 # 2025-04-23
435491
with:
@@ -442,18 +498,20 @@ jobs:
442498
action: add # In order to be able to run a multiline script, we need to add/remove the problem matcher before and after.
443499
linters: gcc
444500

445-
- name: check for unused imports
446-
id: shake
447-
run: |
448-
cd pr-branch
449-
env LEAN_ABORT_ON_PANIC=1 lake exe shake --gh-style
501+
# With the arrival of the module system, the old `shake` is no longer functional.
502+
# This will be replaced soon.
503+
# - name: check for unused imports
504+
# id: shake
505+
# run: |
506+
# cd pr-branch
507+
# env LEAN_ABORT_ON_PANIC=1 lake exe shake --gh-style
450508

451509
- name: lint mathlib
452510
if: ${{ always() && steps.build.outcome == 'success' || steps.build.outcome == 'failure' }}
453511
id: lint
454512
run: |
455513
cd pr-branch
456-
env LEAN_ABORT_ON_PANIC=1 lake exe runLinter Mathlib
514+
env LEAN_ABORT_ON_PANIC=1 ../master-branch/scripts/lake-build-wrapper.py .lake/build_summary_lint.json lake exe runLinter Mathlib
457515
458516
- name: end gh-problem-match-wrap for shake and lint steps
459517
uses: leanprover-community/gh-problem-matcher-wrap@20007cb926a46aa324653a387363b52f07709845 # 2025-04-23

0 commit comments

Comments
 (0)