Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 88 additions & 15 deletions .github/ci-plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
# pull request, draft honesty then the `rest` leg only: a development signal
# pull request, ready, base honesty then the `rest` leg only, the same signal: only a pull
# not main or release/* request into a line can land on it
# pull request, ready, base the whole gate
# main or release/*
# pull request, ready, base the whole gate, without the Intel macOS jobs
# main or release/* unless the head is a release cut (`cut/v*`) or
# the base is `main`
# workflow_dispatch on the planned as that pull request, by the rows above
# head branch of one open (`regenerate.yml` dispatches this after it
# pull request commits to the head)
Expand All @@ -16,7 +17,9 @@
# tree is the tree of its second parent and the
# whole gate passed on that parent as a pull
# request or dispatched run: then nothing, and the run says
# which run verified the tree
# which run verified the tree; or when that run
# passed every job but the Intel macOS jobs it did
# not run, honesty and the Intel jobs only
#
# Why: a pull request is pushed to several times before its head is final, a
# merge of a head that already contains main lands that head's tree
Expand All @@ -27,9 +30,18 @@
# carries the stack into `main` or a release line runs the whole gate on the
# tree that lands.
#
# Intel macOS (§8.3) has about one hosted runner for this repository and the
# whole of its workload takes about three hours of it, so pull requests that
# each waited for it queued for six hours and more. A pull request into a line
# runs every other job and leaves the Intel jobs to the line: the push that
# lands it runs them on the tree it lands. A release cut, and a pull request
# into `main`, run them as part of their own gate, so the run a tag's evidence
# names (`release-gate.sh`) is still one run with every host.
#
# Inputs, all from the environment: EVENT, DRAFT, BASE (the base branch of a
# pull request), REPO, and REF (the branch a dispatch names). The jobs read `full`
# and `rows` from GITHUB_OUTPUT. `LEXLEAN_CI_ROWS` names the legs file
# pull request), HEAD (the head branch of a pull request), REPO, and REF (the
# branch a dispatch names). The jobs read `full`, `rows` and `intel` from
# GITHUB_OUTPUT. `LEXLEAN_CI_ROWS` names the legs file
# when a test runs the script elsewhere.
set -euo pipefail

Expand All @@ -39,20 +51,30 @@ draft=${DRAFT:-}
base=${BASE:-}
repo=${REPO:?REPO names owner/name}
ref=${REF:-}
head=${HEAD:-}
out=${GITHUB_OUTPUT:-/dev/stdout}
summary=${GITHUB_STEP_SUMMARY:-/dev/null}

# full, rows, and whether the Intel macOS jobs run (default: with the whole gate).
emit() {
printf 'full=%s\nrows=%s\nhonesty=%s\nfanout=%s\n' "$1" "$2" \
printf 'full=%s\nrows=%s\nhonesty=%s\nfanout=%s\nintel=%s\n' "$1" "$2" \
"$(jq -c '[.[] | select(.part == "honesty")]' <<< "$2")" \
"$(jq -c '[.[] | select(.part != "honesty")]' <<< "$2")" >> "$out"
"$(jq -c '[.[] | select(.part != "honesty")]' <<< "$2")" "${3:-$1}" >> "$out"
}

# The whole gate; INTEL (default true) says whether its Intel macOS jobs run.
whole_gate() {
emit true "$(jq -c . "$rows_file")"
emit true "$(jq -c . "$rows_file")" "${2:-true}"
printf '%s\n' "$1" >> "$summary"
}

# A pull request whose run carries the Intel macOS jobs: a release cut, whose
# run is the evidence of its tag, and a pull request into `main`.
intel_pull_request() {
case "$head" in cut/v*) return 0 ;; esac
[ "$base" = main ]
}

# These are the four auxiliary §8.3 contexts, not the number of matrix rows.
# Linux x86-64 is the normative gate; Intel macOS is a static aggregate. Every
# required context must occur exactly once, so a duplicate or foreign context
Expand All @@ -74,18 +96,61 @@ hosts_passed() {
}'
}

