4343 test-outcome : ${{ steps.test.outcome }}
4444 defaults : # On Hoskinson runners, landrun is already installed.
4545 run :
46- shell : landrun --rox /usr --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 -- bash -euxo pipefail {0}
46+ 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}
4747 steps :
4848 - name : cleanup
4949 shell : bash # This *just* deletes old files, so is safe to run outside landrun.
@@ -181,11 +181,38 @@ jobs:
181181 # - we give --rox access to `~/.elan` and `~/actions-runner/_work` (GitHub CI needs this)
182182 # - we give --unrestricted-network as we need this to download dependencies
183183 # - git needs read only access to `/etc`.
184- shell : landrun --unrestricted-network --rox /etc --rox /usr --rw /dev --rox /home/lean/.elan --rox /home/lean/actions-runner/_work --rw pr-branch/.lake/ --env PATH --env HOME --env GITHUB_OUTPUT -- bash -euxo pipefail {0}
184+ shell : landrun --unrestricted-network --rox /etc --rox /usr --rw /dev --rox /home/lean/.elan --rox /home/lean/actions-runner/_work --rw pr-branch/.lake/ --env PATH --env HOME --env GITHUB_OUTPUT --env CI -- bash -euxo pipefail {0}
185185 run : |
186186 cd pr-branch
187187 lake env
188188
189+ - name : validate lake-manifest.json inputRevs
190+ # Only enforce this on the main mathlib4 repository, not on nightly-testing
191+ if : github.repository == 'leanprover-community/mathlib4'
192+ shell : bash
193+ run : |
194+ cd pr-branch
195+
196+ # Check that all inputRevs in lake-manifest.json match the required pattern
197+ echo "Validating lake-manifest.json inputRevs..."
198+
199+ # Extract all inputRevs from the manifest
200+ invalid_revs=$(jq -r '.packages[].inputRev // empty' lake-manifest.json | \
201+ grep -v -E '^(main|master|v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.-]+)?)$' || true)
202+
203+ if [ -n "$invalid_revs" ]; then
204+ echo "❌ Error: Found invalid inputRevs in lake-manifest.json:"
205+ echo "$invalid_revs"
206+ echo ""
207+ echo "All inputRevs must be one of:"
208+ echo " - 'main'"
209+ echo " - 'master'"
210+ echo " - 'vX.Y.Z' (semantic version, e.g., v1.2.3 or v1.2.3-pre)"
211+ exit 1
212+ else
213+ echo "✅ All inputRevs in lake-manifest.json are valid"
214+ fi
215+
189216 - name : get cache (1/3 - setup and initial fetch)
190217 id : get_cache_part1_setup
191218 shell : bash # only runs `cache get` from `master-branch`, so doesn't need to be inside landrun
@@ -277,7 +304,7 @@ jobs:
277304 !pr-branch/.git/
278305
279306 # The cache secrets are available here, so we must not run any untrusted code.
280- - name : upload cache
307+ - name : Upload cache to Azure
281308 # We only upload the cache if the build started (whether succeeding, failing, or cancelled)
282309 # but not if any earlier step failed or was cancelled.
283310 # See discussion at https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Some.20files.20not.20found.20in.20the.20cache/near/407183836
@@ -288,19 +315,50 @@ jobs:
288315
289316 # Trim trailing whitespace from secrets to prevent issues with accidentally added spaces
290317 export MATHLIB_CACHE_SAS="${MATHLIB_CACHE_SAS_RAW%"${MATHLIB_CACHE_SAS_RAW##*[![:space:]]}"}"
291- export MATHLIB_CACHE_S3_TOKEN="${MATHLIB_CACHE_S3_TOKEN_RAW%"${MATHLIB_CACHE_S3_TOKEN_RAW##*[![:space:]]}"}"
292318
293319 # Use the trusted cache tool from master-branch
294320 # TODO: this is not doing anything currently, and needs to be integrated with put-unpacked
295321 # ../master-branch/.lake/build/bin/cache commit || true
296322 # run this in CI if it gets an incorrect lake hash for existing cache files somehow
297323 # ../master-branch/.lake/build/bin/cache put!
298324 # do not try to upload files just downloaded
299- ../master-branch/.lake/build/bin/cache --repo=${{ github.event.pull_request.head.repo.full_name || github.repository }} put-unpacked
325+
326+ echo "Uploading cache to Azure..."
327+ USE_FRO_CACHE=0 ../master-branch/.lake/build/bin/cache --repo=${{ github.event.pull_request.head.repo.full_name || github.repository }} put-unpacked
300328 env :
301329 MATHLIB_CACHE_SAS_RAW : ${{ secrets.MATHLIB_CACHE_SAS }}
330+
331+ # The cache secrets are available here, so we must not run any untrusted code.
332+ - name : Upload cache to Cloudflare
333+ id : cloudflare-upload-mathlib
334+ if : ${{ always() && steps.get.outcome == 'success' }}
335+ continue-on-error : true
336+ shell : bash
337+ run : |
338+ cd pr-branch
339+
340+ # Trim trailing whitespace from secrets to prevent issues with accidentally added spaces
341+ export MATHLIB_CACHE_S3_TOKEN="${MATHLIB_CACHE_S3_TOKEN_RAW%"${MATHLIB_CACHE_S3_TOKEN_RAW##*[![:space:]]}"}"
342+
343+ echo "Uploading cache to Cloudflare..."
344+ USE_FRO_CACHE=1 ../master-branch/.lake/build/bin/cache --repo=${{ github.event.pull_request.head.repo.full_name || github.repository }} put-unpacked
345+ env :
302346 MATHLIB_CACHE_S3_TOKEN_RAW : ${{ secrets.MATHLIB_CACHE_S3_TOKEN }}
303347
348+ - name : Report Cloudflare upload failure on Zulip
349+ if : steps.cloudflare-upload-mathlib.outcome == 'failure'
350+ uses : zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2
351+ with :
352+ api-key : ${{ secrets.ZULIP_API_KEY }}
353+ email : ' github-mathlib4-bot@leanprover.zulipchat.com'
354+ organization-url : ' https://leanprover.zulipchat.com'
355+ to : ' nightly-testing'
356+ type : ' stream'
357+ topic : ' Cloudflare cache upload failure'
358+ content : |
359+ ❌ Cloudflare cache upload (Mathlib) [failed](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) for PR #${{ github.event.pull_request.number || 'push' }} on commit ${{ github.sha }}
360+ continue-on-error : true
361+
304362 # Note: we should not be including `Archive` and `Counterexamples` in the cache.
305363 # We do this for now for the sake of not rebuilding them in every CI run
306364 # even when they are not touched.
@@ -342,21 +400,50 @@ jobs:
342400 exit 1
343401
344402 # The cache secrets are available here, so we must not run any untrusted code.
345- - name : put archive and counterexamples cache
403+ - name : Upload Archive and Counterexamples cache to Azure
346404 shell : bash
347405 run : |
348406 cd pr-branch
349407
350408 # Trim trailing whitespace from secrets to prevent issues with accidentally added spaces
351409 export MATHLIB_CACHE_SAS="${MATHLIB_CACHE_SAS_RAW%"${MATHLIB_CACHE_SAS_RAW##*[![:space:]]}"}"
352- export MATHLIB_CACHE_S3_TOKEN="${MATHLIB_CACHE_S3_TOKEN_RAW%"${MATHLIB_CACHE_S3_TOKEN_RAW##*[![:space:]]}"}"
353410
354- ../master-branch/.lake/build/bin/cache --repo=${{ github.event.pull_request.head.repo.full_name || github.repository }} put Archive.lean
355- ../master-branch/.lake/build/bin/cache --repo=${{ github.event.pull_request.head.repo.full_name || github.repository }} put Counterexamples.lean
411+ echo "Uploading Archive and Counterexamples cache to Azure..."
412+ USE_FRO_CACHE=0 ../master-branch/.lake/build/bin/cache --repo=${{ github.event.pull_request.head.repo.full_name || github.repository }} put Archive.lean
413+ USE_FRO_CACHE=0 ../master-branch/.lake/build/bin/cache --repo=${{ github.event.pull_request.head.repo.full_name || github.repository }} put Counterexamples.lean
356414 env :
357415 MATHLIB_CACHE_SAS_RAW : ${{ secrets.MATHLIB_CACHE_SAS }}
416+
417+ - name : Upload Archive and Counterexamples cache to Cloudflare
418+ id : cloudflare-upload-archive
419+ continue-on-error : true
420+ shell : bash
421+ run : |
422+ cd pr-branch
423+
424+ # Trim trailing whitespace from secrets to prevent issues with accidentally added spaces
425+ export MATHLIB_CACHE_S3_TOKEN="${MATHLIB_CACHE_S3_TOKEN_RAW%"${MATHLIB_CACHE_S3_TOKEN_RAW##*[![:space:]]}"}"
426+
427+ echo "Uploading Archive and Counterexamples cache to Cloudflare..."
428+ USE_FRO_CACHE=1 ../master-branch/.lake/build/bin/cache --repo=${{ github.event.pull_request.head.repo.full_name || github.repository }} put Archive.lean
429+ USE_FRO_CACHE=1 ../master-branch/.lake/build/bin/cache --repo=${{ github.event.pull_request.head.repo.full_name || github.repository }} put Counterexamples.lean
430+ env :
358431 MATHLIB_CACHE_S3_TOKEN_RAW : ${{ secrets.MATHLIB_CACHE_S3_TOKEN }}
359432
433+ - name : Report Cloudflare Archive/Counterexamples upload failure on Zulip
434+ if : steps.cloudflare-upload-archive.outcome == 'failure'
435+ uses : zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2
436+ with :
437+ api-key : ${{ secrets.ZULIP_API_KEY }}
438+ email : ' github-mathlib4-bot@leanprover.zulipchat.com'
439+ organization-url : ' https://leanprover.zulipchat.com'
440+ to : ' nightly-testing'
441+ type : ' stream'
442+ topic : ' Cloudflare cache upload failure'
443+ content : |
444+ ❌ Cloudflare cache upload (Archive/Counterexamples) [failed](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) for PR #${{ github.event.pull_request.number || 'push' }} on commit ${{ github.sha }}
445+ continue-on-error : true
446+
360447 - name : Check {Mathlib, Tactic, Counterexamples, Archive}.lean
361448 if : always()
362449 run : |
@@ -460,18 +547,39 @@ jobs:
460547 with :
461548 auto-config : false # Don't run `lake build`, `lake test`, or `lake lint` automatically.
462549 use-github-cache : false
463- use-mathlib-cache : true
550+ use-mathlib-cache : false # This can be re-enabled once we are confident in the cache again.
464551 reinstall-transient-toolchain : true
465552
466- # TODO: this step should not be necessary, "Configure Lean" above should already achieve this.
553+ - name : retrieve and test the Cloudflare caches, but don't fail, just report to Zulip, if anything goes wrong
554+ id : cloudflare-cache
555+ continue-on-error : true
556+ run : |
557+ lake exe cache --repo=${{ github.event.pull_request.head.repo.full_name || github.repository }} get
558+ lake build --no-build -v Mathlib
559+ lake exe cache --repo=${{ github.event.pull_request.head.repo.full_name || github.repository }} get Archive Counterexamples
560+ lake build --no-build -v Archive Counterexamples
561+
562+ - name : Report Cloudflare cache failure on Zulip
563+ if : steps.cloudflare-cache.outcome == 'failure'
564+ uses : zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2
565+ with :
566+ api-key : ${{ secrets.ZULIP_API_KEY }}
567+ email : ' github-mathlib4-bot@leanprover.zulipchat.com'
568+ organization-url : ' https://leanprover.zulipchat.com'
569+ to : ' nightly-testing'
570+ type : ' stream'
571+ topic : ' Cloudflare cache failure'
572+ content : |
573+ ❌ Cloudflare cache retrieval/test [failed](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) for PR #${{ github.event.pull_request.number || 'push' }} on commit ${{ github.sha }}
574+ continue-on-error : true
575+
467576 - name : get cache for Mathlib
468577 run : |
469578 # Run once without --repo, so we can diagnose what `lake exe cache get` wants to do by itself.
470579 lake exe cache get
471580 # Run again with --repo, so ensure we actually get the oleans.
472581 lake exe cache --repo=${{ github.event.pull_request.head.repo.full_name || github.repository }} get
473582
474-
475583 - name : get cache for Archive and Counterexamples
476584 run : |
477585 # Run once without --repo, so we can diagnose what `lake exe cache get` wants to do by itself.
@@ -517,6 +625,12 @@ jobs:
517625 run : |
518626 lake build Batteries Qq Aesop ProofWidgets Plausible
519627
628+ - name : build AesopTest (nightly-testing only)
629+ # Only run on the mathlib4-nightly-testing repository
630+ if : github.repository == 'leanprover-community/mathlib4-nightly-testing'
631+ run : |
632+ lake build AesopTest
633+
520634 # We no longer run `lean4checker` in regular CI, as it is quite expensive for little benefit.
521635 # Instead we run it in a cron job on master: see `lean4checker.yml`.
522636 # Output is posted to the zulip topic
@@ -551,7 +665,7 @@ jobs:
551665 if : FORK_CONDITION
552666 runs-on : ubuntu-latest
553667 steps :
554- - uses : leanprover-community/lint-style-action@d29fb3b12c1c834450680b3c544f63fe0237a2e2 # 2025-06-20
668+ - uses : leanprover-community/lint-style-action@a7e7428fa44f9635d6eb8e01919d16fd498d387a # 2025-08-18
555669 with :
556670 mode : check
557671 lint-bib-file : true
@@ -573,18 +687,16 @@ jobs:
573687 needs : [style_lint, build, post_steps]
574688 runs-on : ubuntu-latest
575689 steps :
576- # This action is used to determine the PR metadata in the event of a push.
577- # If it is called from a PR from a fork, it will find nothing/irrelevant data.
578- - if : github.event_name != 'pull_request_target'
579- id : PR_from_push
580- uses : 8BitJonny/gh-get-current-pr@08e737c57a3a4eb24cec6487664b243b77eb5e36 # 3.0.0
690+ - id : PR_from_push
691+ uses : 8BitJonny/gh-get-current-pr@4056877062a1f3b624d5d4c2bedefa9cf51435c9 # 4.0.0
581692 # TODO: this may not work properly if the same commit is pushed to multiple branches:
582693 # https://github.com/8BitJonny/gh-get-current-pr/issues/8
583694 with :
584695 github-token : ${{ secrets.GITHUB_TOKEN }}
585696 # Only return if PR is still open
586697 filterOutClosed : true
587698
699+ # TODO: delete this step and rename `PR_from_push` to `PR` if the above step seems to work properly
588700 # Combine the output from the previous action with the metadata supplied by GitHub itself.
589701 # Note that if we fall back to github.event.pull_request data, the list of labels is generated when this workflow is triggered
590702 # and not updated afterwards!
0 commit comments