Skip to content

Commit 7c8bf3f

Browse files
Merge branch 'master' into mitchell-horner/kovari-sos-turan
2 parents d4c88ba + 3117eec commit 7c8bf3f

3,774 files changed

Lines changed: 92997 additions & 45013 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/build.in.yml

Lines changed: 346 additions & 156 deletions
Large diffs are not rendered by default.

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,13 @@ updates:
88
schedule:
99
# Check for updates to GitHub Actions every month
1010
interval: "monthly"
11+
groups:
12+
# group updates into single PRs since we want to update both build.in.yml and its outputs at the same time
13+
actions-version-updates:
14+
applies-to: version-updates
15+
patterns:
16+
- "*"
17+
actions-security-updates:
18+
applies-to: security-updates
19+
patterns:
20+
- "*"

.github/workflows/PR_summary.yml

Lines changed: 141 additions & 25 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,16 +47,19 @@ 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 \
34-
--url https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels/merge-conflict \
35-
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}'
54+
--header 'Accept: application/vnd.github+json' \
55+
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
56+
--header 'X-GitHub-Api-Version: 2022-11-28' \
57+
--url https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels \
58+
--data '{"labels":["merge-conflict"]}'
3659
fi
3760
3861
- name: Set up Python
39-
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
62+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
4063
with:
4164
python-version: 3.12
4265

