Skip to content

Commit 3809e45

Browse files
committed
Merge remote-tracking branch 'upstream/master' into volume
2 parents 3c0e0ac + eddcb62 commit 3809e45

4,607 files changed

Lines changed: 114413 additions & 49501 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.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# get-mathlib-ci
2+
3+
This action is the source of truth for how workflows in this repository check out
4+
`leanprover-community/mathlib-ci`.
5+
6+
## Policy
7+
8+
Any workflow that needs `mathlib-ci` should use this action instead of writing its
9+
own `actions/checkout` block for `leanprover-community/mathlib-ci`.
10+
11+
The default `ref` in [`action.yml`](./action.yml) is the single canonical pinned
12+
`mathlib-ci` commit for this repository.
13+
14+
## Why
15+
16+
- Keep the pinned `mathlib-ci` ref in one place.
17+
- Avoid drift and copy/paste mistakes across many workflows.
18+
- Make ref bumps a one-file update.
19+
20+
## Usage
21+
22+
In workflows, check out this repository's actions from the running workflow commit,
23+
then use the local action:
24+
25+
```yaml
26+
- name: Checkout local actions
27+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
28+
with:
29+
ref: ${{ github.workflow_sha }}
30+
fetch-depth: 1
31+
sparse-checkout: .github/actions
32+
path: workflow-actions
33+
34+
- name: Get mathlib-ci
35+
uses: ./workflow-actions/.github/actions/get-mathlib-ci
36+
```
37+
38+
Override the ref only when needed:
39+
40+
```yaml
41+
- name: Get mathlib-ci
42+
uses: ./workflow-actions/.github/actions/get-mathlib-ci
43+
with:
44+
ref: master
45+
```
46+
47+
## Outputs
48+
49+
This action also exposes values that later workflow steps can reuse:
50+
51+
- `ref`: the effective `mathlib-ci` ref that was checked out. If the workflow did
52+
not pass `with.ref`, this is the action's default pinned commit.
53+
- `path`: the checkout path used for `mathlib-ci`.
54+
- `scripts_dir`: the absolute path to the checked out `scripts` directory.
55+
56+
The action also exports these environment variables for subsequent steps:
57+
58+
- `CI_CHECKOUT_PATH`: the absolute path to the checked out `mathlib-ci` repository.
59+
- `CI_SCRIPTS_DIR`: the absolute path to the checked out `mathlib-ci/scripts` directory.
60+
61+
If a workflow needs to refer to the exact resolved `mathlib-ci` ref later, use the
62+
action output instead of duplicating the pinned SHA in the workflow:
63+
64+
```yaml
65+
- name: Get mathlib-ci
66+
id: get_mathlib_ci
67+
uses: ./workflow-actions/.github/actions/get-mathlib-ci
68+
69+
- name: Use resolved ref
70+
run: |
71+
echo "Resolved ref: ${{ steps.get_mathlib_ci.outputs.ref }}"
72+
echo "Scripts dir: ${{ steps.get_mathlib_ci.outputs.scripts_dir }}"
73+
echo "Raw URL: https://raw.githubusercontent.com/leanprover-community/mathlib-ci/${{ steps.get_mathlib_ci.outputs.ref }}/scripts/nightly/create-adaptation-pr.sh"
74+
```
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Source of truth for `mathlib-ci` checkout settings in this repository.
2+
# Workflows should use this action instead of duplicating the checkout block
3+
# and hardcoded ref in multiple places.
4+
name: Get mathlib-ci
5+
description: Checkout leanprover-community/mathlib-ci at a shared ref.
6+
inputs:
7+
ref:
8+
description: Git ref (branch, tag, or SHA) for mathlib-ci.
9+
required: false
10+
# Default pinned commit used by workflows unless they explicitly override.
11+
# Update this ref as needed to pick up changes to mathlib-ci scripts
12+
default: 261ca4c0c6bd3267e4846ef9fdd676afab9fef4e
13+
path:
14+
description: Checkout destination path.
15+
required: false
16+
default: ci-tools
17+
fetch-depth:
18+
description: Number of commits to fetch.
19+
required: false
20+
default: '1'
21+
outputs:
22+
ref:
23+
description: Effective ref used for the checkout.
24+
value: ${{ inputs.ref }}
25+
path:
26+
description: Checkout path used.
27+
value: ${{ inputs.path }}
28+
scripts_dir:
29+
description: Absolute path to the scripts directory.
30+
value: ${{ steps.paths.outputs.scripts_dir }}
31+
runs:
32+
using: composite
33+
steps:
34+
- name: Get mathlib-ci
35+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
36+
with:
37+
repository: leanprover-community/mathlib-ci
38+
ref: ${{ inputs.ref }}
39+
fetch-depth: ${{ inputs.fetch-depth }}
40+
path: ${{ inputs.path }}
41+
42+
- name: Setup CI Scripts Paths
43+
id: paths
44+
shell: bash
45+
run: |
46+
checkout_path="${GITHUB_WORKSPACE}/${{ inputs.path }}"
47+
scripts_dir="${checkout_path}/scripts"
48+
echo "checkout_path=${checkout_path}" >> "$GITHUB_OUTPUT"
49+
echo "scripts_dir=${scripts_dir}" >> "$GITHUB_OUTPUT"
50+
echo "CI_CHECKOUT_PATH=${checkout_path}" >> "$GITHUB_ENV"
51+
echo "CI_SCRIPTS_DIR=${scripts_dir}" >> "$GITHUB_ENV"

