Skip to content

Commit 9cea5b8

Browse files
committed
Merge remote-tracking branch 'origin/master' into CB_Eisenstein_E2
2 parents 8cebcb8 + 8588bb8 commit 9cea5b8

File tree

3,996 files changed

+82951
-37273
lines changed

Some content is hidden

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

3,996 files changed

+82951
-37273
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ In particular, note that most reviewers will only notice your PR
1111
if it passes the continuous integration checks.
1212
Please ask for help on https://leanprover.zulipchat.com if needed.
1313
14-
To indicate co-authors, include lines at the bottom of the commit message
15-
(that is, before the `---`) using the following format:
14+
To indicate co-authors, include at least one commit authored by each
15+
co-author among the commits in the pull request. If necessary, you may
16+
create empty commits to indicate co-authorship, using commands like so:
17+
18+
git commit --author="Author Name <author@email.com>" --allow-empty -m "add Author Name as coauthor"
1619
17-
Co-authored-by: Author Name <author@email.com>
20+
When merging, all the commits will be squashed into a single commit listing all co-authors.
1821
1922
If you are moving or deleting declarations, please include these lines at the bottom of the commit message
2023
(that is, before the `---`) using the following format:

.github/build.in.yml

Lines changed: 101 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ jobs:
4848
- name: cleanup
4949
shell: bash # This *just* deletes old files, so is safe to run outside landrun.
5050
run: |
51-
find . -name . -o -prune -exec rm -rf -- {} +
51+
if ! find . -mindepth 1 -exec rm -rf -- {} +; then
52+
echo "ERROR: Initial cleanup failed, waiting 5 seconds and retrying..."
53+
sleep 5
54+
find . -mindepth 1 -exec rm -rf -- {} +
55+
fi
5256
# Delete all but the 5 most recent toolchains.
5357
# Make sure to delete both the `~/.elan/toolchains/X` directory and the `~/.elan/update-hashes/X` file.
5458
# Skip symbolic links (`-type d`), the current directory (`! -name .`), and `nightly` and `stable`.
@@ -66,7 +70,10 @@ jobs:
6670
- name: Checkout master branch
6771
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
6872
with:
69-
ref: master
73+
# Recall that on the `leanprover-community/mathlib4-nightly-testing` repository,
74+
# we don't maintain a `master` branch at all.
75+
# For PRs and pushes to this repository, we will use `nightly-testing` instead.
76+
ref: ${{ github.repository == 'leanprover-community/mathlib4-nightly-testing' && 'nightly-testing' || 'master' }}
7077
path: master-branch
7178

7279
# Checkout the PR branch into a subdirectory
@@ -268,31 +275,11 @@ jobs:
268275
# run this in CI if it gets an incorrect lake hash for existing cache files somehow
269276
# ../master-branch/.lake/build/bin/cache put!
270277
# do not try to upload files just downloaded
271-
../master-branch/.lake/build/bin/cache put-unpacked
278+
../master-branch/.lake/build/bin/cache --repo=${{ github.event.pull_request.head.repo.full_name || github.repository }} put-unpacked
272279
env:
273280
MATHLIB_CACHE_SAS: ${{ secrets.MATHLIB_CACHE_SAS }}
274281
MATHLIB_CACHE_S3_TOKEN: ${{ secrets.MATHLIB_CACHE_S3_TOKEN }}
275282

