Skip to content

Commit c93b76d

Browse files
committed
Merge branch 'master' into Frullani_integral
2 parents b2b98a2 + 35638f9 commit c93b76d

2,125 files changed

Lines changed: 29806 additions & 19256 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/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/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: 59 additions & 112 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
@@ -378,9 +311,9 @@ jobs:
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
380313
git checkout "$PREV_SHA"
381-
../tools-branch/.lake/build/bin/cache --skip-proofwidgets get
314+
../tools-branch/.lake/build/bin/cache get
382315
# Run again with --repo, to ensure we actually get the oleans.
383-
../tools-branch/.lake/build/bin/cache --repo="$CACHE_REPO" --skip-proofwidgets get
316+
../tools-branch/.lake/build/bin/cache --repo="$CACHE_REPO" get
384317
385318
echo "Switching back to branch head"
386319
git checkout "$ORIG_SHA"
@@ -393,18 +326,10 @@ jobs:
393326
394327
echo "Fetching all remaining cache..."
395328
396-
../tools-branch/.lake/build/bin/cache --skip-proofwidgets get
329+
../tools-branch/.lake/build/bin/cache get
397330
398331
# 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
332+
../tools-branch/.lake/build/bin/cache --repo="$CACHE_REPO" get
408333
409334
- name: update {Mathlib, Tactic, Counterexamples, Archive}.lean
410335
id: mk_all
@@ -459,8 +384,8 @@ jobs:
459384
shell: bash
460385
run: |
461386
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
387+
../tools-branch/.lake/build/bin/cache get Archive.lean
388+
../tools-branch/.lake/build/bin/cache get Counterexamples.lean
464389
465390
- name: build archive
466391
id: archive
@@ -672,6 +597,9 @@ jobs:
672597
name: Upload to cache
673598
needs: [build]
674599
runs-on: ubuntu-latest # These steps run on a GitHub runner; no landrun sandboxing is needed.
600+
permissions:
601+
contents: read
602+
id-token: write
675603
# We only upload the cache if the build started (whether succeeding, failing, or cancelled)
676604
# but not if any earlier step failed or was cancelled.
677605
# See discussion at https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Some.20files.20not.20found.20in.20the.20cache/near/407183836
@@ -707,16 +635,41 @@ jobs:
707635
name: cache-staging
708636
path: cache-staging
709637

710-
- name: Upload staged cache to Azure
638+
- name: Azure CLI OIDC login and mint storage bearer token
639+
id: mint_cache_bearer
640+
continue-on-error: true
641+
uses: leanprover-community/mathlib-ci/.github/actions/azure-create-cache-token@17db5ff55a65df98d55cbddcc67938f70d10dab2
642+
with:
643+
azure-client-id: ${{ inputs.cache_application_id }}
644+
azure-tenant-id: ${{ secrets.LPC_AZ_TENANT_ID }}
645+
646+
- name: Fallback to SAS token if bearer mint fails (for ease of migration)
647+
if: ${{ steps.mint_cache_bearer.outcome != 'success' }}
711648
shell: bash
649+
env:
650+
MATHLIB_CACHE_SAS_RAW: ${{ secrets.MATHLIB_CACHE_SAS }}
712651
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:]]}"}"
652+
if [ -z "$MATHLIB_CACHE_SAS_RAW" ]; then
653+
echo "Azure bearer mint failed and secrets.MATHLIB_CACHE_SAS is not set"
654+
exit 1
655+
fi
656+
657+
MATHLIB_CACHE_SAS="${MATHLIB_CACHE_SAS_RAW%"${MATHLIB_CACHE_SAS_RAW##*[![:space:]]}"}"
658+
if [ -z "$MATHLIB_CACHE_SAS" ]; then
659+
echo "Azure bearer mint failed and secrets.MATHLIB_CACHE_SAS is empty after trimming"
660+
exit 1
661+
fi
715662
663+
echo "::add-mask::$MATHLIB_CACHE_SAS"
664+
echo "MATHLIB_CACHE_AZURE_BEARER_TOKEN=" >> "$GITHUB_ENV"
665+
echo "MATHLIB_CACHE_SAS=$MATHLIB_CACHE_SAS" >> "$GITHUB_ENV"
666+
echo "Using SAS fallback because bearer mint step failed."
667+
668+
- name: Upload staged cache to Azure
669+
shell: bash
670+
run: |
716671
echo "Uploading cache to Azure..."
717672
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 }}
720673
721674
post_steps:
722675
name: Post-Build Step
@@ -816,17 +769,7 @@ jobs:
816769
needs: [style_lint, build, post_steps]
817770
runs-on: ubuntu-latest
818771
steps:
819-
- name: Generate auto merge app token
820-
id: auto-merge-app-token
821-
uses: leanprover-community/mathlib-ci/.github/actions/azure-create-github-app-token@3bb576208589a435eeaeac9b144a1b7c3e948760
822-
with:
823-
app-id: ${{ secrets.MATHLIB_AUTO_MERGE_APP_ID }}
824-
key-vault-name: ${{ vars.MATHLIB_AZ_KEY_VAULT_NAME }}
825-
key-name: mathlib-auto-merge-app-pk
826-
azure-client-id: ${{ vars.GH_APP_AZURE_CLIENT_ID_CI_AUTO_MERGE }}
827-
azure-tenant-id: ${{ secrets.LPC_AZ_TENANT_ID }}
828-
829-
- id: PR_from_push
772+
- id: PR
830773
uses: 8BitJonny/gh-get-current-pr@4056877062a1f3b624d5d4c2bedefa9cf51435c9 # 4.0.0
831774
# TODO: this may not work properly if the same commit is pushed to multiple branches:
832775
# https://github.com/8BitJonny/gh-get-current-pr/issues/8
@@ -835,16 +778,6 @@ jobs:
835778
# Only return if PR is still open
836779
filterOutClosed: true
837780

