Skip to content

Commit a84fbd3

Browse files
committed
merge master
2 parents 6368f5d + fc58204 commit a84fbd3

5,388 files changed

Lines changed: 166028 additions & 83256 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.

.devcontainer/devcontainer.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
{
22
"name": "Mathlib4 dev container",
33

4-
"build": {
5-
"dockerfile": "Dockerfile"
6-
},
4+
"image": "ghcr.io/leanprover-community/mathlib4/gitpod",
75

86
"onCreateCommand": "lake exe cache get!",
97

.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: 476 additions & 164 deletions
Large diffs are not rendered by default.

.github/workflows/PR_summary.yml

Lines changed: 78 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,43 @@
11
name: Post PR summary comment
22

33
on:
4-
pull_request:
4+
pull_request_target:
5+
6+
# Limit permissions for GITHUB_TOKEN for the entire workflow
7+
permissions:
8+
contents: read
9+
pull-requests: write # Only allow PR comments/labels
10+
# All other permissions are implicitly 'none'
511

612
jobs:
713
build:
814
name: "post-or-update-summary-comment"
915
runs-on: ubuntu-latest
16+
if: github.repository == 'leanprover-community/mathlib4'
1017

1118
steps:
1219
- name: Checkout code
1320
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1421
with:
22+
ref: ${{ github.event.pull_request.head.sha }}
1523
fetch-depth: 0
24+
path: pr-branch
25+
26+
# Checkout the master branch into a subdirectory
27+
- name: Checkout master branch
28+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
29+
with:
30+
# When testing the scripts, comment out the "ref: master"
31+
ref: master
32+
path: master-branch
1633

1734
- name: Update the merge-conflict label
1835
run: |
36+
cd pr-branch
1937
printf 'PR number: "%s"\n' "${{ github.event.pull_request.number }}"
38+
git config user.name "leanprover-community-mathlib4-bot"
39+
git config user.email "leanprover-community-mathlib4-bot@users.noreply.github.com"
40+
2041
if git merge origin/master --no-ff --no-commit
2142
then
2243
git merge --abort || true
@@ -27,7 +48,7 @@ jobs:
2748
--url https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels/merge-conflict \
2849
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}'
2950
else
30-
echo "This PR has merge conflicts with main."
51+
echo "This PR has merge conflicts with master."
3152
# we use curl rather than octokit/request-action so that the job won't fail
3253
# (and send an annoying email) if the labels don't exist
3354
curl --request POST \
@@ -36,7 +57,6 @@ jobs:
3657
--header 'X-GitHub-Api-Version: 2022-11-28' \
3758
--url https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels \
3859
--data '{"labels":["merge-conflict"]}'
39-
4060
fi
4161
4262
- name: Set up Python
@@ -52,10 +72,12 @@ jobs:
5272
5373
- name: Get changed and removed/renamed files
5474
run: |
75+
cd pr-branch
5576
git fetch origin ${{ github.base_ref }} # fetch the base branch
5677
5778
# Get the list of all changed files.
58-
git diff --name-only origin/${{ github.base_ref }}... > changed_files.txt
79+
echo "Saving the changed files to 'changed_files.txt'..."
80+
git diff --name-only origin/${{ github.base_ref }}... | tee changed_files.txt
5981
6082
# Get all files which were removed or renamed.
6183
echo "Checking for removed files..."
@@ -87,61 +109,79 @@ jobs:
87109
88110
- name: Compute (re)moved files without deprecation
89111
run: |
112+
cd pr-branch
90113
touch moved_without_deprecation.txt
114+
touch extraneous_deprecated_module.txt
91115
git checkout ${{ github.base_ref }}
92-
for file in $(cat removed_files.txt) ; do
116+
while IFS= read -r file
117+
do
93118
if grep ^deprecated_module "${file}" ; then
94-
printf 'info: removed file %s contains a deprecation\n' "${file}"
119+
# shellcheck disable=SC2016
120+
printf '\n⚠️ **warning**: removed file `%s` contains a module deprecation: please add this in a follow-up PR instead\n' "${file}" |
121+
tee -a extraneous_deprecated_module.txt
95122
else
96-
printf '\n⚠️ **warning**: file `%s` was removed without a module deprecation\n' "${file}" |
123+
# shellcheck disable=SC2016
124+
printf '\nnote: file `%s` was removed.\nPlease create a follow-up pull request adding a module deprecation. Thanks!\n' "${file}" |
97125
tee -a moved_without_deprecation.txt
98126
fi
99-
done
127+
done < removed_files.txt
100128
IFS=$'\n'
101-
for file in $(cat renamed_files.txt) ; do
102-
printf '\n⚠️ **warning**: file %s without a module deprecation\n' "${file}" |
103-
tee -a moved_without_deprecation.txt
104-
done
129+
while IFS= read -r file
130+
do
131+
if grep ^deprecated_module "${file}" ; then
132+
# shellcheck disable=SC2016
133+
printf '\n⚠️ **warning**: renamed file `%s` contains a module deprecation: please add this in a follow-up PR instead\n' "${file}" |
134+
tee -a extraneous_deprecated_module.txt
135+
else
136+
# shellcheck disable=SC2016
137+
printf '\nnote: file `%s` without a module deprecation\nPlease create a follow-up pull request adding one. Thanks!\n' "${file}" |
138+
tee -a moved_without_deprecation.txt
139+
fi
140+
done < renamed_files.txt
105141
106142
# we return to the PR branch, since the next step wants it!
107143
git checkout -
108144
109145
- name: Compute transitive imports
110146
run: |
147+
cd pr-branch
111148
# the checkout dance, to avoid a detached head
112149
git checkout master
113150
git checkout -
114151
currentHash="$(git rev-parse HEAD)"
152+
printf 'currentHash=%s\n' "${currentHash}"
115153
116-
# Compute the counts for the HEAD of the PR
117-
python ./scripts/count-trans-deps.py "Mathlib/" > head.json
154+
echo "Compute the counts for the HEAD of the PR"
155+
python ../master-branch/scripts/count-trans-deps.py "Mathlib/" > head.json
118156
119157
# Checkout the merge base
120-
git checkout "$(git merge-base master ${{ github.sha }})"
158+
git checkout "$(git merge-base master ${{ github.event.pull_request.head.sha }})"
121159
122-
# Compute the counts for the merge base
123-
python ./scripts/count-trans-deps.py "Mathlib/" > base.json
160+
echo "Compute the counts for the merge base"
161+
python ../master-branch/scripts/count-trans-deps.py "Mathlib/" > base.json
124162
125163
# switch back to the current branch: the `declarations_diff` script should be here
126-
git checkout "${currentHash}"
164+
git checkout "${currentHash}" --
127165
128166
- name: Post or update the summary comment
129167
env:
130-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
168+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
131169
BRANCH_NAME: ${{ github.head_ref }}
132170
run: |
171+
cd pr-branch
172+
currentHash="$(git rev-parse HEAD)"
133173
PR="${{ github.event.pull_request.number }}"
134174
title="### PR summary"
135175
136-
graphAndHighPercentReports=$(python ./scripts/import-graph-report.py base.json head.json changed_files.txt)
176+
graphAndHighPercentReports=$(python ../master-branch/scripts/import-graph-report.py base.json head.json changed_files.txt)
137177
138-
## Import count comment
178+
echo "Produce import count comment"
139179
importCount=$(
140180
printf '%s\n' "${graphAndHighPercentReports}" | sed '/^Import changes exceeding/Q'
141-
./scripts/import_trans_difference.sh
181+
../master-branch/scripts/import_trans_difference.sh
142182
)
143183
144-
## High percentage imports
184+
echo "Produce high percentage imports"
145185
high_percentages=$(
146186
printf '%s\n' "${graphAndHighPercentReports}" | sed -n '/^Import changes exceeding/,$p'
147187
)
@@ -161,36 +201,43 @@ jobs:
161201
importCount="$(printf '#### Import changes for modified files\n\n%s\n' "${importCount}")"
162202
fi
163203
164-
## Declarations' diff comment
165-
declDiff=$(./scripts/declarations_diff.sh)
204+
echo "Compute Declarations' diff comment"
205+
declDiff=$(../master-branch/scripts/declarations_diff.sh)
166206
if [ "$(printf '%s' "${declDiff}" | wc -l)" -gt 15 ]
167207
then
168208
declDiff="$(printf '<details><summary>\n\n%s\n\n</summary>\n\n%s\n\n</details>\n' "#### Declarations diff" "${declDiff}")"
169209
else
170210
declDiff="$(printf '#### Declarations diff\n\n%s\n' "${declDiff}")"
171211
fi
172-
git checkout "${BRANCH_NAME}"
173-
currentHash="$(git rev-parse HEAD)"
212+
git checkout "${currentHash}" --
174213
hashURL="https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}/commits/${currentHash}"
214+
printf 'hashURL: %s' "${hashURL}"
175215
176-
## Technical debt changes
177-
techDebtVar="$(./scripts/technical-debt-metrics.sh pr_summary)"
216+
echo "Compute technical debt changes"
217+
techDebtVar="$(../master-branch/scripts/technical-debt-metrics.sh pr_summary)"
178218
179219
# store in a file, to avoid "long arguments" error.
180220
printf '%s [%s](%s)%s\n\n%s\n\n---\n\n%s\n\n---\n\n%s\n' "${title}" "$(git rev-parse --short HEAD)" "${hashURL}" "${high_percentages}" "${importCount}" "${declDiff}" "${techDebtVar}" > please_merge_master.md
181221
182-
# At the end, include any errors about removed or renamed files without deprecation.
222+
echo "Include any errors about removed or renamed files without deprecation,"
223+
echo "as well as errors about extraneous deprecated_module additions."
183224
if [ -s moved_without_deprecation.txt ]
184225
then
185226
printf '\n\n---\n\n' >> please_merge_master.md
186227
cat moved_without_deprecation.txt >> please_merge_master.md
187228
fi
229+
if [ -s extraneous_deprecated_module.txt ]
230+
then
231+
printf '\n\n---\n\n' >> please_merge_master.md
232+
cat extraneous_deprecated_module.txt >> please_merge_master.md
233+
fi
188234
189235
cat please_merge_master.md
190-
./scripts/update_PR_comment.sh please_merge_master.md "${title}" "${PR}"
236+
../master-branch/scripts/update_PR_comment.sh please_merge_master.md "${title}" "${PR}"
191237
192238
- name: Update the file-removed label
193239
run: |
240+
cd pr-branch
194241
undeprecatedMoves="$(cat moved_without_deprecation.txt)"
195242
if [ -n "$undeprecatedMoves" ]; then
196243
echo "This PR has undeprecated module (re)movals."
Lines changed: 48 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,64 @@
11
name: Autolabel PRs
22