276-
- name: check the cache
277-
# We need network access to download dependencies
278-
# We run this inside landrun, but restrict disk access as usual.
279-
shell: landrun --unrestricted-network --rox /usr --rw /dev --rox /etc --rox /home/lean/.elan --rox /home/lean/actions-runner/_work --rox /home/lean/.cache/mathlib -rw pr-branch/.lake/ --rw pr-branch/DownstreamTest/ --env PATH --env HOME --env GITHUB_OUTPUT -- bash -euxo pipefail {0}
280-
run: |
281-
cd pr-branch
282-
283-
# Because the `lean-pr-testing-NNNN` branches use toolchains that are "updated in place"
284-
# the cache mechanism is unreliable, so we don't test it if we are on such a branch.
285-
if [[ ! $(cat lean-toolchain) =~ ^leanprover/lean4-pr-releases:pr-release-[0-9]+$ ]]; then
286-
cd DownstreamTest
287-
MATHLIB_NO_CACHE_ON_UPDATE=1 lake update
288-
289-
lake env ../../master-branch/.lake/build/bin/cache get || (sleep 1; lake env ../../master-branch/.lake/build/bin/cache get)
290-
291-
# We need to run `lake build ProofWidgets` here to retrieve ProofWidgets via Reservoir.
292-
lake build ProofWidgets
293-
lake build --no-build Mathlib
294-
fi
295-
296283
# Note: we should not be including `Archive` and `Counterexamples` in the cache.
297284
# We do this for now for the sake of not rebuilding them in every CI run
298285
# even when they are not touched.
@@ -325,8 +312,8 @@ jobs:
325312
shell: bash
326313
run: |
327314
cd pr-branch
328-
../master-branch/.lake/build/bin/cache put Archive.lean
329-
../master-branch/.lake/build/bin/cache put Counterexamples.lean
315+
../master-branch/.lake/build/bin/cache --repo=${{ github.event.pull_request.head.repo.full_name || github.repository }} put Archive.lean
316+
../master-branch/.lake/build/bin/cache --repo=${{ github.event.pull_request.head.repo.full_name || github.repository }} put Counterexamples.lean
330317
env:
331318
MATHLIB_CACHE_SAS: ${{ secrets.MATHLIB_CACHE_SAS }}
332319
MATHLIB_CACHE_S3_TOKEN: ${{ secrets.MATHLIB_CACHE_S3_TOKEN }}
@@ -413,6 +400,7 @@ jobs:
413400
COUNTEREXAMPLES_OUTCOME: ${{ steps.counterexamples.outcome }}
414401
LINT_OUTCOME: ${{ steps.lint.outcome }}
415402
TEST_OUTCOME: ${{ steps.test.outcome }}
403+
NIGHTLY_TESTING_REPO: leanprover-community/mathlib4-nightly-testing
416404
run: |
417405
master-branch/scripts/lean-pr-testing-comments.sh lean
418406
master-branch/scripts/lean-pr-testing-comments.sh batteries
@@ -425,6 +413,8 @@ jobs:
425413
steps:
426414

427415
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
416+
with:
417+
ref: "${{ PR_BRANCH_REF }}"
428418

429419
- name: Configure Lean
430420
uses: leanprover/lean-action@f807b338d95de7813c5c50d018f1c23c9b93b4ec # 2025-04-24
@@ -434,9 +424,21 @@ jobs:
434424
use-mathlib-cache: true
435425
reinstall-transient-toolchain: true
436426

427+
# TODO: this step should not be necessary, "Configure Lean" above should already achieve this.
428+
- name: get cache for Mathlib
429+
run: |
430+
# Run once without --repo, so we can diagnose what `lake exe cache get` wants to do by itself.
431+
lake exe cache get
432+
# Run again with --repo, so ensure we actually get the oleans.
433+
lake exe cache --repo=${{ github.event.pull_request.head.repo.full_name || github.repository }} get
434+
435+
437436
- name: get cache for Archive and Counterexamples
438437
run: |
438+
# Run once without --repo, so we can diagnose what `lake exe cache get` wants to do by itself.
439439
lake exe cache get Archive Counterexamples
440+
# Run again with --repo, so ensure we actually get the oleans.
441+
lake exe cache --repo=${{ github.event.pull_request.head.repo.full_name || github.repository }} get Archive Counterexamples
440442
441443
- name: verify that everything was available in the cache
442444
run: |
@@ -504,10 +506,11 @@ jobs:
504506
if: FORK_CONDITION
505507
runs-on: ubuntu-latest
506508
steps:
507-
- uses: leanprover-community/lint-style-action@f2e7272aad56233a642b08fe974cf09dd664b0c8 # 2025-05-22
509+
- uses: leanprover-community/lint-style-action@d29fb3b12c1c834450680b3c544f63fe0237a2e2 # 2025-06-20
508510
with:
509511
mode: check
510512
lint-bib-file: true
513+
ref: ${{ PR_BRANCH_REF }}
511514

512515
build_and_lint:
513516
name: CI Success
@@ -538,11 +541,13 @@ jobs:
538541
filterOutClosed: true
539542

