Skip to content

Commit 5205d78

Browse files
authored
Merge branch 'master' into feature/order/subsingleton-rel-refl
2 parents b222c7e + 4049cbf commit 5205d78

4,702 files changed

Lines changed: 89982 additions & 44100 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/actions/get-mathlib-ci/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ Any workflow that needs `mathlib-ci` should use this action instead of writing i
99
own `actions/checkout` block for `leanprover-community/mathlib-ci`.
1010

1111
The default `ref` in [`action.yml`](./action.yml) is the single canonical pinned
12-
`mathlib-ci` commit for this repository.
12+
`mathlib-ci` commit for this repository. This is auto-updated regularly by the
13+
[`update_dependencies.yml` workflow](../../workflows/update_dependencies.yml).
1314

1415
## Why
1516

.github/actions/get-mathlib-ci/action.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ inputs:
99
required: false
1010
# Default pinned commit used by workflows unless they explicitly override.
1111
# Update this ref as needed to pick up changes to mathlib-ci scripts
12-
default: 261ca4c0c6bd3267e4846ef9fdd676afab9fef4e
12+
# This is also updated automatically by .github/workflows/update_dependencies.yml
13+
default: d7b053bde8ef240c29f6724fa285dc5bb6bbe00a
1314
path:
1415
description: Checkout destination path.
1516
required: false