838-
# TODO: delete this step and rename `PR_from_push` to `PR` if the above step seems to work properly
839-
# Combine the output from the previous action with the metadata supplied by GitHub itself.
840-
# Note that if we fall back to github.event.pull_request data, the list of labels is generated when this workflow is triggered
841-
# and not updated afterwards!
842-
- id: PR
843-
shell: bash
844-
run: |
845-
echo "number=${{ steps.PR_from_push.outputs.number || github.event.pull_request.number }}" | tee -a "$GITHUB_OUTPUT"
846-
echo "pr_labels=${{ steps.PR_from_push.outputs.pr_labels || join(github.event.pull_request.labels.*.name, ',') }}" | tee -a "$GITHUB_OUTPUT"
847-
848781
- id: remove_labels
849782
name: Remove "awaiting-CI"
850783
# we use curl rather than octokit/request-action so that the job won't fail
@@ -854,6 +787,17 @@ jobs:
854787
--url https://api.github.com/repos/${{ github.repository }}/issues/${{ steps.PR.outputs.number }}/labels/awaiting-CI \
855788
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}'
856789
790+
- if: contains(steps.PR.outputs.pr_labels, 'auto-merge-after-CI')
791+
name: Generate auto merge app token
792+
id: auto-merge-app-token
793+
uses: leanprover-community/mathlib-ci/.github/actions/azure-create-github-app-token@3bb576208589a435eeaeac9b144a1b7c3e948760
794+
with:
795+
app-id: ${{ secrets.MATHLIB_AUTO_MERGE_APP_ID }}
796+
key-vault-name: ${{ vars.MATHLIB_AZ_KEY_VAULT_NAME }}
797+
key-name: mathlib-auto-merge-app-pk
798+
azure-client-id: ${{ vars.GH_APP_AZURE_CLIENT_ID_CI_AUTO_MERGE }}
799+
azure-tenant-id: ${{ secrets.LPC_AZ_TENANT_ID }}
800+
857801
- if: contains(steps.PR.outputs.pr_labels, 'auto-merge-after-CI')
858802
name: Get PR label timeline data
859803
# 'auto-merge-after-CI' must be within the last 100 labels added (could be increased to 250 if needed)
@@ -915,7 +859,8 @@ jobs:
915859
- if: >- # bot usernames will cause this step to error with "Could not resolve to a User..."
916860
contains(steps.PR.outputs.pr_labels, 'auto-merge-after-CI') &&
917861
steps.get-label-actor.outputs.username != 'mathlib-nolints' &&
918-
steps.get-label-actor.outputs.username != 'mathlib-update-dependencies'
862+
steps.get-label-actor.outputs.username != 'mathlib-update-dependencies' &&
863+
steps.get-label-actor.outputs.username != 'mathlib-splicebot'
919864
name: check team membership
920865
uses: tspascoal/get-user-teams-membership@57e9f42acd78f4d0f496b3be4368fc5f62696662 # v3.0.0
921866
id: actorTeams
@@ -930,7 +875,9 @@ jobs:
930875
(
931876
steps.get-label-actor.outputs.username == 'mathlib-nolints' ||
932877
steps.get-label-actor.outputs.username == 'mathlib-update-dependencies' ||
878+
steps.get-label-actor.outputs.username == 'mathlib-splicebot' ||
933879
contains(steps.actorTeams.outputs.teams, 'mathlib-maintainers') ||
880+
contains(steps.actorTeams.outputs.teams, 'lean-release-managers') ||
934881
contains(steps.actorTeams.outputs.teams, 'bot-users')
935882
)
936883
name: If `auto-merge-after-CI` is present, add a `bors merge` comment.

.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)