Skip to content

Commit bf98076

Browse files
authored
Merge branch 'master' into restrictHom1
2 parents 2555478 + d1b620c commit bf98076

574 files changed

Lines changed: 7088 additions & 2605 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/actions/get-mathlib-ci/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ inputs:
1010
# Default pinned commit used by workflows unless they explicitly override.
1111
# Update this ref as needed to pick up changes to mathlib-ci scripts
1212
# This is also updated automatically by .github/workflows/update_dependencies.yml
13-
default: 194b03113712fdf55c2c29651f161893f0305fe8
13+
default: e7a159e9a129f92fd07e6852a742485798678473
1414
path:
1515
description: Checkout destination path.
1616
required: false

.github/workflows/PR_summary.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ jobs:
2222
ref: ${{ github.event.pull_request.head.sha }}
2323
fetch-depth: 0
2424
path: pr-branch
25+
# Untrusted (potentially fork) checkout: don't persist the GITHUB_TOKEN into its .git/config.
26+
persist-credentials: false
2527

2628
- name: Checkout local actions
2729
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

.github/workflows/add_label_from_diff.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ jobs:
4343
ref: ${{ github.event.pull_request.head.sha || github.sha }}
4444
fetch-depth: 0
4545
path: pr-branch
46+
# Untrusted (potentially fork) checkout: don't persist the GITHUB_TOKEN into its .git/config.
47+
persist-credentials: false
4648
- name: Run autolabel
4749
working-directory: pr-branch
4850
run: |

.github/workflows/bot_fix_style.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ on:
1212
# triggers on a review comment
1313
types: [created, edited]
1414

15+
# `lint-style-action` in `fix` mode pushes a style-fix commit and reacts/comments
16+
# on the PR. Grant exactly those scopes rather than inheriting the default token
17+
# permissions; all other scopes are implicitly 'none'.
18+
permissions:
19+
contents: write # push the style-fix commit to the PR branch
20+
pull-requests: write # add the bot's reaction/comment
21+
issues: write # PR comment reactions go through the issues API
22+
1523
jobs:
1624
fix_style:
1725
# we set some variables. The ones of the form `${{ X }}${{ Y }}` are typically not

.github/workflows/build_template.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ jobs:
127127
ref: ${{ inputs.pr_branch_ref }}
128128
fetch-depth: 2 # we may fetch cache from the commit before this one (or earlier)
129129
path: pr-branch
130+
# This is an untrusted (potentially fork) checkout whose code we build.
131+
# Don't leave the GITHUB_TOKEN in pr-branch/.git/config, where that code could read it.
132+
persist-credentials: false
130133

131134
- name: Prepare DownstreamTest directory
132135
shell: bash
@@ -513,19 +516,19 @@ jobs:
513516
run: |
514517
cd pr-branch
515518
set -o pipefail
516-
# Try running with --trace; if it fails due to argument parsing, the PR needs to merge master
519+
# If lint fails because the PR predates lake-lint configuration or the
520+
# old --trace argument-parsing behavior, ask the author to merge master.
517521
# We use .lake/ for the output file because landrun restricts /tmp access
518522
for attempt in 1 2; do
519-
if timeout 10m env LEAN_ABORT_ON_PANIC=1 stdbuf -oL lake exe runLinter --trace Mathlib 2>&1 | tee ".lake/lint_output_attempt_${attempt}.txt"; then
523+
if timeout 10m env LEAN_ABORT_ON_PANIC=1 stdbuf -oL lake lint -- --trace 2>&1 | tee ".lake/lint_output_attempt_${attempt}.txt"; then
520524
break
521525
fi
522526
status=${PIPESTATUS[0]}
523-
if grep -q "cannot parse arguments" ".lake/lint_output_attempt_${attempt}.txt"; then
527+
if grep -qE "cannot parse arguments|no lint driver configured" ".lake/lint_output_attempt_${attempt}.txt"; then
524528
echo ""
525529
echo "=============================================================================="
526-
echo "ERROR: Your branch uses an older version of runLinter that doesn't support"
527-
echo "the --trace flag. Please merge 'master' into your PR branch to get the"
528-
echo "updated linter, then push again."
530+
echo "ERROR: Your branch predates the current 'lake lint' configuration."
531+
echo "Please merge 'master' into your PR branch and push again."
529532
echo ""
530533
echo "You can do this with:"
531534
echo " git fetch upstream"
@@ -689,6 +692,8 @@ jobs:
689692
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
690693
with:
691694
ref: ${{ inputs.pr_branch_ref }}
695+
# Untrusted (potentially fork) checkout: don't persist the GITHUB_TOKEN into its .git/config.
696+
persist-credentials: false
692697