.github/dependabot.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ version: 2 # Specifies the version of the Dependabot configuration file format
33
updates:
44
# Configuration for dependency updates
55
- package-ecosystem: "github-actions" # Specifies the ecosystem to check for updates
6-
directories:
7-
- "/.github/*" # covers `build.in.yml` as well, which is not in `.github/workflows/` because it shouldn't be run in CI.
6+
directories:
7+
- "/.github/workflows"
88
schedule:
99
# Check for updates to GitHub Actions every month
1010
interval: "monthly"
1111
groups:
12-
# group updates into single PRs since we want to update both build.in.yml and its outputs at the same time
12+
# group updates into single PRs
1313
actions-version-updates:
1414
applies-to: version-updates
1515
patterns:

.github/workflows/PR_summary.yml

Lines changed: 51 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,21 @@ jobs:
1717

1818
steps:
1919
- name: Checkout code
20-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
20+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2121
with:
2222
ref: ${{ github.event.pull_request.head.sha }}
2323
fetch-depth: 0
2424
path: pr-branch
2525

26-
# Checkout the master branch into a subdirectory
27-
- name: Checkout master branch
28-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
26+
- name: Checkout local actions
27+
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+
ref: ${{ github.workflow_sha }}
30+
fetch-depth: 1
31+
sparse-checkout: .github/actions
32+
path: workflow-actions
33+
- name: Get mathlib-ci
34+
uses: ./workflow-actions/.github/actions/get-mathlib-ci
3335

3436
- name: Update the merge-conflict label
3537
run: |
@@ -60,7 +62,7 @@ jobs:
6062
fi
6163
6264
- name: Set up Python
63-
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
65+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
6466
with:
6567
python-version: 3.12
6668

