Spracherkennung für: .yml vermutete Sprache: Abap {ABAP[54] Apollo[36] Postscript[36]} [Methode: maximale Elemente, drei Dimensionen]
# Builds the trusted CI tooling (`cache`
binary + the `lake-build-
*` helper scripts)
#
from `master`
and publishes them
as a small artifact (`tools-bin`).
#
# CI runs (build_template.yml, via the `
get-tools` composite action) download this
# artifact
and use the tools directly, saving a full `master` checkout plus a ~
30s
# build
on every
run. They build the tools
from source only
when no artifact
is
# available
or a non-`master` tools branch
is requested (bors, ci_dev, nightly-testing).
#
# Trust model: this workflow
is triggered
*only* by pushes to `master` on the
# canonical repository, so every artifact it emits
is built
from trusted `master`
#
code,
and the consumer pins its download
to this workflow
's `master` `push` runs.
# The tools a CI run executes are therefore always built from trusted `master` code.
name: publish CI tools
on:
push:
branches:
- master
# Allow manual rebuilds (e.g. after fixing a broken tools build).
workflow_dispatch:
concurrency:
# Only keep the latest publish run; superseded master pushes are cancelled.
group: publish-tools-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
publish:
name: Build and publish tools
if: github.repository == 'leanprover-community/mathlib4
'
# Must run on the same kind of runner as the consumers (build_template's `pr`
# runners), so the
binary we build here will
run on the machines that use it.
runs-
on: pr
steps:
# Build
under `tools-branch/`, the same directory `build_template.yml` unpacks
# the tools
into,
in case the build bakes its own location
into the
binary.
- name: Checkout master
uses: actions/checkout@
3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.
0.
1
with:
ref: master
path: tools-branch
- name: install elan
shell: bash
run: |
set -o pipefail
curl -o elan-init.sh -sSfL
https://elan.lean-lang.org/elan-init.sh
chmod +x elan-init.sh
./elan-init.sh -y --default-toolchain none
echo
"$HOME/.elan/bin" >>
"${GITHUB_PATH}"
- name: build tools
shell: bash
run: |
cd tools-branch
# `
check-yaml`
and `graph` are built
as a smoke test that master
's tools
# still compile; only `cache` is bundled (the only one consumed by path).
lake build cache check-yaml graph
ls .lake/build/bin/cache
- name: bundle tools
shell: bash
run: |
cd tools-branch
# Tarball (rather than a plain directory artifact) so that executable bits
# and the hidden `.lake` directory survive upload/download without relying
# on `include-hidden-files` or post-download `chmod`.
#
# We bundle exactly what `build_template.yml` invokes from `tools-branch/`:
# - .lake/build: holds the `cache` binary that the build
# job runs by path (.lake/build/bin/cache).
# We ship the whole build dir, not just the
# binary, in case it needs other files there
# to run.
# - scripts/lake-build-with-retry.sh: builds Mathlib/Archive/Counterexamples/
# Wanted with retries.
# - scripts/lake-build-wrapper.py: wraps the `lake test` step.
# - lean-toolchain: the toolchain this binary was built with;
# the consumer installs it (via elan) so the
# binary has a matching Lean to run against,
# even when the PR uses a newer toolchain.
tar -czf "${GITHUB_WORKSPACE}/tools-bin.tar.gz" \
.lake/build \
scripts/lake-build-with-retry.sh \
scripts/lake-build-wrapper.py \
lean-toolchain
ls -l "${GITHUB_WORKSPACE}/tools-bin.tar.gz"
- name: upload tools artifact
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: tools-bin
path: tools-bin.tar.gz
# Master is pushed frequently, so a short retention keeps storage bounded
# while still leaving a recent artifact available.
retention-days: 7
if-no-files-found: error