@@ -46,46 +69,109 @@ jobs:
4669
sudo apt-get install -y jq
4770
# If you have additional dependencies, install them here
4871
49-
- name: Get changed files
72+
- name: Get changed and removed/renamed files
5073
run: |
74+
cd pr-branch
5175
git fetch origin ${{ github.base_ref }} # fetch the base branch
52-
git diff --name-only origin/${{ github.base_ref }}... > changed_files.txt # get the list of changed files
76+
77+
# Get the list of all changed files.
78+
echo "Saving the changed files to 'changed_files.txt'..."
79+
git diff --name-only origin/${{ github.base_ref }}... | tee changed_files.txt
80+
81+
# Get all files which were removed or renamed.
82+
echo "Checking for removed files..."
83+
84+
# Shows the `D`eleted files, one per line.
85+
git diff --name-only --diff-filter D origin/${{ github.base_ref }}... | tee removed_files.txt
86+
echo "Checking for renamed files..."
87+
88+
# Shows the `R`enamed files, in human readable format
89+
# The `awk` pipe
90+
# * extracts into an array the old name as the key and the new name as the value
91+
# * eventually prints "`oldName` was renamed to `newName`" for each key-value pair.
92+
git diff -p --summary --diff-filter=R origin/${{ github.base_ref }}... |
93+
awk '
94+
/^rename from / {
95+
file=$0
96+
gsub(/rename from /, "", file)
97+
oldFile=file
98+
}
99+
/^rename to / {
100+
file=$0
101+
gsub(/rename to /, "", file)
102+
oldNew[oldFile]=file
103+
} END {
104+
for(old in oldNew) {
105+
printf("`%s` was renamed to `%s`\n", old, oldNew[old])
106+
}
107+
}' | tee renamed_files.txt
108+
109+
- name: Compute (re)moved files without deprecation
110+
run: |
111+
cd pr-branch
112+
touch moved_without_deprecation.txt
113+
git checkout ${{ github.base_ref }}
114+
while IFS= read -r file
115+
do
116+
if grep ^deprecated_module "${file}" ; then
117+
printf 'info: removed file %s contains a deprecation\n' "${file}"
118+
else
119+
# shellcheck disable=SC2016
120+
printf '\n⚠️ **warning**: file `%s` was removed without a module deprecation\n' "${file}" |
121+
tee -a moved_without_deprecation.txt
122+
fi
123+
done < removed_files.txt
124+
IFS=$'\n'
125+
while IFS= read -r file
126+
do
127+
# shellcheck disable=SC2016
128+
printf '\n⚠️ **warning**: file %s without a module deprecation\n' "${file}" |
129+
tee -a moved_without_deprecation.txt
130+
done < renamed_files.txt
131+
132+
# we return to the PR branch, since the next step wants it!
133+
git checkout -
53134
54135
- name: Compute transitive imports
55136
run: |
137+
cd pr-branch
56138
# the checkout dance, to avoid a detached head
57139
git checkout master
58140
git checkout -
59141
currentHash="$(git rev-parse HEAD)"
142+
printf 'currentHash=%s\n' "${currentHash}"
60143
61-
# Compute the counts for the HEAD of the PR
62-
python ./scripts/count-trans-deps.py "Mathlib/" > head.json
144+
echo "Compute the counts for the HEAD of the PR"
145+
python ../master-branch/scripts/count-trans-deps.py "Mathlib/" > head.json
63146
64147
# Checkout the merge base
65-
git checkout "$(git merge-base master ${{ github.sha }})"
148+
git checkout "$(git merge-base master ${{ github.event.pull_request.head.sha }})"
66149
67-
# Compute the counts for the merge base
68-
python ./scripts/count-trans-deps.py "Mathlib/" > base.json
150+
echo "Compute the counts for the merge base"
151+
python ../master-branch/scripts/count-trans-deps.py "Mathlib/" > base.json
69152
70153
# switch back to the current branch: the `declarations_diff` script should be here
71-
git checkout "${currentHash}"
154+
git checkout "${currentHash}" --
155+
72156
- name: Post or update the summary comment
73157
env:
74-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
158+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75159
BRANCH_NAME: ${{ github.head_ref }}
76160
run: |
161+
cd pr-branch
162+
currentHash="$(git rev-parse HEAD)"
77163
PR="${{ github.event.pull_request.number }}"
78164
title="### PR summary"
79165
80-
graphAndHighPercentReports=$(python ./scripts/import-graph-report.py base.json head.json changed_files.txt)
166+
graphAndHighPercentReports=$(python ../master-branch/scripts/import-graph-report.py base.json head.json changed_files.txt)
81167
82-
## Import count comment
168+
echo "Produce import count comment"
83169
importCount=$(
84170
printf '%s\n' "${graphAndHighPercentReports}" | sed '/^Import changes exceeding/Q'
85-
./scripts/import_trans_difference.sh
171+
../master-branch/scripts/import_trans_difference.sh
86172
)
87173
88-
## High percentage imports
174+
echo "Produce high percentage imports"
89175
high_percentages=$(
90176
printf '%s\n' "${graphAndHighPercentReports}" | sed -n '/^Import changes exceeding/,$p'
91177
)
@@ -105,23 +191,53 @@ jobs:
105191
importCount="$(printf '#### Import changes for modified files\n\n%s\n' "${importCount}")"
106192
fi
107193
108-
## Declarations' diff comment
109-
declDiff=$(./scripts/declarations_diff.sh)
194+
echo "Compute Declarations' diff comment"
195+
declDiff=$(../master-branch/scripts/declarations_diff.sh)
110196
if [ "$(printf '%s' "${declDiff}" | wc -l)" -gt 15 ]
111197
then
112198
declDiff="$(printf '<details><summary>\n\n%s\n\n</summary>\n\n%s\n\n</details>\n' "#### Declarations diff" "${declDiff}")"
113199
else
114200
declDiff="$(printf '#### Declarations diff\n\n%s\n' "${declDiff}")"
115201
fi
116-
git checkout "${BRANCH_NAME}"
117-
currentHash="$(git rev-parse HEAD)"
202+
git checkout "${currentHash}" --
118203
hashURL="https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}/commits/${currentHash}"
204+
printf 'hashURL: %s' "${hashURL}"
119205
120-
## Technical debt changes
121-
techDebtVar="$(./scripts/technical-debt-metrics.sh pr_summary)"
206+
echo "Compute technical debt changes"
207+
techDebtVar="$(../master-branch/scripts/technical-debt-metrics.sh pr_summary)"
122208
123209
# store in a file, to avoid "long arguments" error.
124210
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
125211
212+
echo "Include any errors about removed or renamed files without deprecation."
213+
if [ -s moved_without_deprecation.txt ]
214+
then
215+
printf '\n\n---\n\n' >> please_merge_master.md
216+
cat moved_without_deprecation.txt >> please_merge_master.md
217+
fi
218+
126219
cat please_merge_master.md
127-
./scripts/update_PR_comment.sh please_merge_master.md "${title}" "${PR}"
220+
../master-branch/scripts/update_PR_comment.sh please_merge_master.md "${title}" "${PR}"
221+
222+
- name: Update the file-removed label
223+
run: |
224+
cd pr-branch
225+
undeprecatedMoves="$(cat moved_without_deprecation.txt)"
226+
if [ -n "$undeprecatedMoves" ]; then
227+
echo "This PR has undeprecated module (re)movals."
228+
# we use curl rather than octokit/request-action so that the job won't fail
229+
# (and send an annoying email) if the labels don't exist
230+
curl --request POST \
231+
--header 'Accept: application/vnd.github+json' \
232+
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
233+
--header 'X-GitHub-Api-Version: 2022-11-28' \
234+
--url https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels \
235+
--data '{"labels":["file-removed"]}'
236+
else
237+
echo "This PR (re)moves no modules without deprecations."
238+
# we use curl rather than octokit/request-action so that the job won't fail
239+
# (and send an annoying email) if the labels don't exist
240+
curl --request DELETE \
241+
--url https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels/file-removed \
242+
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}'
243+
fi
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@e18f2df7f0d4f30d11a4b963bff9b1140999480c # 2025-04-22
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 }}

.github/workflows/bench_summary_comment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
scripts/bench_summary.lean
1818
1919
- name: Configure Lean
20-
uses: leanprover/lean-action@e18f2df7f0d4f30d11a4b963bff9b1140999480c # 2025-04-22
20+
uses: leanprover/lean-action@f807b338d95de7813c5c50d018f1c23c9b93b4ec # 2025-04-24
2121
with:
2222
auto-config: false
2323
use-github-cache: false

0 commit comments

Comments
 (0)