Skip to content

Commit 23902bd

Browse files
committed
Merge remote-tracking branch 'origin/master' into CB_Eisenstein_E2
2 parents e761796 + 4466755 commit 23902bd

File tree

3,328 files changed

+76796
-35528
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,328 files changed

+76796
-35528
lines changed

.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/build.in.yml

Lines changed: 344 additions & 153 deletions
Large diffs are not rendered by default.

.github/workflows/PR_summary.yml

Lines changed: 77 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
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:
@@ -12,11 +18,25 @@ jobs:
1218
- name: Checkout code
1319
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1420
with:
21+
ref: ${{ github.event.pull_request.head.sha }}
1522
fetch-depth: 0
23+
path: pr-branch
24+
25+
# Checkout the master branch into a subdirectory
26+
- name: Checkout master branch
27+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
28+
with:
29+
# When testing the scripts, comment out the "ref: master"
30+
ref: master
31+
path: master-branch
1632

1733
- name: Update the merge-conflict label
1834
run: |
35+
cd pr-branch
1936
printf 'PR number: "%s"\n' "${{ github.event.pull_request.number }}"
37+
git config user.name "leanprover-community-mathlib4-bot"
38+
git config user.email "leanprover-community-mathlib4-bot@users.noreply.github.com"
39+
2040
if git merge origin/master --no-ff --no-commit
2141
then
2242
git merge --abort || true
@@ -27,7 +47,7 @@ jobs:
2747
--url https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels/merge-conflict \
2848
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}'
2949
else
30-
echo "This PR has merge conflicts with main."
50+
echo "This PR has merge conflicts with master."
3151
# we use curl rather than octokit/request-action so that the job won't fail
3252
# (and send an annoying email) if the labels don't exist
3353
curl --request POST \
@@ -36,7 +56,6 @@ jobs:
3656
--header 'X-GitHub-Api-Version: 2022-11-28' \
3757
--url https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels \
3858
--data '{"labels":["merge-conflict"]}'
39-
4059
fi
4160
4261
- name: Set up Python
@@ -52,10 +71,12 @@ jobs:
5271
5372
- name: Get changed and removed/renamed files
5473
run: |
74+
cd pr-branch
5575
git fetch origin ${{ github.base_ref }} # fetch the base branch
5676
5777
# Get the list of all changed files.
58-
git diff --name-only origin/${{ github.base_ref }}... > changed_files.txt
78+
echo "Saving the changed files to 'changed_files.txt'..."
79+
git diff --name-only origin/${{ github.base_ref }}... | tee changed_files.txt
5980
6081
# Get all files which were removed or renamed.
6182
echo "Checking for removed files..."
@@ -87,61 +108,79 @@ jobs:
87108
88109
- name: Compute (re)moved files without deprecation
89110
run: |
111+
cd pr-branch
90112
touch moved_without_deprecation.txt
113+
touch extraneous_deprecated_module.txt
91114
git checkout ${{ github.base_ref }}
92-
for file in $(cat removed_files.txt) ; do
115+
while IFS= read -r file
116+
do
93117
if grep ^deprecated_module "${file}" ; then
94-
printf 'info: removed file %s contains a deprecation\n' "${file}"
118+
# shellcheck disable=SC2016
119+
printf '\n⚠️ **warning**: removed file `%s` contains a module deprecation: please add this in a follow-up PR instead\n' "${file}" |
120+
tee -a extraneous_deprecated_module.txt
95121
else
96-
printf '\n⚠️ **warning**: file `%s` was removed without a module deprecation\n' "${file}" |
122+
# shellcheck disable=SC2016
123+
printf '\nnote: file `%s` was removed.\nPlease create a follow-up pull request adding a module deprecation. Thanks!\n' "${file}" |
97124
tee -a moved_without_deprecation.txt
98125
fi
99-
done
126+
done < removed_files.txt
100127
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
128+
while IFS= read -r file
129+
do
130+
if grep ^deprecated_module "${file}" ; then
131+
# shellcheck disable=SC2016
132+
printf '\n⚠️ **warning**: renamed file `%s` contains a module deprecation: please add this in a follow-up PR instead\n' "${file}" |
133+
tee -a extraneous_deprecated_module.txt
134+
else
135+
# shellcheck disable=SC2016
136+
printf '\nnote: file `%s` without a module deprecation\nPlease create a follow-up pull request adding one. Thanks!\n' "${file}" |
137+
tee -a moved_without_deprecation.txt
138+
fi
139+
done < renamed_files.txt
105140
106141
# we return to the PR branch, since the next step wants it!
107142
git checkout -
108143
109144
- name: Compute transitive imports
110145
run: |
146+
cd pr-branch
111147
# the checkout dance, to avoid a detached head
112148
git checkout master
113149
git checkout -
114150
currentHash="$(git rev-parse HEAD)"
151+
printf 'currentHash=%s\n' "${currentHash}"
115152
116-
# Compute the counts for the HEAD of the PR
117-
python ./scripts/count-trans-deps.py "Mathlib/" > head.json
153+
echo "Compute the counts for the HEAD of the PR"
154+
python ../master-branch/scripts/count-trans-deps.py "Mathlib/" > head.json
118155
119156
# Checkout the merge base
120-
git checkout "$(git merge-base master ${{ github.sha }})"
157+
git checkout "$(git merge-base master ${{ github.event.pull_request.head.sha }})"
121158
122-
# Compute the counts for the merge base
123-
python ./scripts/count-trans-deps.py "Mathlib/" > base.json
159+
echo "Compute the counts for the merge base"
160+
python ../master-branch/scripts/count-trans-deps.py "Mathlib/" > base.json
124161
125162
# switch back to the current branch: the `declarations_diff` script should be here
126-
git checkout "${currentHash}"
163+
git checkout "${currentHash}" --
127164
128165
- name: Post or update the summary comment
129166
env:
130-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
167+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
131168
BRANCH_NAME: ${{ github.head_ref }}
132169
run: |
170+
cd pr-branch
171+
currentHash="$(git rev-parse HEAD)"
133172
PR="${{ github.event.pull_request.number }}"
134173
title="### PR summary"
135174
136-
graphAndHighPercentReports=$(python ./scripts/import-graph-report.py base.json head.json changed_files.txt)
175+
graphAndHighPercentReports=$(python ../master-branch/scripts/import-graph-report.py base.json head.json changed_files.txt)
137176
138-
## Import count comment
177+
echo "Produce import count comment"
139178
importCount=$(
140179
printf '%s\n' "${graphAndHighPercentReports}" | sed '/^Import changes exceeding/Q'
141-
./scripts/import_trans_difference.sh
180+
../master-branch/scripts/import_trans_difference.sh
142181
)
143182
144-
## High percentage imports
183+
echo "Produce high percentage imports"
145184
high_percentages=$(
146185
printf '%s\n' "${graphAndHighPercentReports}" | sed -n '/^Import changes exceeding/,$p'
147186
)
@@ -161,36 +200,43 @@ jobs:
161200
importCount="$(printf '#### Import changes for modified files\n\n%s\n' "${importCount}")"
162201
fi
163202
164-
## Declarations' diff comment
165-
declDiff=$(./scripts/declarations_diff.sh)
203+
echo "Compute Declarations' diff comment"
204+
declDiff=$(../master-branch/scripts/declarations_diff.sh)
166205
if [ "$(printf '%s' "${declDiff}" | wc -l)" -gt 15 ]
167206
then
168207
declDiff="$(printf '<details><summary>\n\n%s\n\n</summary>\n\n%s\n\n</details>\n' "#### Declarations diff" "${declDiff}")"
169208
else
170209
declDiff="$(printf '#### Declarations diff\n\n%s\n' "${declDiff}")"
171210
fi
172-
git checkout "${BRANCH_NAME}"
173-
currentHash="$(git rev-parse HEAD)"
211+
git checkout "${currentHash}" --
174212
hashURL="https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}/commits/${currentHash}"
213+
printf 'hashURL: %s' "${hashURL}"
175214
176-
## Technical debt changes
177-
techDebtVar="$(./scripts/technical-debt-metrics.sh pr_summary)"
215+
echo "Compute technical debt changes"
216+
techDebtVar="$(../master-branch/scripts/technical-debt-metrics.sh pr_summary)"
178217
179218
# store in a file, to avoid "long arguments" error.
180219
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
181220
182-
# At the end, include any errors about removed or renamed files without deprecation.
221+
echo "Include any errors about removed or renamed files without deprecation,"
222+
echo "as well as errors about extraneous deprecated_module additions."
183223
if [ -s moved_without_deprecation.txt ]
184224
then
185225
printf '\n\n---\n\n' >> please_merge_master.md
186226
cat moved_without_deprecation.txt >> please_merge_master.md
187227
fi
228+
if [ -s extraneous_deprecated_module.txt ]
229+
then
230+
printf '\n\n---\n\n' >> please_merge_master.md
231+
cat extraneous_deprecated_module.txt >> please_merge_master.md
232+
fi
188233
189234
cat please_merge_master.md
190-
./scripts/update_PR_comment.sh please_merge_master.md "${title}" "${PR}"
235+
../master-branch/scripts/update_PR_comment.sh please_merge_master.md "${title}" "${PR}"
191236
192237
- name: Update the file-removed label
193238
run: |
239+
cd pr-branch
194240
undeprecatedMoves="$(cat moved_without_deprecation.txt)"
195241
if [ -n "$undeprecatedMoves" ]; then
196242
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 }}

0 commit comments

Comments
 (0)