693698
- name: Configure Lean
694699
uses: leanprover/lean-action@38fbc41a8c28c4cbaec22d7f7de508ec2e7c0dd9 # v1.5.0

.github/workflows/decls-diff.yml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# Post-build workflow that emits a Lean-aware declarations-diff in the Actions
2+
# step summary for each successful PR build. Consumes the `import-graph`
3+
# artifact uploaded by `build_template.yml` on both sides (PR head + master
4+
# merge-base) and computes the diff via mathlib-ci's `decls-diff` action.
5+
#
6+
# Stage-2 scope: visibility only. No `### PR summary` comment patching; that
7+
# behaviour ships in a follow-up PR.
8+
9+
name: Declarations diff (post-build)
10+
11+
on:
12+
workflow_run:
13+
# Match the build workflows by their `name:` — `build.yml` (non-fork PRs,
14+
# push-triggered) and `build_fork.yml` (fork PRs, pull_request_target).
15+
workflows: ["continuous integration", "continuous integration (mathlib forks)"]
16+
types: [completed]
17+
18+
permissions:
19+
contents: read
20+
actions: read # for cross-workflow artifact downloads
21+
22+
jobs:
23+
diff:
24+
# The build never runs on a `pull_request` event: non-fork PRs build via
25+
# `build.yml` on `push` (head_branch = the PR branch), fork PRs via
26+
# `build_fork.yml` on `pull_request_target`. Accept both, and for `push`
27+
# exclude master and the non-PR maintenance branches.
28+
if: >-
29+
github.repository == 'leanprover-community/mathlib4'
30+
&& github.event.workflow_run.conclusion == 'success'
31+
&& (
32+
github.event.workflow_run.event == 'pull_request_target'
33+
|| (
34+
github.event.workflow_run.event == 'push'
35+
&& github.event.workflow_run.head_branch != 'master'
36+
&& github.event.workflow_run.head_branch != 'nightly-testing'
37+
&& !startsWith(github.event.workflow_run.head_branch, 'lean-pr-testing-')
38+
)
39+
)
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Resolve Build run + SHA
43+
id: meta
44+
run: |
45+
set -euo pipefail
46+
RUN_ID="${{ github.event.workflow_run.id }}"
47+
NEW_SHA="${{ github.event.workflow_run.head_sha }}"
48+
{
49+
echo "run-id=$RUN_ID"
50+
echo "new-sha=$NEW_SHA"
51+
} | tee -a "$GITHUB_OUTPUT"
52+
53+
- name: Checkout new commit
54+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
55+
with:
56+
ref: ${{ steps.meta.outputs.new-sha }}
57+
fetch-depth: 0
58+
59+
- name: Resolve merge-base against master
60+
id: resolve
61+
env:
62+
NEW_SHA: ${{ steps.meta.outputs.new-sha }}
63+
run: |
64+
set -euo pipefail
65+
git fetch --quiet origin master
66+
MB="$(git merge-base "$NEW_SHA" origin/master)"
67+
echo "merge-base=$MB" | tee -a "$GITHUB_OUTPUT"
68+
69+
- name: Download new-side artifact
70+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
71+
with:
72+
name: import-graph
73+
path: ./new-artifact
74+
run-id: ${{ steps.meta.outputs.run-id }}
75+
github-token: ${{ secrets.GITHUB_TOKEN }}
76+
77+
- name: Find master Build for the merge-base
78+
id: master-run
79+
env:
80+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81+
REPO: ${{ github.repository }}
82+
MB: ${{ steps.resolve.outputs.merge-base }}
83+
run: |
84+
set -euo pipefail
85+
RUN="$(gh api "repos/$REPO/actions/runs?head_sha=$MB&event=push&status=success&branch=master" \
86+
--jq '[.workflow_runs[] | select(.name=="continuous integration")] | .[0].id // ""')"
87+
# A successful run is not enough: it must also carry the `import-graph` artifact.
88+
HAS_ARTIFACT=""
89+
if [ -n "$RUN" ]; then
90+
HAS_ARTIFACT="$(gh api "repos/$REPO/actions/runs/$RUN/artifacts" \
91+
--jq '[.artifacts[] | select(.name=="import-graph")] | length')"
92+
fi
93+
if [ -n "$RUN" ] && [ "${HAS_ARTIFACT:-0}" -gt 0 ]; then
94+
{
95+
echo "found=true"
96+
echo "run-id=$RUN"
97+
} | tee -a "$GITHUB_OUTPUT"
98+
else
99+
echo "found=false" | tee -a "$GITHUB_OUTPUT"
100+
echo "No usable master Build for merge-base $MB (no run, or run lacks the import-graph artifact)."
101+
fi
102+
103+
- name: Download master-side artifact
104+
if: steps.master-run.outputs.found == 'true'
105+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
106+
with:
107+
name: import-graph
108+
path: ./ref-artifact
109+
run-id: ${{ steps.master-run.outputs.run-id }}
110+
github-token: ${{ secrets.GITHUB_TOKEN }}
111+
112+
- name: Checkout local actions
113+
if: steps.master-run.outputs.found == 'true'
114+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
115+
with:
116+
ref: ${{ github.workflow_sha }}
117+
fetch-depth: 1
118+
sparse-checkout: .github/actions
119+
path: workflow-actions
120+
121+
- name: Get mathlib-ci
122+
if: steps.master-run.outputs.found == 'true'
123+
uses: ./workflow-actions/.github/actions/get-mathlib-ci
124+
125+
- name: Compute Lean-aware declarations diff
126+
if: steps.master-run.outputs.found == 'true'
127+
uses: ./ci-tools/.github/actions/decls-diff
128+
with:
129+
reference-decls-file: ${{ github.workspace }}/ref-artifact/decls.txt
130+
reference-imports-file: ${{ github.workspace }}/ref-artifact/imports.json
131+
new-decls-file: ${{ github.workspace }}/new-artifact/decls.txt
132+
new-imports-file: ${{ github.workspace }}/new-artifact/imports.json
133+
new-sha: ${{ steps.meta.outputs.new-sha }}
134+
135+
- name: Note cache miss
136+
if: steps.master-run.outputs.found != 'true'
137+
run: |
138+
{
139+
echo "## Declarations diff"
140+
echo
141+
echo "⚠️ The Mathlib cache for this PR's merge-base \`${{ steps.resolve.outputs.merge-base }}\` isn't on the server (typically because the merge-base is a bors-batch intermediate that CI never built). Merge \`master\` into this PR and push to retrigger the build."
142+
} >> "$GITHUB_STEP_SUMMARY"