@@ -79,6 +81,10 @@ jobs:
7981
echo "Saving the changed files to 'changed_files.txt'..."
8082
git diff --name-only origin/${{ github.base_ref }}... | tee changed_files.txt
8183
84+
# Get all newly added files.
85+
echo "Checking for added files..."
86+
git diff --name-only --diff-filter A origin/${{ github.base_ref }}... | tee added_files.txt
87+
8288
# Get all files which were removed or renamed.
8389
echo "Checking for removed files..."
8490
@@ -152,13 +158,13 @@ jobs:
152158
printf 'currentHash=%s\n' "${currentHash}"
153159
154160
echo "Compute the counts for the HEAD of the PR"
155-
python ../master-branch/scripts/count-trans-deps.py "Mathlib/" > head.json
161+
python "${CI_SCRIPTS_DIR}/pr_summary/count-trans-deps.py" "Mathlib/" > head.json
156162
157163
# Checkout the merge base
158164
git checkout "$(git merge-base master ${{ github.event.pull_request.head.sha }})"
159165
160166
echo "Compute the counts for the merge base"
161-
python ../master-branch/scripts/count-trans-deps.py "Mathlib/" > base.json
167+
python "${CI_SCRIPTS_DIR}/pr_summary/count-trans-deps.py" "Mathlib/" > base.json
162168
163169
# switch back to the current branch: the `declarations_diff` script should be here
164170
git checkout "${currentHash}" --
@@ -173,12 +179,12 @@ jobs:
173179
PR="${{ github.event.pull_request.number }}"
174180
title="### PR summary"
175181
176-
graphAndHighPercentReports=$(python ../master-branch/scripts/import-graph-report.py base.json head.json changed_files.txt)
182+
graphAndHighPercentReports=$(python "${CI_SCRIPTS_DIR}/pr_summary/import-graph-report.py" base.json head.json changed_files.txt)
177183
178184
echo "Produce import count comment"
179185
importCount=$(
180186
printf '%s\n' "${graphAndHighPercentReports}" | sed '/^Import changes exceeding/Q'
181-
../master-branch/scripts/import_trans_difference.sh
187+
"${CI_SCRIPTS_DIR}/pr_summary/import_trans_difference.sh"
182188
)
183189
184190
echo "Produce high percentage imports"
@@ -202,7 +208,7 @@ jobs:
202208
fi
203209
204210
echo "Compute Declarations' diff comment"
205-
declDiff=$(../master-branch/scripts/declarations_diff.sh)
211+
declDiff=$("${CI_SCRIPTS_DIR}/pr_summary/declarations_diff.sh")
206212
if [ "$(printf '%s' "${declDiff}" | wc -l)" -gt 15 ]
207213
then
208214
declDiff="$(printf '<details><summary>\n\n%s\n\n</summary>\n\n%s\n\n</details>\n' "#### Declarations diff" "${declDiff}")"
@@ -214,10 +220,40 @@ jobs:
214220
printf 'hashURL: %s' "${hashURL}"
215221
216222
echo "Compute technical debt changes"
217-
techDebtVar="$(../master-branch/scripts/technical-debt-metrics.sh pr_summary)"
223+
techDebtVar="$("${CI_SCRIPTS_DIR}/reporting/technical-debt-metrics.sh" pr_summary)"
224+
225+
echo "Compute documentation reminder"
226+
workflowFilesChanged="$(grep '^\.github/workflows/' changed_files.txt || true)"
227+
if [ -n "${workflowFilesChanged}" ]
228+
then
229+
# Format each changed workflow path as a Markdown bullet: "- `path`"
230+
workflowFilesChangedMarkdown="$(sed "s|^|- \`|; s|\$|\`|" <<< "${workflowFilesChanged}")"
231+
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}")"
232+
else
233+
workflowDocsReminder=""
234+
fi
235+
236+
echo "Compute scripts-location reminder"
237+
scriptsFilesAdded="$(grep '^scripts/' added_files.txt || true)"
238+
if [ -n "${scriptsFilesAdded}" ]
239+
then
240+
# Format each added scripts path as a Markdown bullet: "- `path`"
241+
scriptsFilesAddedMarkdown="$(sed "s|^|- \`|; s|\$|\`|" <<< "${scriptsFilesAdded}")"
242+
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}")"
243+
else
244+
scriptsLocationReminder=""
245+
fi
218246
219247
# store in a file, to avoid "long arguments" error.
220248
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
249+
if [ -n "${workflowDocsReminder}" ]
250+
then
251+
printf '\n\n---\n\n%s\n' "${workflowDocsReminder}" >> please_merge_master.md
252+
fi
253+
if [ -n "${scriptsLocationReminder}" ]
254+
then
255+
printf '\n\n---\n\n%s\n' "${scriptsLocationReminder}" >> please_merge_master.md
256+
fi
221257
222258
echo "Include any errors about removed or renamed files without deprecation,"
223259
echo "as well as errors about extraneous deprecated_module additions."
@@ -233,7 +269,7 @@ jobs:
233269
fi
234270
235271
cat please_merge_master.md
236-
../master-branch/scripts/update_PR_comment.sh please_merge_master.md "${title}" "${PR}"
272+
"${CI_SCRIPTS_DIR}/pr_summary/update_PR_comment.sh" please_merge_master.md "${title}" "${PR}"
237273
238274
- name: Update the file-removed label
239275
run: |

.github/workflows/actionlint.yml

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,22 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout
13-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
13+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1414

1515
- name: suggester / actionlint
16-
uses: reviewdog/action-actionlint@83e4ed25b168066ad8f62f5afbb29ebd8641d982 # v1.69.1
16+
uses: reviewdog/action-actionlint@0d952c597ef8459f634d7145b0b044a9699e5e43 # v1.71.0
1717
with:
1818
tool_name: actionlint
19-
fail_level: error
19+
fail_level: any
2020

21-
check_build_yml:
22-
name: check workflows generated by build.in.yml
21+
ensure-sha-pinned-actions:
2322
runs-on: ubuntu-latest
2423
steps:
25-
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
26-
27-
- name: update workflows
28-
run: |
29-
cd .github/workflows/
30-
./mk_build_yml.sh
24+
- name: Checkout
25+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3126

32-
- name: suggester / build.in.yml
33-
uses: reviewdog/action-suggester@aa38384ceb608d00f84b4690cacc83a5aba307ff # v1.24.0
34-
with:
35-
tool_name: mk_build_yml.sh
36-
fail_level: error
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: 24 additions & 12 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
25-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
24+
- name: Checkout master branch to build autolabel from
25+
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
30-
uses: leanprover/lean-action@434f25c2f80ded67bba02502ad3a86f25db50709 # v1.3.0
30+
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 }}

0 commit comments

Comments
 (0)