Skip to content

Commit a1022d7

Browse files
committed
Merge remote-tracking branch 'upstream/master' into prod-lp-measure
2 parents 57a4db2 + 2050510 commit a1022d7

4,396 files changed

Lines changed: 95493 additions & 40258 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/workflows/PR_summary.yml

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@ jobs:
2323
fetch-depth: 0
2424
path: pr-branch
2525

26-
# Checkout the master branch into a subdirectory
27-
- name: Checkout master branch
26+
- name: Checkout mathlib-ci
2827
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2928
with:
30-
# When testing the scripts, comment out the "ref: master"
31-
ref: master
32-
path: master-branch
29+
repository: leanprover-community/mathlib-ci
30+
ref: 4af75ac0b0d1aaf38d4546a779bc5c68b4d75069
31+
fetch-depth: 1
32+
path: ci-tools
33+
34+
- name: Set up CI scripts paths
35+
uses: ./ci-tools/.github/actions/setup-ci-scripts
3336

3437
- name: Update the merge-conflict label
3538
run: |
@@ -79,6 +82,10 @@ jobs:
7982
echo "Saving the changed files to 'changed_files.txt'..."
8083
git diff --name-only origin/${{ github.base_ref }}... | tee changed_files.txt
8184
85+
# Get all newly added files.
86+
echo "Checking for added files..."
87+
git diff --name-only --diff-filter A origin/${{ github.base_ref }}... | tee added_files.txt
88+
8289
# Get all files which were removed or renamed.
8390
echo "Checking for removed files..."
8491
@@ -152,13 +159,13 @@ jobs:
152159
printf 'currentHash=%s\n' "${currentHash}"
153160
154161
echo "Compute the counts for the HEAD of the PR"
155-
python ../master-branch/scripts/count-trans-deps.py "Mathlib/" > head.json
162+
python "${CI_SCRIPTS_DIR}/pr_summary/count-trans-deps.py" "Mathlib/" > head.json
156163
157164
# Checkout the merge base
158165
git checkout "$(git merge-base master ${{ github.event.pull_request.head.sha }})"
159166
160167
echo "Compute the counts for the merge base"
161-
python ../master-branch/scripts/count-trans-deps.py "Mathlib/" > base.json
168+
python "${CI_SCRIPTS_DIR}/pr_summary/count-trans-deps.py" "Mathlib/" > base.json
162169
163170
# switch back to the current branch: the `declarations_diff` script should be here
164171
git checkout "${currentHash}" --
@@ -173,12 +180,12 @@ jobs:
173180
PR="${{ github.event.pull_request.number }}"
174181
title="### PR summary"
175182
176-
graphAndHighPercentReports=$(python ../master-branch/scripts/import-graph-report.py base.json head.json changed_files.txt)
183+
graphAndHighPercentReports=$(python "${CI_SCRIPTS_DIR}/pr_summary/import-graph-report.py" base.json head.json changed_files.txt)
177184
178185
echo "Produce import count comment"
179186
importCount=$(
180187
printf '%s\n' "${graphAndHighPercentReports}" | sed '/^Import changes exceeding/Q'
181-
../master-branch/scripts/import_trans_difference.sh
188+
"${CI_SCRIPTS_DIR}/pr_summary/import_trans_difference.sh"
182189
)
183190
184191
echo "Produce high percentage imports"
@@ -202,7 +209,7 @@ jobs:
202209
fi
203210
204211
echo "Compute Declarations' diff comment"
205-
declDiff=$(../master-branch/scripts/declarations_diff.sh)
212+
declDiff=$("${CI_SCRIPTS_DIR}/pr_summary/declarations_diff.sh")
206213
if [ "$(printf '%s' "${declDiff}" | wc -l)" -gt 15 ]
207214
then
208215
declDiff="$(printf '<details><summary>\n\n%s\n\n</summary>\n\n%s\n\n</details>\n' "#### Declarations diff" "${declDiff}")"
@@ -214,10 +221,40 @@ jobs:
214221
printf 'hashURL: %s' "${hashURL}"
215222
216223
echo "Compute technical debt changes"
217-
techDebtVar="$(../master-branch/scripts/technical-debt-metrics.sh pr_summary)"
224+
techDebtVar="$("${CI_SCRIPTS_DIR}/reporting/technical-debt-metrics.sh" pr_summary)"
225+
226+
echo "Compute documentation reminder"
227+
workflowFilesChanged="$(grep '^\.github/workflows/' changed_files.txt || true)"
228+
if [ -n "${workflowFilesChanged}" ]
229+
then
230+
# Format each changed workflow path as a Markdown bullet: "- `path`"
231+
workflowFilesChangedMarkdown="$(sed "s|^|- \`|; s|\$|\`|" <<< "${workflowFilesChanged}")"
232+
workflowDocsReminder="$(printf "### Workflow documentation reminder\nThis PR modifies files under \`.github/workflows/\`.\nPlease update \`docs/workflows.md\` if the workflow inventory, triggers, or behavior changed.\n\nModified workflow files:\n%s\n" "${workflowFilesChangedMarkdown}")"
233+
else
234+
workflowDocsReminder=""
235+
fi
236+
237+
echo "Compute scripts-location reminder"
238+
scriptsFilesAdded="$(grep '^scripts/' added_files.txt || true)"
239+
if [ -n "${scriptsFilesAdded}" ]
240+
then
241+
# Format each added scripts path as a Markdown bullet: "- `path`"
242+
scriptsFilesAddedMarkdown="$(sed "s|^|- \`|; s|\$|\`|" <<< "${scriptsFilesAdded}")"
243+
scriptsLocationReminder="$(printf "### Scripts folder reminder\nThis PR adds files under \`scripts/\`.\nPlease consider whether each added script belongs in this repository or in \`leanprover-community/mathlib-ci\`.\n\nAdded scripts files:\n%s\n" "${scriptsFilesAddedMarkdown}")"
244+
else
245+
scriptsLocationReminder=""
246+
fi
218247
219248
# store in a file, to avoid "long arguments" error.
220249
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
250+
if [ -n "${workflowDocsReminder}" ]
251+
then
252+
printf '\n\n---\n\n%s\n' "${workflowDocsReminder}" >> please_merge_master.md
253+
fi
254+
if [ -n "${scriptsLocationReminder}" ]
255+
then
256+
printf '\n\n---\n\n%s\n' "${scriptsLocationReminder}" >> please_merge_master.md
257+
fi
221258
222259
echo "Include any errors about removed or renamed files without deprecation,"
223260
echo "as well as errors about extraneous deprecated_module additions."
@@ -233,7 +270,7 @@ jobs:
233270
fi
234271
235272
cat please_merge_master.md
236-
../master-branch/scripts/update_PR_comment.sh please_merge_master.md "${title}" "${PR}"
273+
"${CI_SCRIPTS_DIR}/pr_summary/update_PR_comment.sh" please_merge_master.md "${title}" "${PR}"
237274
238275
- name: Update the file-removed label
239276
run: |

.github/workflows/actionlint.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,16 @@ jobs:
1616
uses: reviewdog/action-actionlint@e58ee9d111489c31395fbe4857b0be6e7635dbda # v1.70.0
1717
with:
1818
tool_name: actionlint
19-
fail_level: error
19+
fail_level: any
20+
21+
ensure-sha-pinned-actions:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
26+
27+
# Using our fork's PR branch until upstream merges the improved error reporting:
28+
# https://github.com/zgosalvez/github-actions-ensure-sha-pinned-actions/pull/288
29+
# TODO: Update to upstream release once merged.
30+
- name: Ensure all actions are pinned to SHA
31+
uses: kim-em/github-actions-ensure-sha-pinned-actions@00f51cdb5bbc21f5bc873ef3a2dceef45df213af # improve-error-reporting

.github/workflows/add_label_from_diff.yaml

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,42 @@ jobs:
2121
# Don't run on forks, where we wouldn't have permissions to add the label anyway.
2222
if: github.repository == 'leanprover-community/mathlib4'
2323
steps:
24-
- name: Checkout code
24+
- name: Checkout master branch to build autolabel from
2525
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2626
with:
27-
ref: ${{ github.event.pull_request.head.sha }}
28-
fetch-depth: 0
27+
ref: master
28+
path: tools
2929
- name: Configure Lean
3030
uses: leanprover/lean-action@c544e89643240c6b398f14a431bcdc6309e36b3e # v1.4.0
3131
with:
3232
auto-config: false
3333
use-github-cache: false
3434
use-mathlib-cache: false
35-
- name: lake exe autolabel
35+
lake-package-directory: tools # Building here
36+
- name: Build autolabel from master
37+
working-directory: tools
38+
run: |
39+
lake build autolabel
40+
- name: Checkout branch to label
41+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
42+
with:
43+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
44+
fetch-depth: 0
45+
path: pr-branch
46+
- name: Run autolabel
47+
working-directory: pr-branch
3648
run: |
37-
# the checkout dance, to avoid a detached head
38-
git checkout master
39-
git checkout -
40-
labels="$(lake exe autolabel)"
49+
labels="$("${GITHUB_WORKSPACE}/tools/.lake/build/bin/autolabel")"
4150
printf '%s\n' "${labels}"
4251
# extract
4352
label="$(printf '%s' "${labels}" | sed -n 's=^::notice::.*#\[\([^,]*\)\].*=\1=p')"
4453
printf 'label: "%s"\n' "${label}"
45-
if [ -n "${label}" ]
54+
if [ -n "${label}" ] && [ -n "${PR_NUMBER}" ]
4655
then
4756
printf 'Applying label %s\n' "${label}"
4857
# we use curl rather than octokit/request-action so that the job won't fail
4958
# (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"
59+
url="https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/labels"
5160
printf 'url: %s\n' "${url}"
5261
jsonLabel="$(printf '{"labels":["%s"]}' "${label}")"
5362
printf 'jsonLabel: %s\n' "${jsonLabel}"
@@ -62,3 +71,6 @@ jobs:
6271
fi
6372
env:
6473
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74+
# the PR number could be undefined in workflows triggered by 'push',
75+
# in which case we only log the applicable label and exit
76+
PR_NUMBER: ${{ github.event.pull_request.number }}

.github/workflows/auto_assign_reviewers.yaml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/workflows/bors.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ jobs:
2626
with:
2727
concurrency_group: ${{ github.workflow }}-${{ github.ref }}-${{ github.run_id }}
2828
pr_branch_ref: ${{ github.sha }}
29-
# We don't wan't 'bors try' runs to compete with merge-candidates, so we pool trying with PR runs
29+
# bors runs should build the tools from their commit-under-test: after all, we are trying to
30+
# test 'what would happen if this was merged', so we need to use the 'would-be-post-merge' tools
31+
tools_branch_ref: ${{ github.sha }}
32+
# We don't want 'bors try' runs to compete with merge-candidates, so we pool trying with PR runs
3033
runs_on: ${{ github.ref_name == 'trying' && 'pr' || 'bors' }}
3134
secrets: inherit

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ on:
1010
# ignore staging and trying branches used by bors, these are handled by bors.yml
1111
- 'staging'
1212
- 'trying'
13+
# ignore branches meant for experiments
14+
- 'ci-dev/**'
1315
merge_group:
1416

1517
concurrency:

0 commit comments

Comments
 (0)