# Whether a jobs listing (`name<TAB>conclusion`) is the whole gate without its
# Intel macOS jobs, passed: every job concluded `success` but those Intel jobs,
# which were skipped, and the run holds the Intel context exactly once and
# skipped, the join of Atlas, the three other supported-host contexts exactly
# once, and every leg of the rows file.
linux_passed() {
local names=$1 part job
printf '%s\n' "$names" | awk -F'\t' '
$1 == "build and non-Lean tests (x86_64-apple-darwin)" { intel++ }
$1 == "Intel test construction and local targets" || $1 ~ /^Intel conformance \(/ \
|| $1 == "build and non-Lean tests (x86_64-apple-darwin)" {
if ($2 != "skipped") bad = 1
next
}
$2 != "success" { bad = 1 }
END { exit bad || intel != 1 }' || return 1
printf '%s\n' "$names" | grep -xF $'atlas (join)\tsuccess' >/dev/null || return 1
printf '%s\n' "$names" | awk -F'\t' '
BEGIN {
expected["build and non-Lean tests (aarch64-unknown-linux-gnu)"] = 1
expected["build and non-Lean tests (aarch64-apple-darwin)"] = 1
expected["build and non-Lean tests (x86_64-pc-windows-msvc)"] = 1
}
/^build and non-Lean tests \(/ {
if ($1 == "build and non-Lean tests (x86_64-apple-darwin)") next
if (!($1 in expected) || ++seen[$1] != 1 || $2 != "success") bad = 1
}
END {
for (host in expected) if (seen[host] != 1) bad = 1
exit bad
}' || return 1
for part in $(jq -r '.[].part' "$rows_file"); do
job="just vv ($part)"
[ "$part" != honesty ] || job=honesty
printf '%s\n' "$names" | grep -xF "$job"$'\tsuccess' >/dev/null || return 1
done
}

# The id of a pull request run, or a dispatched run, of this workflow on
# COMMIT that ran every job of the gate and passed every one. A draft run has
# honesty and the `rest` leg, so it is never one: the run must hold the join of
# Atlas, every exact supported-host context, and every leg of the rows file,
# and no job that did not conclude `success`.
# and no job that did not conclude `success`. With MODE `linux`, a run that
# passed every job but the Intel macOS jobs it skipped counts as well.
full_run_of() {
local commit=$1 runs id names part job
local commit=$1 mode=${2:-whole} runs id names part job
runs=$(gh api "repos/$repo/actions/workflows/ci.yml/runs?head_sha=$commit&status=success&per_page=30" \
--jq ".workflow_runs[] | select(.head_repository.full_name == \"$repo\") | select(.event == \"pull_request\" or .event == \"workflow_dispatch\") | .id") || return 1
for id in $runs; do
names=$(gh api "repos/$repo/actions/runs/$id/jobs?per_page=100" --paginate \
--jq '.jobs[] | "\(.name)\t\(.conclusion)"') || continue
if [ "$mode" = linux ] && linux_passed "$names"; then
printf '%s\n' "$id"
return 0
fi
if printf '%s\n' "$names" | awk -F'\t' '$2 != "success" { bad = 1 } END { exit bad }' \
&& printf '%s\n' "$names" | grep -xF $'atlas (join)\tsuccess' >/dev/null \
&& printf '%s\n' "$names" | hosts_passed; then
Expand All @@ -108,9 +173,9 @@ full_run_of() {
# release merge lands the regenerated head's tree, and the pull request that
# carries the line to `main` lands the release merge's.
verified_tree_run() {
local commit=$1 depth=${2:-0}
local commit=$1 depth=${2:-0} mode=${3:-whole}
while :; do
if full_run_of "$commit"; then
if full_run_of "$commit" "$mode"; then
return 0
fi
[ "$depth" -lt 4 ] || return 1
Expand All @@ -125,14 +190,14 @@ verified_tree_run() {
}

# The verified run of the second parent of HEAD, when HEAD is a merge of that
# parent with the same tree.
# parent with the same tree (MODE as for `full_run_of`).
verified_parent_run() {
local parent
parent=$(git rev-parse --verify --quiet 'HEAD^2') || return 1
[ "$(git rev-parse 'HEAD^{tree}')" = "$(git rev-parse "$parent^{tree}")" ] || return 1
# HEAD to its parent is the first of the four merges `release-gate.sh`
# walks from the tagged commit.
verified_tree_run "$parent" 1
verified_tree_run "$parent" 1 "${1:-whole}"
}

# A pull request's run: honesty then `rest` for a draft or a stacked base,
Expand All @@ -145,7 +210,11 @@ pull_request_plan() {
case "$base" in
# An unknown base is not known to be stacked: the whole gate.
main | release/* | '')
whole_gate 'Pull request ready for review: the whole gate.'
if intel_pull_request; then
whole_gate 'Pull request ready for review: the whole gate.'
else
whole_gate 'Pull request ready for review: the whole gate but its Intel macOS jobs, which the push that lands it runs.' false
fi
;;
*)
emit false "$(jq -c '[.[] | select(.part == "honesty" or .part == "rest")]' "$rows_file")"
Expand Down Expand Up @@ -175,6 +244,9 @@ case "$event" in
if run=$(verified_parent_run); then
emit false '[]'
printf 'This push merges a head whose tree it equals, and the whole gate passed on that head: run %s of %s. Nothing is run again.\n' "$run" "$repo" >> "$summary"
elif run=$(verified_parent_run linux); then
emit false "$(jq -c '[.[] | select(.part == "honesty")]' "$rows_file")" true
printf 'This push merges a head whose tree it equals, and run %s of %s passed the whole gate on it but the Intel macOS jobs: honesty and the Intel jobs only.\n' "$run" "$repo" >> "$summary"
else
whole_gate 'Push: the whole gate.'
fi
Expand All @@ -183,6 +255,7 @@ case "$event" in
if found=$(dispatched_pull_request); then
draft=${found%%$'\t'*}
base=${found#*$'\t'}
head=$ref
printf 'Dispatched on the head of an open pull request into `%s`: planned as that pull request.\n' "$base" >> "$summary"
# A ready head whose tree a full run already verified (the line a cut
# carries to `main`) is not verified again.
Expand Down
20 changes: 15 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,12 @@ jobs:
# pull request into one of those, a request (planned as the pull request whose
# head it names, when there is one), and a push to `main` run the whole
# gate, except a push that merges a head whose tree it equals and whose whole
# gate passed (it runs nothing and names the run). `.github/ci-plan.sh` is the
# decision, and RP-14 runs it against planted events.
# gate passed (it runs nothing and names the run). A pull request into a
# line runs the Intel macOS jobs only when it is a release cut (`cut/v*`) or
# its base is `main`; the push that lands any other runs them, alone after
# honesty when its tree is the one the pull request verified (`intel`).
# `.github/ci-plan.sh` is the decision, and RP-14 runs it against planted
# events.
plan:
name: plan
runs-on: ubuntu-24.04
Expand All @@ -116,6 +120,7 @@ jobs:
rows: ${{ steps.plan.outputs.rows }}
honesty: ${{ steps.plan.outputs.honesty }}
fanout: ${{ steps.plan.outputs.fanout }}
intel: ${{ steps.plan.outputs.intel }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
Expand All @@ -128,6 +133,7 @@ jobs:
EVENT: ${{ github.event_name }}
DRAFT: ${{ github.event.pull_request.draft }}
BASE: ${{ github.event.pull_request.base.ref }}
HEAD: ${{ github.event.pull_request.head.ref }}
REPO: ${{ github.repository }}
REF: ${{ github.ref_name }}
run: .github/ci-plan.sh
Expand Down Expand Up @@ -1184,10 +1190,14 @@ jobs:
# conformance binary embeds its checkout path and builds generated packages
# offline, so its same-run handoff includes those explicit dependencies.
# No build cache, credentials, or evidence from another run is admitted.
#
# Intel macOS has about one hosted runner here, and these jobs take about
# three hours of it, so they run when the plan's `intel` is set: on the line,
# on a release cut, and on a pull request into `main` (§9.4).
intel-construction:
name: Intel test construction and local targets
needs: [plan, honesty]
if: ${{ needs.plan.outputs.full == 'true' }}
if: ${{ needs.plan.outputs.intel == 'true' }}
runs-on: macos-15-intel
timeout-minutes: 240
outputs:
Expand All @@ -1210,7 +1220,7 @@ jobs:
intel-part:
name: Intel conformance (${{ matrix.lane }})
needs: [plan, intel-construction]
if: ${{ needs.plan.outputs.full == 'true' }}
if: ${{ needs.plan.outputs.intel == 'true' }}
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -1241,7 +1251,7 @@ jobs:
intel-join:
name: build and non-Lean tests (x86_64-apple-darwin)
needs: [plan, intel-construction, intel-part]
if: ${{ always() && needs.plan.outputs.full == 'true' }}
if: ${{ always() && needs.plan.outputs.intel == 'true' }}
runs-on: ubuntu-24.04
timeout-minutes: 15
steps:
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ workspace carried at those versions without a tag.

## Unreleased

- Intel macOS runs on the line, not on every pull request (SPEC.md §8.3,
§9.4). The repository has about one hosted Intel runner and the host's
workload takes about three hours of it, so pull requests queued six hours
and more for it. `ci-plan.sh` writes `intel`: a ready pull request into a
release line runs the whole gate without the Intel construction, lanes and
aggregate, unless its head is a release cut (`cut/v*`) or its base is
`main`; a push and a request run them. A push landing a tree whose pull
request run passed every job but the skipped Intel jobs runs honesty and the
Intel jobs only. Such a run never counts as the whole gate for the plan, a
dispatch or `release-gate.sh`, so a tag's evidence is still one run with
every host. `RP-14` and `RP-18` pin the new cases.

- Canonical JSON refuses duplicate keys that differ only in their escapes (SPEC.md §21.7,
`AR-11`, #475). The duplicate check compared each key as written, so `{"a":1,"\u0061":2}`
passed it and `Json::parse` returned `{"a":2}`, dropping the first member; keys are now
Expand Down
Loading
Loading