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
58 changes: 37 additions & 21 deletions .github/workflows/merge-train.yml
Original file line number Diff line number Diff line change
Expand Up @@ -232,27 +232,43 @@ jobs:
python3 -m venv "$RUNNER_TEMP/draw"
"$RUNNER_TEMP/draw/bin/pip" install --quiet --no-deps --only-binary :all: --require-hashes -r bootstrap/draw-requirements.txt
fi
accepted=()
for entry in "${ready[@]}"; do
number=${entry%%:*}
head=${entry#*:}
before=$(git rev-parse HEAD)
git fetch -q origin "$head"
if ! git merge -q --no-ff --no-edit "$head" >/dev/null 2>&1; then
git merge --abort || true
printf '%s %s %s\n' "$number" "$head" "it conflicts with main ($main) and the pull requests the train takes before it" >>"$RUNNER_TEMP/refused"
continue
fi
# The pull request's own code runs without the token.
if (unset GH_TOKEN; fast_gates && bash -euo pipefail -c "$(declare -f acceptances); acceptances") >"$RUNNER_TEMP/gates-$number.log" 2>&1; then
accepted+=("$number:$head")
echo "#$number $head: the fast gates and the browser acceptances pass on main and the train before it"
else
tail -n 40 "$RUNNER_TEMP/gates-$number.log"
printf '%s %s %s\n' "$number" "$head" "the fast gates or the browser acceptances refuse it merged with main ($main) and the pull requests the train takes before it; see run $GITHUB_RUN_ID" >>"$RUNNER_TEMP/refused"
git reset -q --hard "$before"
fi
done
# The browser acceptances take about a quarter of an hour, so the train runs
# them once, on all the pull requests that board together, and one by one only
# when that tree fails, to find which of them it refuses.
board() { # board batch|each: merge each of the queue that passes the fast gates (each: and the browser acceptances) onto HEAD
local entry number head before
boarded=()
for entry in "${queue[@]}"; do
number=${entry%%:*}
head=${entry#*:}
before=$(git rev-parse HEAD)
git fetch -q origin "$head"
if ! git merge -q --no-ff --no-edit "$head" >/dev/null 2>&1; then
git merge --abort || true
printf '%s %s %s\n' "$number" "$head" "it conflicts with main ($main) and the pull requests the train takes before it" >>"$RUNNER_TEMP/refused"
continue
fi
# The pull request's own code runs without the token.
if (unset GH_TOKEN; fast_gates && { [[ $1 == batch ]] || bash -euo pipefail -c "$(declare -f acceptances); acceptances"; }) >"$RUNNER_TEMP/gates-$number.log" 2>&1; then
boarded+=("$entry")
echo "#$number $head: passes on main and the train before it ($1)"
else
tail -n 40 "$RUNNER_TEMP/gates-$number.log"
printf '%s %s %s\n' "$number" "$head" "the fast gates or the browser acceptances refuse it merged with main ($main) and the pull requests the train takes before it; see run $GITHUB_RUN_ID" >>"$RUNNER_TEMP/refused"
git reset -q --hard "$before"
fi
done
}
queue=("${ready[@]}")
board batch
if [[ ${#boarded[@]} -gt 0 ]] && ! (unset GH_TOKEN; bash -euo pipefail -c "$(declare -f acceptances); acceptances") >"$RUNNER_TEMP/gates-train.log" 2>&1; then
tail -n 40 "$RUNNER_TEMP/gates-train.log"
echo "the browser acceptances refuse ${boarded[*]} together: taking them one by one"
git reset -q --hard "$main"
queue=("${boarded[@]}")
board each
fi
accepted=("${boarded[@]}")
echo "accepted=${accepted[*]:-}" >>"$GITHUB_OUTPUT"
# The refusals travel to the merge job as an output: a run cannot download its
# own artifacts while it is still running.
Expand Down
2 changes: 1 addition & 1 deletion app/specs/pipeline/workflows/merge-train.yml.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"GH_TOKEN": "${{ github.token }}",
"REPO": "${{ github.repository }}"
},
"run": "set -euo pipefail\ngit config user.name \"merge train\"\ngit config user.email \"merge-train@train.invalid\"\nmain=$(git rev-parse HEAD)\necho \"main=$main\" >>\"$GITHUB_OUTPUT\"\nimage=$(sed -n 's/.*\"sdk_image\":\"\\([^\"]*\\)\".*/\\1/p' prismpm.lock)\n[[ $image =~ ^[a-z0-9.-]+(:[0-9]{1,5})?/[a-z0-9./_-]+@sha256:[0-9a-f]{64}$ ]]\nscratch=$(mktemp -d)\nexport scratch image\ntrap 'rm -rf \"$scratch\"' EXIT\nfast_gates() {\n node bootstrap/brand-sync.mjs --check &&\n python3 -I bootstrap/brand-fonts.py --check &&\n node bootstrap/frame-sync.mjs --check &&\n python3 -I tools/realize/gate.py --check &&\n python3 -I tools/standards/gate.py --check --base \"$main\" &&\n { [[ ! -f tools/parts/gate.py ]] || python3 -I tools/parts/gate.py; } &&\n { [[ ! -f tools/product/gate.py ]] || python3 -I tools/product/gate.py; } &&\n python3 -I tools/guests/gen.py check &&\n sh tools/generators/run.sh --check &&\n python3 -I tools/handwritten/gate.py --check --base \"$main\" &&\n docker run --rm \\\n --user \"$(id -u):$(id -g)\" \\\n --volume \"$scratch:/tmp\" \\\n --volume \"$PWD:$PWD\" \\\n --workdir \"$PWD\" \\\n --env HOME=/tmp/prismpm-home \\\n --env PRISMPM_EPHEMERAL_HOME=1 \\\n --env SDK_IMAGE=\"$image\" \\\n \"$image\" bash -c 'set -euo pipefail; mkdir -p \"$HOME\"; just fmt-check model template-check lint test'\n}\n# The browser acceptances on the merged tree, as the page job runs them on a\n# pull request alone (CO-01 and the timing budgets failed on main after #145 and\n# #161 were each green): a holo built from this tree, without the proof that\n# main's own run binds, the page assembled around it, then every runner and\n# every suite once. In a worktree of its own (the gates' own tests need git), so the train's tree stays what it merges, and in a\n# shell of its own, because bash ignores errexit inside an if.\nacceptances() {\n local copy=$RUNNER_TEMP/accept\n git worktree remove --force \"$copy\" 2>/dev/null || rm -rf \"$copy\"\n git worktree add -q --detach \"$copy\" HEAD\n mkdir -p \"$scratch/prismpm-home/.docker\"\n printf '{}\\n' >\"$scratch/prismpm-home/.docker/config.json\"\n (\n cd \"$copy\"\n shopt -s nullglob globstar\n docker run --rm \\\n --user \"$(id -u):$(id -g)\" \\\n --group-add \"$(stat -c '%g' /var/run/docker.sock)\" \\\n --volume \"$scratch:/tmp\" \\\n --volume \"$PWD:$PWD\" \\\n --volume /var/run/docker.sock:/var/run/docker.sock \\\n --workdir \"$PWD\" \\\n --env DOCKER_CONFIG=/tmp/prismpm-home/.docker \\\n --env BUILDX_CONFIG=/tmp/prismpm-buildx \\\n --env HOME=/tmp/prismpm-home \\\n --env PRISMPM_EPHEMERAL_HOME=1 \\\n --env SDK_IMAGE=\"$image\" \\\n \"$image\" bash -c 'set -euo pipefail; prismpm --project app build --no-provenance'\n holos=(app/.prism/build/*/*.holo)\n [[ ${#holos[@]} -eq 1 ]]\n fingerprint=$(node -e 'process.stdout.write(JSON.parse(require(\"fs\").readFileSync(process.argv[1], \"utf8\")).archive_fingerprint)' \"$(dirname \"${holos[0]}\")/application/holo-identities.json\")\n \"$RUNNER_TEMP/draw/bin/python\" -I bootstrap/og.py\n \"$RUNNER_TEMP/draw/bin/python\" -I bootstrap/icons.py\n cp \"${holos[0]}\" site/app.holo\n cp -r try/vendor site/vendor\n rm -rf site/vendor/prism-code/fixtures site/vault/test\n node -e '\n const { readFileSync, writeFileSync } = require(\"node:fs\");\n const [id, url] = process.argv.slice(1);\n const app = JSON.parse(readFileSync(\"site/app.json\", \"utf8\"));\n app.attestations ??= {};\n app.attestations.build = { id, url };\n writeFileSync(\"site/app.json\", `${JSON.stringify(app, null, 2)}\\n`);\n ' \"$fingerprint\" \"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID\"\n node bootstrap/page.mjs site\n for objects in bootstrap/*-objects.mjs; do node \"$objects\" site; done\n node bootstrap/precache.mjs site\n export NODE_PATH=\"$(npm root --global)\"\n runners=(test/*/run.mjs)\n suites=(test/**/*.test.mjs)\n for runner in \"${runners[@]}\"; do node \"$runner\"; done\n node --test \"${suites[@]}\"\n )\n}\nready=()\n: >\"$RUNNER_TEMP/refused\"\nwhile read -r number head draft fork; do\n [[ $draft == false && $fork == false ]] || continue\n ok=true\n for name in \"page / gates\" \"acceptance / ubuntu-24.04\"; do\n state=$(gh api \"repos/$REPO/commits/$head/check-runs\" -f check_name=\"$name\" -X GET --jq '[.check_runs[] | .conclusion][0] // \"pending\"')\n [[ $state == success ]] || ok=false\n # A check that ended without passing is said once, so a pull request is never left waiting in silence.\n case $state in success | pending) ;; *) printf '%s %s %s\\n' \"$number\" \"$head\" \"its check \\\"$name\\\" ended $state on this head, so it is not green; push to this branch to run it again\" >>\"$RUNNER_TEMP/refused\" ;; esac\n done\n if $ok; then ready+=(\"$number:$head\"); fi\ndone < <(gh api \"repos/$REPO/pulls?state=open&base=main&sort=created&direction=asc&per_page=50\" \\\n --jq '.[] | \"\\(.number) \\(.head.sha) \\(.draft) \\(.head.repo.full_name != .base.repo.full_name)\"')\necho \"ready: ${ready[*]:-none}\"\n# What the acceptances need on the runner, installed once and before any pull request's code runs.\nif [[ ${#ready[@]} -gt 0 ]]; then\n npm install --no-audit --no-fund --global playwright@1.56.1\n playwright install --with-deps chromium\n python3 -m venv \"$RUNNER_TEMP/draw\"\n \"$RUNNER_TEMP/draw/bin/pip\" install --quiet --no-deps --only-binary :all: --require-hashes -r bootstrap/draw-requirements.txt\nfi\naccepted=()\nfor entry in \"${ready[@]}\"; do\n number=${entry%%:*}\n head=${entry#*:}\n before=$(git rev-parse HEAD)\n git fetch -q origin \"$head\"\n if ! git merge -q --no-ff --no-edit \"$head\" >/dev/null 2>&1; then\n git merge --abort || true\n printf '%s %s %s\\n' \"$number\" \"$head\" \"it conflicts with main ($main) and the pull requests the train takes before it\" >>\"$RUNNER_TEMP/refused\"\n continue\n fi\n # The pull request's own code runs without the token.\n if (unset GH_TOKEN; fast_gates && bash -euo pipefail -c \"$(declare -f acceptances); acceptances\") >\"$RUNNER_TEMP/gates-$number.log\" 2>&1; then\n accepted+=(\"$number:$head\")\n echo \"#$number $head: the fast gates and the browser acceptances pass on main and the train before it\"\n else\n tail -n 40 \"$RUNNER_TEMP/gates-$number.log\"\n printf '%s %s %s\\n' \"$number\" \"$head\" \"the fast gates or the browser acceptances refuse it merged with main ($main) and the pull requests the train takes before it; see run $GITHUB_RUN_ID\" >>\"$RUNNER_TEMP/refused\"\n git reset -q --hard \"$before\"\n fi\ndone\necho \"accepted=${accepted[*]:-}\" >>\"$GITHUB_OUTPUT\"\n# The refusals travel to the merge job as an output: a run cannot download its\n# own artifacts while it is still running.\ncat \"$RUNNER_TEMP/refused\"\necho \"refused=$(base64 -w0 <\"$RUNNER_TEMP/refused\")\" >>\"$GITHUB_OUTPUT\"\n",
"run": "set -euo pipefail\ngit config user.name \"merge train\"\ngit config user.email \"merge-train@train.invalid\"\nmain=$(git rev-parse HEAD)\necho \"main=$main\" >>\"$GITHUB_OUTPUT\"\nimage=$(sed -n 's/.*\"sdk_image\":\"\\([^\"]*\\)\".*/\\1/p' prismpm.lock)\n[[ $image =~ ^[a-z0-9.-]+(:[0-9]{1,5})?/[a-z0-9./_-]+@sha256:[0-9a-f]{64}$ ]]\nscratch=$(mktemp -d)\nexport scratch image\ntrap 'rm -rf \"$scratch\"' EXIT\nfast_gates() {\n node bootstrap/brand-sync.mjs --check &&\n python3 -I bootstrap/brand-fonts.py --check &&\n node bootstrap/frame-sync.mjs --check &&\n python3 -I tools/realize/gate.py --check &&\n python3 -I tools/standards/gate.py --check --base \"$main\" &&\n { [[ ! -f tools/parts/gate.py ]] || python3 -I tools/parts/gate.py; } &&\n { [[ ! -f tools/product/gate.py ]] || python3 -I tools/product/gate.py; } &&\n python3 -I tools/guests/gen.py check &&\n sh tools/generators/run.sh --check &&\n python3 -I tools/handwritten/gate.py --check --base \"$main\" &&\n docker run --rm \\\n --user \"$(id -u):$(id -g)\" \\\n --volume \"$scratch:/tmp\" \\\n --volume \"$PWD:$PWD\" \\\n --workdir \"$PWD\" \\\n --env HOME=/tmp/prismpm-home \\\n --env PRISMPM_EPHEMERAL_HOME=1 \\\n --env SDK_IMAGE=\"$image\" \\\n \"$image\" bash -c 'set -euo pipefail; mkdir -p \"$HOME\"; just fmt-check model template-check lint test'\n}\n# The browser acceptances on the merged tree, as the page job runs them on a\n# pull request alone (CO-01 and the timing budgets failed on main after #145 and\n# #161 were each green): a holo built from this tree, without the proof that\n# main's own run binds, the page assembled around it, then every runner and\n# every suite once. In a worktree of its own (the gates' own tests need git), so the train's tree stays what it merges, and in a\n# shell of its own, because bash ignores errexit inside an if.\nacceptances() {\n local copy=$RUNNER_TEMP/accept\n git worktree remove --force \"$copy\" 2>/dev/null || rm -rf \"$copy\"\n git worktree add -q --detach \"$copy\" HEAD\n mkdir -p \"$scratch/prismpm-home/.docker\"\n printf '{}\\n' >\"$scratch/prismpm-home/.docker/config.json\"\n (\n cd \"$copy\"\n shopt -s nullglob globstar\n docker run --rm \\\n --user \"$(id -u):$(id -g)\" \\\n --group-add \"$(stat -c '%g' /var/run/docker.sock)\" \\\n --volume \"$scratch:/tmp\" \\\n --volume \"$PWD:$PWD\" \\\n --volume /var/run/docker.sock:/var/run/docker.sock \\\n --workdir \"$PWD\" \\\n --env DOCKER_CONFIG=/tmp/prismpm-home/.docker \\\n --env BUILDX_CONFIG=/tmp/prismpm-buildx \\\n --env HOME=/tmp/prismpm-home \\\n --env PRISMPM_EPHEMERAL_HOME=1 \\\n --env SDK_IMAGE=\"$image\" \\\n \"$image\" bash -c 'set -euo pipefail; prismpm --project app build --no-provenance'\n holos=(app/.prism/build/*/*.holo)\n [[ ${#holos[@]} -eq 1 ]]\n fingerprint=$(node -e 'process.stdout.write(JSON.parse(require(\"fs\").readFileSync(process.argv[1], \"utf8\")).archive_fingerprint)' \"$(dirname \"${holos[0]}\")/application/holo-identities.json\")\n \"$RUNNER_TEMP/draw/bin/python\" -I bootstrap/og.py\n \"$RUNNER_TEMP/draw/bin/python\" -I bootstrap/icons.py\n cp \"${holos[0]}\" site/app.holo\n cp -r try/vendor site/vendor\n rm -rf site/vendor/prism-code/fixtures site/vault/test\n node -e '\n const { readFileSync, writeFileSync } = require(\"node:fs\");\n const [id, url] = process.argv.slice(1);\n const app = JSON.parse(readFileSync(\"site/app.json\", \"utf8\"));\n app.attestations ??= {};\n app.attestations.build = { id, url };\n writeFileSync(\"site/app.json\", `${JSON.stringify(app, null, 2)}\\n`);\n ' \"$fingerprint\" \"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID\"\n node bootstrap/page.mjs site\n for objects in bootstrap/*-objects.mjs; do node \"$objects\" site; done\n node bootstrap/precache.mjs site\n export NODE_PATH=\"$(npm root --global)\"\n runners=(test/*/run.mjs)\n suites=(test/**/*.test.mjs)\n for runner in \"${runners[@]}\"; do node \"$runner\"; done\n node --test \"${suites[@]}\"\n )\n}\nready=()\n: >\"$RUNNER_TEMP/refused\"\nwhile read -r number head draft fork; do\n [[ $draft == false && $fork == false ]] || continue\n ok=true\n for name in \"page / gates\" \"acceptance / ubuntu-24.04\"; do\n state=$(gh api \"repos/$REPO/commits/$head/check-runs\" -f check_name=\"$name\" -X GET --jq '[.check_runs[] | .conclusion][0] // \"pending\"')\n [[ $state == success ]] || ok=false\n # A check that ended without passing is said once, so a pull request is never left waiting in silence.\n case $state in success | pending) ;; *) printf '%s %s %s\\n' \"$number\" \"$head\" \"its check \\\"$name\\\" ended $state on this head, so it is not green; push to this branch to run it again\" >>\"$RUNNER_TEMP/refused\" ;; esac\n done\n if $ok; then ready+=(\"$number:$head\"); fi\ndone < <(gh api \"repos/$REPO/pulls?state=open&base=main&sort=created&direction=asc&per_page=50\" \\\n --jq '.[] | \"\\(.number) \\(.head.sha) \\(.draft) \\(.head.repo.full_name != .base.repo.full_name)\"')\necho \"ready: ${ready[*]:-none}\"\n# What the acceptances need on the runner, installed once and before any pull request's code runs.\nif [[ ${#ready[@]} -gt 0 ]]; then\n npm install --no-audit --no-fund --global playwright@1.56.1\n playwright install --with-deps chromium\n python3 -m venv \"$RUNNER_TEMP/draw\"\n \"$RUNNER_TEMP/draw/bin/pip\" install --quiet --no-deps --only-binary :all: --require-hashes -r bootstrap/draw-requirements.txt\nfi\n# The browser acceptances take about a quarter of an hour, so the train runs\n# them once, on all the pull requests that board together, and one by one only\n# when that tree fails, to find which of them it refuses.\nboard() { # board batch|each: merge each of the queue that passes the fast gates (each: and the browser acceptances) onto HEAD\n local entry number head before\n boarded=()\n for entry in \"${queue[@]}\"; do\n number=${entry%%:*}\n head=${entry#*:}\n before=$(git rev-parse HEAD)\n git fetch -q origin \"$head\"\n if ! git merge -q --no-ff --no-edit \"$head\" >/dev/null 2>&1; then\n git merge --abort || true\n printf '%s %s %s\\n' \"$number\" \"$head\" \"it conflicts with main ($main) and the pull requests the train takes before it\" >>\"$RUNNER_TEMP/refused\"\n continue\n fi\n # The pull request's own code runs without the token.\n if (unset GH_TOKEN; fast_gates && { [[ $1 == batch ]] || bash -euo pipefail -c \"$(declare -f acceptances); acceptances\"; }) >\"$RUNNER_TEMP/gates-$number.log\" 2>&1; then\n boarded+=(\"$entry\")\n echo \"#$number $head: passes on main and the train before it ($1)\"\n else\n tail -n 40 \"$RUNNER_TEMP/gates-$number.log\"\n printf '%s %s %s\\n' \"$number\" \"$head\" \"the fast gates or the browser acceptances refuse it merged with main ($main) and the pull requests the train takes before it; see run $GITHUB_RUN_ID\" >>\"$RUNNER_TEMP/refused\"\n git reset -q --hard \"$before\"\n fi\n done\n}\nqueue=(\"${ready[@]}\")\nboard batch\nif [[ ${#boarded[@]} -gt 0 ]] && ! (unset GH_TOKEN; bash -euo pipefail -c \"$(declare -f acceptances); acceptances\") >\"$RUNNER_TEMP/gates-train.log\" 2>&1; then\n tail -n 40 \"$RUNNER_TEMP/gates-train.log\"\n echo \"the browser acceptances refuse ${boarded[*]} together: taking them one by one\"\n git reset -q --hard \"$main\"\n queue=(\"${boarded[@]}\")\n board each\nfi\naccepted=(\"${boarded[@]}\")\necho \"accepted=${accepted[*]:-}\" >>\"$GITHUB_OUTPUT\"\n# The refusals travel to the merge job as an output: a run cannot download its\n# own artifacts while it is still running.\ncat \"$RUNNER_TEMP/refused\"\necho \"refused=$(base64 -w0 <\"$RUNNER_TEMP/refused\")\" >>\"$GITHUB_OUTPUT\"\n",
"#": {
"": [
"Ready: open, from this repository, not a draft, and both required",
Expand Down
2 changes: 1 addition & 1 deletion app/specs/product/quality/QR-03.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"measures": [
{
"key": "labeling-ms-per-100",
"says": "milliseconds to read, take apart, learn from and label 100 items, from a cold start over ten copies of the specifications' mail and calendar examples, the slowest of three cold starts",
"says": "milliseconds to read, take apart, learn from and label 100 items, from a cold start over ten copies of the specifications' mail and calendar examples, the middle of three cold starts",
"direction": "atMost",
"threshold": 250,
"gate": "test/router/labels.test.mjs"
Expand Down
Loading
Loading