Skip to content

Commit d3b7303

Browse files
Merge branch 'master' into mitchell-horner/turan-density
2 parents 65e65bc + 3117eec commit d3b7303

1,288 files changed

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

Lines changed: 333 additions & 95 deletions
Large diffs are not rendered by default.

.github/workflows/PR_summary.yml

Lines changed: 49 additions & 22 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,6 +108,7 @@ jobs:
87108
88109
- name: Compute (re)moved files without deprecation
89110
run: |
111+
cd pr-branch
90112
touch moved_without_deprecation.txt
91113
git checkout ${{ github.base_ref }}
92114
while IFS= read -r file
@@ -112,40 +134,44 @@ jobs:
112134
113135
- name: Compute transitive imports
114136
run: |
137+
cd pr-branch
115138
# the checkout dance, to avoid a detached head
116139
git checkout master
117140
git checkout -
118141
currentHash="$(git rev-parse HEAD)"
142+
printf 'currentHash=%s\n' "${currentHash}"
119143
120-
# Compute the counts for the HEAD of the PR
121-
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
122146
123147
# Checkout the merge base
124-
git checkout "$(git merge-base master ${{ github.sha }})"
148+
git checkout "$(git merge-base master ${{ github.event.pull_request.head.sha }})"
125149
126-
# Compute the counts for the merge base
127-
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
128152
129153
# switch back to the current branch: the `declarations_diff` script should be here
130-
git checkout "${currentHash}"
154+
git checkout "${currentHash}" --
131155
132156
- name: Post or update the summary comment
133157
env:
134158
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
135159
BRANCH_NAME: ${{ github.head_ref }}
136160
run: |
161+
cd pr-branch
162+
currentHash="$(git rev-parse HEAD)"
137163
PR="${{ github.event.pull_request.number }}"
138164
title="### PR summary"
139165
140-
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)
141167
142-
## Import count comment
168+
echo "Produce import count comment"
143169
importCount=$(
144170
printf '%s\n' "${graphAndHighPercentReports}" | sed '/^Import changes exceeding/Q'
145-
./scripts/import_trans_difference.sh
171+
../master-branch/scripts/import_trans_difference.sh
146172
)
147173
148-
## High percentage imports
174+
echo "Produce high percentage imports"
149175
high_percentages=$(
150176
printf '%s\n' "${graphAndHighPercentReports}" | sed -n '/^Import changes exceeding/,$p'
151177
)
@@ -165,36 +191,37 @@ jobs:
165191
importCount="$(printf '#### Import changes for modified files\n\n%s\n' "${importCount}")"
166192
fi
167193
168-
## Declarations' diff comment
169-
declDiff=$(./scripts/declarations_diff.sh)
194+
echo "Compute Declarations' diff comment"
195+
declDiff=$(../master-branch/scripts/declarations_diff.sh)
170196
if [ "$(printf '%s' "${declDiff}" | wc -l)" -gt 15 ]
171197
then
172198
declDiff="$(printf '<details><summary>\n\n%s\n\n</summary>\n\n%s\n\n</details>\n' "#### Declarations diff" "${declDiff}")"
173199
else
174200
declDiff="$(printf '#### Declarations diff\n\n%s\n' "${declDiff}")"
175201
fi
176-
git checkout "${BRANCH_NAME}"
177-
currentHash="$(git rev-parse HEAD)"
202+
git checkout "${currentHash}" --
178203
hashURL="https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}/commits/${currentHash}"
204+
printf 'hashURL: %s' "${hashURL}"
179205
180-
## Technical debt changes
181-
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)"
182208
183209
# store in a file, to avoid "long arguments" error.
184210
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
185211
186-
# At the end, include any errors about removed or renamed files without deprecation.
212+
echo "Include any errors about removed or renamed files without deprecation."
187213
if [ -s moved_without_deprecation.txt ]
188214
then
189215
printf '\n\n---\n\n' >> please_merge_master.md
190216
cat moved_without_deprecation.txt >> please_merge_master.md
191217
fi
192218
193219
cat please_merge_master.md
194-
./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}"
195221
196222
- name: Update the file-removed label
197223
run: |
224+
cd pr-branch
198225
undeprecatedMoves="$(cat moved_without_deprecation.txt)"
199226
if [ -n "$undeprecatedMoves" ]; then
200227
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)