Skip to content

Commit 80d425f

Browse files
authored
Merge branch 'master' into restrictHom1
2 parents 8628ccd + b9f1435 commit 80d425f

565 files changed

Lines changed: 13151 additions & 5024 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: e7a159e9a129f92fd07e6852a742485798678473
13+
default: 910febac0a5c2751e99cfd464b99f549351f0f1a
1414
path:
1515
description: Checkout destination path.
1616
required: false
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Populates `tools-branch/` with the trusted CI tooling (`cache` binary + the
2+
# `lake-build-*` helper scripts) that `build_template.yml` invokes by path.
3+
#
4+
# Fast path: download the `tools-bin` artifact published by `publish_tools.yml`
5+
# from its latest successful `master` `push` run, unpack it, and install the
6+
# matching toolchain. Fallback: check out `tools_source_ref` and build from source
7+
# (the original behaviour). The fallback also triggers automatically if anything
8+
# about the download/verification fails, so this action can never make CI worse
9+
# than building from source.
10+
#
11+
# Requires (fast path only): `actions: read` permission. The `gh` CLI is provided
12+
# by the Hoskinson runner image. Any lookup/download failure falls through to the
13+
# source build, so the fast path can never make CI worse.
14+
name: Get CI tools
15+
description: Download prebuilt CI tools from master, or build them from source.
16+
inputs:
17+
use_artifact:
18+
description: Whether to attempt the prebuilt-artifact fast path ('true'/'false').
19+
required: true
20+
tools_source_ref:
21+
description: Git ref to check out and build from when not using the artifact.
22+
required: true
23+
github_token:
24+
description: "Token with `actions: read` on artifact_repo (fast path only)."
25+
required: false
26+
default: ''
27+
artifact_repo:
28+
description: Repository that publishes the tools artifact.
29+
required: false
30+
default: leanprover-community/mathlib4
31+
artifact_workflow:
32+
description: Workflow file that publishes the tools artifact.
33+
required: false
34+
default: publish_tools.yml
35+
path:
36+
description: Destination directory for the tools.
37+
required: false
38+
default: tools-branch
39+
runs:
40+
using: composite
41+
steps:
42+
# Resolve the run-id of the latest successful master push of the publisher.
43+
# Pure lookup: on any failure (or when the fast path is disabled) we emit an
44+
# empty run_id, which skips the download and lands us on the source-build path.
45+
- name: Resolve tools artifact run
46+
id: resolve
47+
shell: bash
48+
env:
49+
GH_TOKEN: ${{ inputs.github_token }}
50+
run: |
51+
set -uo pipefail
52+
run_id=""
53+
if [[ "${{ inputs.use_artifact }}" == "true" && -n "${{ inputs.github_token }}" ]]; then
54+
run_id=$(gh run list \
55+
--repo "${{ inputs.artifact_repo }}" \
56+
--workflow "${{ inputs.artifact_workflow }}" \
57+
--branch master --status success --event push \
58+
--limit 1 --json databaseId --jq '.[0].databaseId // empty' 2>/dev/null || true)
59+
fi
60+
echo "Resolved publisher run_id: '${run_id}'"
61+
echo "run_id=${run_id}" >> "$GITHUB_OUTPUT"
62+
63+
- name: Download tools artifact
64+
if: ${{ steps.resolve.outputs.run_id != '' }}
65+
continue-on-error: true
66+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
67+
with:
68+
name: tools-bin
69+
path: tools-artifact
70+
repository: ${{ inputs.artifact_repo }}
71+
run-id: ${{ steps.resolve.outputs.run_id }}
72+
github-token: ${{ inputs.github_token }}
73+
74+
# Unpack the tools and install the toolchain the `cache` binary was linked
75+
# against (the one guarantee the old `lake build` of the tools gave us for
76+
# free). If the tarball is missing, the unpack fails, or the toolchain won't
77+
# install, wipe any partial state and signal a source build.
78+
- name: Unpack tools
79+
id: finalize
80+
shell: bash
81+
run: |
82+
set -uo pipefail
83+
result=build
84+
tarball="tools-artifact/tools-bin.tar.gz"
85+
if [[ -f "$tarball" ]]; then
86+
echo "Found downloaded tools artifact; unpacking..."
87+
rm -rf "${{ inputs.path }}"
88+
mkdir -p "${{ inputs.path }}"
89+
if tar -xzf "$tarball" -C "${{ inputs.path }}" \
90+
&& [[ -x "${{ inputs.path }}/.lake/build/bin/cache" ]]; then
91+
toolchain="$(cat "${{ inputs.path }}/lean-toolchain")"
92+
echo "Ensuring tools toolchain is installed: ${toolchain}"
93+
# `elan toolchain install` exits non-zero when the toolchain is already
94+
# present (the common case), so install best-effort and then confirm the
95+
# toolchain is available rather than trusting the install exit code.
96+
elan toolchain install "$toolchain" || true
97+
if elan toolchain list | awk '{print $1}' | grep -qxF "$toolchain"; then
98+
result=artifact
99+
else
100+
echo "WARNING: tools toolchain '${toolchain}' is not available; falling back to source build."
101+
fi
102+
else
103+
echo "WARNING: tools artifact unpack/validation failed; falling back to source build."
104+
fi
105+
else
106+
echo "No tools artifact available; will build from source."
107+
fi
108+
if [[ "$result" != "artifact" ]]; then
109+
rm -rf "${{ inputs.path }}"
110+
fi
111+
echo "Tools source: ${result}"
112+
echo "result=${result}" >> "$GITHUB_OUTPUT"
113+
114+
- name: Checkout tools branch (source build)
115+
if: ${{ steps.finalize.outputs.result == 'build' }}
116+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
117+
with:
118+
ref: ${{ inputs.tools_source_ref }}
119+
path: ${{ inputs.path }}
120+
121+
- name: Build tools from source
122+
if: ${{ steps.finalize.outputs.result == 'build' }}
123+
shell: bash # We're only building a trusted branch with the tools, so no need to run inside landrun.
124+
run: |
125+
cd "${{ inputs.path }}"
126+
lake build cache check-yaml graph
127+
ls .lake/build/bin/cache
128+
ls .lake/build/bin/check-yaml
129+
ls .lake/packages/importGraph/.lake/build/bin/graph

.github/workflows/PR_summary.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717

1818
steps:
1919
- name: Checkout code
20-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
20+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
2121
with:
2222
ref: ${{ github.event.pull_request.head.sha }}
2323
fetch-depth: 0
@@ -26,7 +26,7 @@ jobs:
2626
persist-credentials: false
2727

2828
- name: Checkout local actions
29-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
29+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
3030
with:
3131
ref: ${{ github.workflow_sha }}
3232
fetch-depth: 1
@@ -213,10 +213,16 @@ jobs:
213213
declDiff=$("${CI_SCRIPTS_DIR}/pr_summary/declarations_diff.sh")
214214
if [ "$(printf '%s' "${declDiff}" | wc -l)" -gt 15 ]
215215
then
216-
declDiff="$(printf '<details><summary>\n\n%s\n\n</summary>\n\n%s\n\n</details>\n' "#### Declarations diff" "${declDiff}")"
216+
declDiff="$(printf '<details><summary>\n\n%s\n\n</summary>\n\n%s\n\n</details>\n' "#### Declarations diff (regex)" "${declDiff}")"
217217
else
218-
declDiff="$(printf '#### Declarations diff\n\n%s\n' "${declDiff}")"
218+
declDiff="$(printf '#### Declarations diff (regex)\n\n%s\n' "${declDiff}")"
219219
fi
220+
# Append a placeholder for the post-build, Lean-aware diff. The
221+
# `decls-diff.yml` workflow replaces the region between the markers (see
222+
# mathlib-ci's `updateDeclsDiffSection.py`); the regex block above is left
223+
# as-is. The markers are HTML comments (invisible when rendered), and the
224+
# heading carries the status (`pending` → `(Lean)` / `(Lean -- unavailable)`).
225+
declDiff="$(printf '%s\n\n<!-- DECLS_DIFF_LEAN_BEGIN -->\n#### Declarations diff (Lean -- pending)\n\n_Computed after the build finishes._\n<!-- DECLS_DIFF_LEAN_END -->\n' "${declDiff}")"
220226
git checkout "${currentHash}" --
221227
hashURL="https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}/commits/${currentHash}"
222228
printf 'hashURL: %s' "${hashURL}"

.github/workflows/actionlint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Checkout
12-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
12+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
1313

1414
- name: suggester / actionlint
1515
uses: reviewdog/action-actionlint@6fb7acc99f4a1008869fa8a0f09cfca740837d9d # v1.72.0
@@ -21,7 +21,7 @@ jobs:
2121
runs-on: ubuntu-latest
2222
steps:
2323
- name: Checkout
24-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
24+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
2525

2626
# Using our fork's PR branch until upstream merges the improved error reporting:
2727
# https://github.com/zgosalvez/github-actions-ensure-sha-pinned-actions/pull/288

.github/workflows/add_label_from_diff.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
if: github.repository == 'leanprover-community/mathlib4'
2323
steps:
2424
- name: Checkout master branch to build autolabel from
25-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
25+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
2626
with:
2727
ref: master
2828
path: tools
@@ -38,7 +38,7 @@ jobs:
3838
run: |
3939
lake build autolabel
4040
- name: Checkout branch to label
41-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
41+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
4242
with:
4343
ref: ${{ github.event.pull_request.head.sha || github.sha }}
4444
fetch-depth: 0

.github/workflows/bors.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ jobs:
3030
# Use the MASTER cache key only when merging into mathlib4 (staging branch);
3131
# 'bors try' runs (trying branch) and nightly-testing use NON_MASTER
3232
cache_application_id: ${{ github.ref_name == 'staging' && github.repository == 'leanprover-community/mathlib4' && vars.CACHE_MASTER_WRITER_AZURE_APP_ID || vars.CACHE_NON_MASTER_WRITER_AZURE_APP_ID }}
33+
# Track the cache_application_id choice above; the environment fixes the OIDC subject the Azure app trusts.
34+
# nightly-testing is intentionally left without an environment ('') so it keeps its existing ref-based trust.
35+
# TODO: give mathlib4-nightly-testing its own cache-upload environment + federated credential.
36+
cache_environment: ${{ github.repository == 'leanprover-community/mathlib4' && (github.ref_name == 'staging' && 'cache-upload-master' || 'cache-upload-forks') || '' }}
3337
# bors runs should build the tools from their commit-under-test: after all, we are trying to
3438
# test 'what would happen if this was merged', so we need to use the 'would-be-post-merge' tools
3539
tools_branch_ref: ${{ github.sha }}

.github/workflows/build.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ concurrency:
2424
permissions:
2525
contents: read
2626
id-token: write
27+
actions: read # Allow get-tools to download the prebuilt tools artifact from master's publish_tools runs
2728
pull-requests: write # Only allow PR comments/labels
2829
# All other permissions are implicitly 'none'
2930

@@ -37,5 +38,9 @@ jobs:
3738
pr_branch_ref: ${{ github.sha }}
3839
# Use the MASTER cache key only on mathlib4/master; nightly-testing and other branches use NON_MASTER
3940
cache_application_id: ${{ github.repository == 'leanprover-community/mathlib4' && github.ref == 'refs/heads/master' && vars.CACHE_MASTER_WRITER_AZURE_APP_ID || vars.CACHE_NON_MASTER_WRITER_AZURE_APP_ID }}
41+
# Track the cache_application_id choice above; the environment fixes the OIDC subject the Azure app trusts.
42+
# nightly-testing is intentionally left without an environment ('') so it keeps its existing ref-based trust.
43+
# TODO: give mathlib4-nightly-testing its own cache-upload environment + federated credential.
44+
cache_environment: ${{ github.repository == 'leanprover-community/mathlib4' && (github.ref == 'refs/heads/master' && 'cache-upload-master' || 'cache-upload-forks') || '' }}
4045
runs_on: pr
4146
secrets: inherit

.github/workflows/build_fork.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ concurrency:
2525
permissions:
2626
contents: read
2727
id-token: write
28+
actions: read # Allow get-tools to download the prebuilt tools artifact from master's publish_tools runs
2829
pull-requests: write # Only allow PR comments/labels
2930
# All other permissions are implicitly 'none'
3031

@@ -37,5 +38,6 @@ jobs:
3738
concurrency_group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
3839
pr_branch_ref: ${{ github.event.pull_request.head.sha }}
3940
cache_application_id: ${{ vars.CACHE_NON_MASTER_WRITER_AZURE_APP_ID }}
41+
cache_environment: cache-upload-forks
4042
runs_on: pr
4143
secrets: inherit

0 commit comments

Comments
 (0)