540543
# Combine the output from the previous action with the metadata supplied by GitHub itself.
544+
# Note that if we fall back to github.event.pull_request data, the list of labels is generated when this workflow is triggered
545+
# and not updated afterwards!
541546
- id: PR
542547
shell: bash
543548
run: |
544-
echo "number=${{ steps.PR_from_push.outputs.number || github.event.pull_request.number }}" >> $GITHUB_OUTPUT
545-
echo "pr_labels=${{ steps.PR_from_push.outputs.pr_labels || join(github.event.pull_request.labels.*.name, ',') }}" >> $GITHUB_OUTPUT
549+
echo "number=${{ steps.PR_from_push.outputs.number || github.event.pull_request.number }}" | tee -a "$GITHUB_OUTPUT"
550+
echo "pr_labels=${{ steps.PR_from_push.outputs.pr_labels || join(github.event.pull_request.labels.*.name, ',') }}" | tee -a "$GITHUB_OUTPUT"
546551
547552
- if: contains(steps.PR.outputs.pr_labels, 'bench-after-CI')
548553
name: If `bench-after-CI` is present, add a `!bench` comment.
@@ -563,6 +568,74 @@ jobs:
563568
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}'
564569
565570
- if: contains(steps.PR.outputs.pr_labels, 'auto-merge-after-CI')
571+
name: Get PR label timeline data
572+
# 'auto-merge-after-CI' must be within the last 100 labels added (could be increased to 250 if needed)
573+
# query from https://stackoverflow.com/a/67939355
574+
# unfortunately we cannot query only for 'auto-merge-after-CI' events
575+
# so we have to process this with jq in the next step
576+
id: get-timeline
577+
uses: octokit/graphql-action@8ad880e4d437783ea2ab17010324de1075228110 # v2.3.2
578+
with:
579+
query: |
580+
query($owner: String!, $name: String!, $number: Int!) {
581+
repository(owner: $owner, name: $name) {
582+
pullRequest(number: $number) {
583+
timelineItems(itemTypes: LABELED_EVENT, last: 100) {
584+
nodes {
585+
... on LabeledEvent {
586+
createdAt
587+
actor { login }
588+
label { name }
589+
}
590+
}
591+
}
592+
}
593+
}
594+
}
595+
owner: leanprover-community
596+
name: mathlib4
597+
number: ${{ steps.PR.outputs.number }}
598+
env:
599+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
600+
601+
- if: contains(steps.PR.outputs.pr_labels, 'auto-merge-after-CI')
602+
name: Extract label actor username
603+
id: get-label-actor
604+
run: |
605+
# Parse the GraphQL response and filter for the specific label
606+
echo '${{ steps.get-timeline.outputs.data }}'
607+
USERNAME=$(echo '${{ steps.get-timeline.outputs.data }}' | jq -r '
608+
.repository.pullRequest.timelineItems.nodes
609+
| map(select(.label.name == "auto-merge-after-CI"))
610+
| sort_by(.createdAt)
611+
| last
612+
| .actor.login // empty
613+
')
614+
615+
# Validate username format (GitHub usernames are alphanumeric + hyphens, max 39 chars)
616+
printf 'USERNAME: %s\n' "$USERNAME"
617+
if [[ -z "$USERNAME" ]]; then
618+
echo "Error: No actor found for the specified label"
619+
exit 1
620+
elif ! [[ "$USERNAME" =~ ^[a-zA-Z0-9-]{1,39}$ ]]; then
621+
echo "Error: Invalid username format: $USERNAME"
622+
exit 1
623+
fi
624+
625+
echo "username=$USERNAME" >> "$GITHUB_OUTPUT"
626+
echo "Found label actor: $USERNAME"
627+
628+
- if: contains(steps.PR.outputs.pr_labels, 'auto-merge-after-CI')
629+
name: check team membership
630+
uses: tspascoal/get-user-teams-membership@57e9f42acd78f4d0f496b3be4368fc5f62696662 # v3.0.0
631+
id: actorTeams
632+
with:
633+
organization: leanprover-community # optional. Default value ${{ github.repository_owner }}
634+
# Organization to get membership from.
635+
username: ${{ steps.get-label-actor.outputs.username }}
636+
GITHUB_TOKEN: ${{ secrets.MATHLIB_REVIEWERS_TEAM_KEY }} # (Requires scope: `read:org`)
637+
638+
- if: ${{ contains(steps.PR.outputs.pr_labels, 'auto-merge-after-CI') && (contains(steps.actorTeams.outputs.teams, 'mathlib-maintainers') || contains(steps.actorTeams.outputs.teams, 'bot-users')) }}
566639
name: If `auto-merge-after-CI` is present, add a `bors merge` comment.
567640
uses: GrantBirki/comment@608e41b19bc973020ec0e189ebfdae935d7fe0cc # v2.1.1
568641
with:

.github/workflows/PR_summary.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
build:
1414
name: "post-or-update-summary-comment"
1515
runs-on: ubuntu-latest
16+
if: github.repository == 'leanprover-community/mathlib4'
1617

1718
steps:
1819
- name: Checkout code
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: automatically assign reviewers
2+
3+
on:
4+
schedule:
5+
- cron: "37 0 * * *" # At 00:37 UTC every day
6+
workflow_dispatch:
7+
8+
jobs:
9+
autoassign-reviewers:
10+
if: github.repository == 'leanprover-community/mathlib4'
11+
name: assign automatically proposed reviewers
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
15+
with:
16+
ref: master
17+
sparse-checkout: |
18+
scripts/assign_reviewers.py
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
22+
with:
23+
python-version: '3.x'
24+
25+
- name: assign reviewers
26+
env:
27+
ASSIGN_REVIEWERS_TOKEN: ${{ secrets.ASSIGN_REVIEWERS }}
28+
run: |
29+
python3 scripts/assign_reviewers.py

0 commit comments

Comments
 (0)