33
on:
4-
pull_request:
4+
pull_request_target:
55
types: [opened]
66
push:
77
paths:
88
- scripts/autolabel.lean
99
- .github/workflows/add_label_from_diff.yaml
1010

11+
# Limit permissions for GITHUB_TOKEN for the entire workflow
12+
permissions:
13+
contents: read
14+
pull-requests: write # Only allow PR comments/labels
15+
# All other permissions are implicitly 'none'
16+
1117
jobs:
1218
add_topic_label:
1319
name: Add topic label
1420
runs-on: ubuntu-latest
1521
# Don't run on forks, where we wouldn't have permissions to add the label anyway.
1622
if: github.repository == 'leanprover-community/mathlib4'
17-
permissions:
18-
issues: write
19-
checks: write
20-
pull-requests: write
21-
contents: read
2223
steps:
23-
- name: Checkout code
24-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
25-
with:
26-
fetch-depth: 0
27-
- name: Configure Lean
28-
uses: leanprover/lean-action@f807b338d95de7813c5c50d018f1c23c9b93b4ec # 2025-04-24
29-
with:
30-
auto-config: false
31-
use-github-cache: false
32-
use-mathlib-cache: false
33-
- name: lake exe autolabel
34-
run: |
35-
# the checkout dance, to avoid a detached head
36-
git checkout master
37-
git checkout -
38-
lake exe autolabel "$NUMBER"
39-
env:
40-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41-
GH_REPO: ${{ github.repository }}
42-
NUMBER: ${{ github.event.number }}
24+
- name: Checkout code
25+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
26+
with:
27+
ref: ${{ github.event.pull_request.head.sha }}
28+
fetch-depth: 0
29+
- name: Configure Lean
30+
uses: leanprover/lean-action@f807b338d95de7813c5c50d018f1c23c9b93b4ec # 2025-04-24
31+
with:
32+
auto-config: false
33+
use-github-cache: false
34+
use-mathlib-cache: false
35+
- name: lake exe autolabel
36+
run: |
37+
# the checkout dance, to avoid a detached head
38+
git checkout master
39+
git checkout -
40+
labels="$(lake exe autolabel)"
41+
printf '%s\n' "${labels}"
42+
# extract
43+
label="$(printf '%s' "${labels}" | sed -n 's=.*#\[\([^,]*\)\].*=\1=p')"
44+
printf 'label: "%s"\n' "${label}"
45+
if [ -n "${label}" ]
46+
then
47+
printf 'Applying label %s\n' "${label}"
48+
# we use curl rather than octokit/request-action so that the job won't fail
49+
# (and send an annoying email) if the labels don't exist
50+
url="https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels"
51+
printf 'url: %s\n' "${url}"
52+
jsonLabel="$(printf '{"labels":["%s"]}' "${label}")"
53+
printf 'jsonLabel: %s\n' "${jsonLabel}"
54+
curl --request POST \
55+
--header 'Accept: application/vnd.github+json' \
56+
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
57+
--header 'X-GitHub-Api-Version: 2022-11-28' \
58+
--url "${url}" \
59+
--data "${jsonLabel}"
60+
else
61+
echo "There is no single label that we could apply, so we are not applying any label."
62+
fi
63+
env:
64+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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)