.github/workflows/maintainer_bors.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ on:
1313
pull_request_review_comment:
1414
types: [created]
1515

16+
# This job only parses the triggering comment and emits an artifact for the
17+
# privileged `maintainer_bors_wf_run` workflow to consume; it never uses the
18+
# token to mutate the repo. Keep it read-only rather than inheriting the
19+
# default token permissions.
20+
permissions:
21+
contents: read
22+
1623
jobs:
1724
add_ready_to_merge_label:
1825
# we set some variables. The ones of the form `${{ X }}${{ Y }}` are typically not

.github/workflows/nightly_bump_and_merge.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ on:
1313
# and 15 minutes after batteries `nightly-testing` branch bumps its toolchain.
1414
workflow_dispatch:
1515

16+
# Serialize runs so an overlapping scheduled run can't race the toolchain commit/push.
17+
# Never cancel an in-flight run: it may be mid-push of the bump or a pr-testing merge.
18+
concurrency:
19+
group: nightly-bump-and-merge
20+
cancel-in-progress: false
21+
1622
jobs:
1723
bump-and-merge:
1824
runs-on: ubuntu-latest
@@ -131,8 +137,18 @@ jobs:
131137
# Navigate to the cloned repository
132138
cd lean4-nightly || exit 1
133139
134-
# Fetch the $OLD tag
135-
git fetch --depth=1 origin tag "$OLD" --no-tags
140+
# Fetch the $OLD tag.
141+
# If $OLD is not a tag in lean4-nightly (e.g. nightly-testing is currently on an
142+
# rc or stable toolchain like `v4.31.0-rc1`, which only exists in leanprover/lean4),
143+
# we can't compute the PR delta. Skip lean-pr-testing adaptation discovery for this
144+
# bump rather than failing: the toolchain bump itself has already been committed and
145+
# must still be pushed (see the `Push all changes` step), otherwise nightly-testing
146+
# would be stuck on the rc/stable toolchain forever.
147+
if ! git fetch --depth=1 origin tag "$OLD" --no-tags 2>/dev/null; then
148+
echo "::notice::OLD toolchain '$OLD' is not a tag in lean4-nightly (rc/stable?). Skipping lean-pr-testing adaptation discovery for this bump."
149+
printf 'prs<<EOF\n\nEOF\n' >> "$GITHUB_OUTPUT"
150+
exit 0
151+
fi
136152
# Fetch the $NEW tag
137153
git fetch origin tag "$NEW" --no-tags
138154

0 commit comments

Comments
 (0)