.github/workflows/PR_summary.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ jobs:
228228
then
229229
# Format each changed workflow path as a Markdown bullet: "- `path`"
230230
workflowFilesChangedMarkdown="$(sed "s|^|- \`|; s|\$|\`|" <<< "${workflowFilesChanged}")"
231-
workflowDocsReminder="$(printf "### Workflow documentation reminder\nThis PR modifies files under \`.github/workflows/\`.\nPlease update \`docs/workflows.md\` if the workflow inventory, triggers, or behavior changed.\n\nModified workflow files:\n%s\n" "${workflowFilesChangedMarkdown}")"
231+
workflowDocsReminder="$(printf "### ⚠️ Workflow documentation reminder\nThis PR modifies files under \`.github/workflows/\`.\nPlease update \`docs/workflows.md\` if the workflow inventory, triggers, or behavior changed.\n\nModified workflow files:\n%s\n" "${workflowFilesChangedMarkdown}")"
232232
else
233233
workflowDocsReminder=""
234234
fi
@@ -239,7 +239,7 @@ jobs:
239239
then
240240
# Format each added scripts path as a Markdown bullet: "- `path`"
241241
scriptsFilesAddedMarkdown="$(sed "s|^|- \`|; s|\$|\`|" <<< "${scriptsFilesAdded}")"
242-
scriptsLocationReminder="$(printf "### Scripts folder reminder\nThis PR adds files under \`scripts/\`.\nPlease consider whether each added script belongs in this repository or in \`leanprover-community/mathlib-ci\`.\n\nAdded scripts files:\n%s\n" "${scriptsFilesAddedMarkdown}")"
242+
scriptsLocationReminder="$(printf "### ⚠️ Scripts folder reminder\nThis PR adds files under \`scripts/\`.\nPlease consider whether each added script belongs in this repository or in [\`leanprover-community/mathlib-ci\`](https://github.com/leanprover-community/mathlib-ci).\n\nA script belongs in **\`mathlib-ci\`** if it is a CI automation script that interacts with GitHub (e.g. managing labels, posting comments, triggering bots), runs from a trusted external checkout in CI, or requires access to secrets.\n\nA script belongs in **this repository** (\`scripts/\`) if it is a developer or maintainer tool to be run locally, a code maintenance or analysis utility, a style linting tool, or a data file used by the library's own linters.\n\nSee the [\`mathlib-ci\` README](https://github.com/leanprover-community/mathlib-ci) for more details.\n\nAdded scripts files:\n%s\n" "${scriptsFilesAddedMarkdown}")"
243243
else
244244
scriptsLocationReminder=""
245245
fi

.github/workflows/actionlint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1313

1414
- name: suggester / actionlint
15-
uses: reviewdog/action-actionlint@0d952c597ef8459f634d7145b0b044a9699e5e43 # v1.71.0
15+
uses: reviewdog/action-actionlint@6fb7acc99f4a1008869fa8a0f09cfca740837d9d # v1.72.0
1616
with:
1717
tool_name: actionlint
1818
fail_level: any

.github/workflows/bors.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ jobs:
2727
with:
2828
concurrency_group: ${{ github.workflow }}-${{ github.ref }}-${{ github.run_id }}
2929
pr_branch_ref: ${{ github.sha }}
30+
# Use the MASTER cache key only when merging into mathlib4 (staging branch);
31+
# 'bors try' runs (trying branch) and nightly-testing use NON_MASTER
32+
cache_application_id: ${{ github.ref_name == 'staging' && github.repository == 'leanprover-community/mathlib4' && vars.CACHE_MASTER_WRITER_AZURE_APP_ID || vars.CACHE_NON_MASTER_WRITER_AZURE_APP_ID }}
3033
# bors runs should build the tools from their commit-under-test: after all, we are trying to
3134
# test 'what would happen if this was merged', so we need to use the 'would-be-post-merge' tools
3235
tools_branch_ref: ${{ github.sha }}

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,7 @@ jobs:
3535
with:
3636
concurrency_group: ${{ github.workflow }}-${{ github.ref }}-${{ (github.event_name == 'push' && github.ref == 'refs/heads/master' && github.run_id) || '' }}
3737
pr_branch_ref: ${{ github.sha }}
38+
# Use the MASTER cache key only on mathlib4/master; nightly-testing and other branches use NON_MASTER
39+
cache_application_id: ${{ github.repository == 'leanprover-community/mathlib4' && github.ref == 'refs/heads/master' && vars.CACHE_MASTER_WRITER_AZURE_APP_ID || vars.CACHE_NON_MASTER_WRITER_AZURE_APP_ID }}
3840
runs_on: pr
3941
secrets: inherit

.github/workflows/build_fork.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ jobs:
3636
with:
3737
concurrency_group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
3838
pr_branch_ref: ${{ github.event.pull_request.head.sha }}
39+
cache_application_id: ${{ vars.CACHE_NON_MASTER_WRITER_AZURE_APP_ID }}
3940
runs_on: pr
4041
secrets: inherit

.github/workflows/build_template.yml

Lines changed: 66 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ on:
2424
type: string
2525
required: false
2626
default: ''
27+
cache_application_id:
28+
type: string
29+
required: true
2730

2831
env:
2932
# Disable Lake's automatic fetching of cloud builds.
@@ -244,76 +247,6 @@ jobs:
244247
echo "✅ All inputRevs in lake-manifest.json are valid"
245248
fi
246249
247-
- name: validate ProofWidgets source repository
248-
# Only enforce this on the main mathlib4 repository, not on nightly-testing
249-
if: github.repository == 'leanprover-community/mathlib4'
250-
shell: bash
251-
run: |
252-
cd pr-branch
253-
254-
expected_url='https://github.com/leanprover-community/ProofWidgets4'
255-
proofwidgets_count=$(jq '[.packages[] | select(.name == "proofwidgets")] | length' lake-manifest.json)
256-
if [ "$proofwidgets_count" -ne 1 ]; then
257-
echo "❌ Error: expected exactly one proofwidgets entry in lake-manifest.json, found $proofwidgets_count"
258-
exit 1
259-
fi
260-
261-
proofwidgets_url=$(jq -r '.packages[] | select(.name == "proofwidgets") | .url' lake-manifest.json)
262-
normalized_url="${proofwidgets_url%.git}"
263-
if [ "$normalized_url" != "$expected_url" ]; then
264-
echo "❌ Error: invalid ProofWidgets source URL in lake-manifest.json"
265-
echo " expected: $expected_url"
266-
echo " found: $proofwidgets_url"
267-
exit 1
268-
fi
269-
270-
echo "✅ ProofWidgets source URL is allowed: $proofwidgets_url"
271-
272-
- name: verify ProofWidgets lean-toolchain matches on versioned releases
273-
# Only enforce this on the main mathlib4 repository, not on nightly-testing
274-
if: github.repository == 'leanprover-community/mathlib4'
275-
shell: bash
276-
run: |
277-
cd pr-branch
278-
279-
# Read the lean-toolchain file
280-
TOOLCHAIN=$(cat lean-toolchain | tr -d '[:space:]')
281-
echo "Lean toolchain: $TOOLCHAIN"
282-
283-
# Check if toolchain matches the versioned release pattern: leanprover/lean4:vX.Y.Z (with optional suffix like -rc1)
284-
if [[ "$TOOLCHAIN" =~ ^leanprover/lean4:v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.-]+)?$ ]]; then
285-
echo "✓ Detected versioned Lean release: $TOOLCHAIN"
286-
echo "Verifying ProofWidgets lean-toolchain matches..."
287-
288-
# Check if ProofWidgets lean-toolchain exists
289-
if [ ! -f .lake/packages/proofwidgets/lean-toolchain ]; then
290-
echo "❌ Error: .lake/packages/proofwidgets/lean-toolchain does not exist"
291-
echo "This file should be created by 'lake env' during dependency download."
292-
exit 1
293-
fi
294-
295-
# Read ProofWidgets lean-toolchain
296-
PROOFWIDGETS_TOOLCHAIN=$(cat .lake/packages/proofwidgets/lean-toolchain | tr -d '[:space:]')
297-
echo "ProofWidgets toolchain: $PROOFWIDGETS_TOOLCHAIN"
298-
299-
# Compare the two
300-
if [ "$TOOLCHAIN" != "$PROOFWIDGETS_TOOLCHAIN" ]; then
301-
echo "❌ Error: Lean toolchain mismatch!"
302-
echo " Main lean-toolchain: $TOOLCHAIN"
303-
echo " ProofWidgets lean-toolchain: $PROOFWIDGETS_TOOLCHAIN"
304-
echo ""
305-
echo "When using a versioned Lean release (leanprover/lean4:vX.Y.Z),"
306-
echo "the ProofWidgets dependency must use the same toolchain."
307-
echo "Please update the ProofWidgets dependency to use $TOOLCHAIN"
308-
exit 1
309-
else
310-
echo "✅ ProofWidgets lean-toolchain matches: $TOOLCHAIN"
311-
fi
312-
else
313-
echo "ℹ Lean toolchain is not a versioned release (pattern: leanprover/lean4:vX.Y.Z)"
314-
echo "Skipping ProofWidgets toolchain verification."
315-
fi
316-
317250
- name: get cache (1/3 - setup and initial fetch)
318251
id: get_cache_part1_setup
319252
shell: bash # only runs `cache get` from `tools-branch`, so doesn't need to be inside landrun
@@ -324,7 +257,7 @@ jobs:
324257
325258
# Fail quickly if the cache is completely cold, by checking for Mathlib.Init
326259
echo "Attempting to fetch olean for Mathlib/Init.lean from cache..."
327-
../tools-branch/.lake/build/bin/cache --skip-proofwidgets get Mathlib/Init.lean
260+
../tools-branch/.lake/build/bin/cache get Mathlib/Init.lean
328261
329262
- name: get cache (2/3 - test Mathlib.Init cache)
330263
id: get_cache_part2_test
@@ -377,13 +310,19 @@ jobs:
377310
# cf. https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Mathlib.20has.20moved.20to.20the.20new.20module.20system/near/563452000
378311
echo "Warming up cache using previous commit: $PREV_SHA (source: $PREV_SHA_SOURCE)"
379312
if git cat-file -e "$PREV_SHA^{commit}" 2>/dev/null || git fetch --no-tags --depth=1 origin "$PREV_SHA"; then
380-
git checkout "$PREV_SHA"
381-
../tools-branch/.lake/build/bin/cache --skip-proofwidgets get
382-
# Run again with --repo, to ensure we actually get the oleans.
383-
../tools-branch/.lake/build/bin/cache --repo="$CACHE_REPO" --skip-proofwidgets get
384-
385-
echo "Switching back to branch head"
386-
git checkout "$ORIG_SHA"
313+
# Skip warmup if the previous commit uses a different toolchain
314+
PREV_TOOLCHAIN=$(git show "$PREV_SHA:lean-toolchain" 2>/dev/null || true)
315+
if [[ "$PREV_TOOLCHAIN" != "$(cat lean-toolchain)" ]]; then
316+
echo "Previous commit $PREV_SHA uses a different toolchain ($PREV_TOOLCHAIN); skipping warmup."
317+
else
318+
git checkout "$PREV_SHA"
319+
../tools-branch/.lake/build/bin/cache get
320+
# Run again with --repo, to ensure we actually get the oleans.
321+
../tools-branch/.lake/build/bin/cache --repo="$CACHE_REPO" get
322+
323+
echo "Switching back to branch head"
324+
git checkout "$ORIG_SHA"
325+
fi
387326
else
388327
echo "Could not fetch $PREV_SHA; skipping parent warmup cache fetch."
389328
fi
@@ -393,18 +332,10 @@ jobs:
393332
394333
echo "Fetching all remaining cache..."
395334
396-
../tools-branch/.lake/build/bin/cache --skip-proofwidgets get
335+
../tools-branch/.lake/build/bin/cache get
397336
398337
# Run again with --repo, to ensure we actually get the oleans.
399-
../tools-branch/.lake/build/bin/cache --repo="$CACHE_REPO" --skip-proofwidgets get
400-
401-
- name: fetch ProofWidgets release
402-
# We need network access for ProofWidgets frontend assets.
403-
# Run inside landrun so PR-controlled code remains sandboxed.
404-
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}
405-
run: |
406-
cd pr-branch
407-
lake build proofwidgets:release
338+
../tools-branch/.lake/build/bin/cache --repo="$CACHE_REPO" get
408339
409340
- name: update {Mathlib, Tactic, Counterexamples, Archive}.lean
410341
id: mk_all
@@ -459,8 +390,8 @@ jobs:
459390
shell: bash
460391
run: |
461392
cd pr-branch
462-
../tools-branch/.lake/build/bin/cache --skip-proofwidgets get Archive.lean
463-
../tools-branch/.lake/build/bin/cache --skip-proofwidgets get Counterexamples.lean
393+
../tools-branch/.lake/build/bin/cache get Archive.lean
394+
../tools-branch/.lake/build/bin/cache get Counterexamples.lean
464395
465396
- name: build archive
466397
id: archive
@@ -643,7 +574,7 @@ jobs:
643574
- name: Generate lean-pr-testing app token
644575
if: ${{ always() && github.repository == 'leanprover-community/mathlib4-nightly-testing' && (startsWith(github.ref_name, 'lean-pr-testing-') || startsWith(github.ref_name, 'batteries-pr-testing-')) }}
645576
id: lean-pr-testing-token
646-
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
577+
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
647578
with:
648579
app-id: ${{ secrets.MATHLIB_LEAN_PR_TESTING_APP_ID }}
649580
private-key: ${{ secrets.MATHLIB_LEAN_PR_TESTING_PRIVATE_KEY }}
@@ -672,6 +603,9 @@ jobs:
672603
name: Upload to cache
673604
needs: [build]
674605
runs-on: ubuntu-latest # These steps run on a GitHub runner; no landrun sandboxing is needed.
606+
permissions:
607+
contents: read
608+
id-token: write
675609
# We only upload the cache if the build started (whether succeeding, failing, or cancelled)
676610
# but not if any earlier step failed or was cancelled.
677611
# See discussion at https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Some.20files.20not.20found.20in.20the.20cache/near/407183836
@@ -702,21 +636,46 @@ jobs:
702636
echo "CACHE_BIN=$CACHE_BIN" >> "$GITHUB_ENV"
703637
704638
- name: Download cache staging artifact
705-
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
639+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
706640
with:
707641
name: cache-staging
708642
path: cache-staging
709643

710-
- name: Upload staged cache to Azure
644+
- name: Azure CLI OIDC login and mint storage bearer token
645+
id: mint_cache_bearer
646+
continue-on-error: true
647+
uses: leanprover-community/mathlib-ci/.github/actions/azure-create-cache-token@17db5ff55a65df98d55cbddcc67938f70d10dab2
648+
with:
649+
azure-client-id: ${{ inputs.cache_application_id }}
650+
azure-tenant-id: ${{ secrets.LPC_AZ_TENANT_ID }}
651+
652+
- name: Fallback to SAS token if bearer mint fails (for ease of migration)
653+
if: ${{ steps.mint_cache_bearer.outcome != 'success' }}
711654
shell: bash
655+
env:
656+
MATHLIB_CACHE_SAS_RAW: ${{ secrets.MATHLIB_CACHE_SAS }}
712657
run: |
713-
# Trim trailing whitespace from secrets to prevent issues with accidentally added spaces
714-
export MATHLIB_CACHE_SAS="${MATHLIB_CACHE_SAS_RAW%"${MATHLIB_CACHE_SAS_RAW##*[![:space:]]}"}"
658+
if [ -z "$MATHLIB_CACHE_SAS_RAW" ]; then
659+
echo "Azure bearer mint failed and secrets.MATHLIB_CACHE_SAS is not set"
660+
exit 1
661+
fi
662+
663+
MATHLIB_CACHE_SAS="${MATHLIB_CACHE_SAS_RAW%"${MATHLIB_CACHE_SAS_RAW##*[![:space:]]}"}"
664+
if [ -z "$MATHLIB_CACHE_SAS" ]; then
665+
echo "Azure bearer mint failed and secrets.MATHLIB_CACHE_SAS is empty after trimming"
666+
exit 1
667+
fi
668+
669+
echo "::add-mask::$MATHLIB_CACHE_SAS"
670+
echo "MATHLIB_CACHE_AZURE_BEARER_TOKEN=" >> "$GITHUB_ENV"
671+
echo "MATHLIB_CACHE_SAS=$MATHLIB_CACHE_SAS" >> "$GITHUB_ENV"
672+
echo "Using SAS fallback because bearer mint step failed."
715673
674+
- name: Upload staged cache to Azure
675+
shell: bash
676+
run: |
716677
echo "Uploading cache to Azure..."
717678
MATHLIB_CACHE_USE_CLOUDFLARE=0 lake env "$CACHE_BIN" put-staged --staging-dir="cache-staging" --repo=${{ github.event.pull_request.head.repo.full_name || github.repository }}
718-
env:
719-
MATHLIB_CACHE_SAS_RAW: ${{ secrets.MATHLIB_CACHE_SAS }}
720679
721680
post_steps:
722681
name: Post-Build Step
@@ -784,6 +743,12 @@ jobs:
784743
- name: clean up the import graph file
785744
run: rm import_graph.dot
786745

746+
- name: check all scripts build successfully
747+
run: |
748+
lake env lean scripts/create_deprecated_modules.lean
749+
lake env lean scripts/autolabel.lean
750+
lake exe check_title_labels --labels "t-algebra" "feat: dummy PR for testing"
751+
787752
- name: build everything
788753
# make sure everything is available for test/import_all.lean
789754
# and that miscellaneous executables still work
@@ -906,7 +871,8 @@ jobs:
906871
- if: >- # bot usernames will cause this step to error with "Could not resolve to a User..."
907872
contains(steps.PR.outputs.pr_labels, 'auto-merge-after-CI') &&
908873
steps.get-label-actor.outputs.username != 'mathlib-nolints' &&
909-
steps.get-label-actor.outputs.username != 'mathlib-update-dependencies'
874+
steps.get-label-actor.outputs.username != 'mathlib-update-dependencies' &&
875+
steps.get-label-actor.outputs.username != 'mathlib-splicebot'
910876
name: check team membership
911877
uses: tspascoal/get-user-teams-membership@57e9f42acd78f4d0f496b3be4368fc5f62696662 # v3.0.0
912878
id: actorTeams
@@ -921,7 +887,9 @@ jobs:
921887
(
922888
steps.get-label-actor.outputs.username == 'mathlib-nolints' ||
923889
steps.get-label-actor.outputs.username == 'mathlib-update-dependencies' ||
890+
steps.get-label-actor.outputs.username == 'mathlib-splicebot' ||
924891
contains(steps.actorTeams.outputs.teams, 'mathlib-maintainers') ||
892+
contains(steps.actorTeams.outputs.teams, 'lean-release-managers') ||
925893
contains(steps.actorTeams.outputs.teams, 'bot-users')
926894
)
927895
name: If `auto-merge-after-CI` is present, add a `bors merge` comment.

.github/workflows/check_pr_titles.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
fi
7171
7272
- name: Add comment to fix PR title
73-
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4
73+
uses: marocchino/sticky-pull-request-comment@70d2764d1a7d5d9560b100cbea0077fc8f633987 # v3.0.2
7474
if: failure() && steps.pr-title-check.outputs.errors
7575
with:
7676
header: 'PR Title Check'
@@ -120,7 +120,7 @@ jobs:
120120
121121
- name: Add comment that PR title is fixed
122122
if: steps.pr-title-check.outcome == 'success'
123-
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4
123+
uses: marocchino/sticky-pull-request-comment@70d2764d1a7d5d9560b100cbea0077fc8f633987 # v3.0.2
124124
with:
125125
header: 'PR Title Check'
126126
# should do nothing if a 'PR Title Check' comment does not exist

.github/workflows/ci_dev.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,6 @@ jobs:
4545
pr_branch_ref: ${{ inputs.pr_branch_ref != '' && inputs.pr_branch_ref || github.sha }}
4646
run_post_ci: ${{ inputs.run_post_ci }}
4747
mathlib_ci_ref: ${{ inputs.mathlib_ci_ref }}
48+
cache_application_id: ${{ vars.CACHE_NON_MASTER_WRITER_AZURE_APP_ID }}
4849
runs_on: pr
4950
secrets: inherit

0 commit comments

Comments
 (0)