open-standards/scripts/standards-touched-selftest.sh
Transaction Science 9edc1ad2aa
Some checks failed
standards workspaces build + test / which workspaces this change touches (pull_request) Successful in 4s
standards workspaces build + test / jouledesk-rs (jouledesk/jouledesk-rs, jouledesk-rs, macos) (pull_request) Successful in 1m3s
standards workspaces build + test / joule-code-rs (joule-code/joule-code-rs, joule-code-rs, linux-arm64, true) (pull_request) Successful in 1m15s
standards workspaces build + test / joulecontract-rs (joulecontract/joulecontract-rs, joulecontract-rs, linux-arm64, true) (pull_request) Successful in 47s
standards workspaces build + test / map-rs (map-conformance, map/map-rs, map-rs, linux-arm64) (pull_request) Successful in 36s
standards workspaces build + test / mesh-rs (mesh/mesh-rs, -p mesh-engine-gguf -p mesh-openai --features mesh-engine-gguf/gguf,mesh-openai/server, mesh-rs, linux-arm64) (pull_request) Successful in 37s
standards workspaces build + test / aac-rs (aac-conformance, aac/aac-rs, aac-rs, linux-arm64) (pull_request) Successful in 5m26s
standards workspaces build + test / jouleclaw-rs (-nodebug, jouleclaw/jouleclaw-rs, -p jouleclaw-energy --features rapl,nvml, jouleclaw-rs, linux-arm64, -C target-feature=+fp16) (pull_request) Successful in 5m51s
standards workspaces build + test / openpay (openpay, openpay, linux-arm64) (pull_request) Successful in 2m13s
standards workspaces build + test / macOS energy backends (pull_request) Failing after 22m22s
lockfiles / every Cargo.lock is current (pull_request) Has been cancelled
spec citations resolve / Code cites no section its SPEC lacks (pull_request) Has been cancelled
standards workspaces build + test / arl-rs (arl/arl-rs, arl-rs, linux) (pull_request) Has been cancelled
standards workspaces build + test / eoc-rs (eoc/eoc-rs, -p eoc-meter --features cuda, eoc-rs, linux) (pull_request) Has been cancelled
standards workspaces build + test / jcp-rs (jcp-conformance, jcp/jcp-rs, -p jcp-energy --features nvml, jcp-rs, linux) (pull_request) Has been cancelled
standards workspaces build + test / joule-ui-rs (joule-ui/joule-ui-rs, joule-ui-rs, linux) (pull_request) Has been cancelled
standards workspaces build + test / joulehook-rs (joulehook/joulehook-rs, joulehook-rs, linux) (pull_request) Has been cancelled
standards workspaces build + test / proof-rs (proof-conformance, proof/proof-rs, proof-rs, linux, true) (pull_request) Has been cancelled
standards workspaces build + test / sandbox-rs (sandbox-conformance, sandbox/sandbox-rs, sandbox-rs, linux) (pull_request) Has been cancelled
standards workspaces build + test / sense-rs (sense/sense-rs, sense-rs, linux) (pull_request) Has been cancelled
standards workspaces build + test / smart-byte-rs (smart-byte/smart-byte-rs, smart-byte-rs, linux) (pull_request) Has been cancelled
tests in CI / every test file is run by a job or listed with its reason (pull_request) Has been cancelled
workflow hygiene / every workflow supersedes its own queue (pull_request) Has been cancelled
ci: the standards build builds the workspaces a change touches
Every pull request built and tested all 17 standards workspaces, whatever it
changed, and the one x86_64 runner's queue filled with builds no change could
affect (90 jobs waiting when measured). A plan job on linux-arm64 now reads the
pull request's own diff and selects the workspaces it touches: a workspace's
own area, the areas of everything it depends on by path, any file outside
them its sources name, and everything every leg shares (this workflow, the
planning script, the toolchain pin, the cargo configuration). The build matrix
is the entries it selects; the macOS energy job runs when an energy-metering
workspace is touched. A push to main builds everything, and so does anything
the plan cannot determine.

Over the last forty merges into main, the WAI-only changes, about half,
would have built none of the 17; the rest built between one and ten. A probe
in ci-test confirmed this forge builds a matrix from a previous job's output
and creates no job for an empty list. A self-test runs in the plan job.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-14 03:40:08 -04:00

55 lines
3.7 KiB
Shell
Executable file

#!/usr/bin/env bash
#
# standards-touched-selftest.sh — the plan builds what a change can affect, and fails
# toward building.
#
# Builds a scratch repository shaped like this one (a workflow with three workspaces,
# one depending on another by path, one reading a file outside its area) and asserts
# what standards-touched.py decides for each kind of change.
set -uo pipefail
here=$(cd "$(dirname "$0")" && pwd)
tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT
cd "$tmp"
git init -q && git config user.email [email protected] && git config user.name t
mkdir -p .github/workflows scripts a/a-rs/src b/b-rs/src c/c-rs/src shared
cp "$here/standards-touched.py" scripts/
cat > .github/workflows/standards-build.yml <<'W'
jobs:
plan:
env:
WORKSPACES: |
- { name: a-rs, dir: a/a-rs, runner: linux }
- { name: b-rs, dir: b/b-rs, runner: linux-arm64, z3: true }
- { name: c-rs, dir: c/c-rs, runner: macos, feature_tests: "-p x --features y,z" }
W
printf '[package]\nname="a"\n[dependencies]\nb = { path = "../../b/b-rs" }\n' > a/a-rs/Cargo.toml
printf '[package]\nname="b"\n' > b/b-rs/Cargo.toml
printf '[package]\nname="c"\n' > c/c-rs/Cargo.toml
printf 'const D: &str = include_str!("../../../shared/data.txt");\n' > c/c-rs/src/lib.rs
: > a/a-rs/src/lib.rs; : > b/b-rs/src/lib.rs; echo one > shared/data.txt; echo x > README.md
git add -A && git commit -qm base && base=$(git rev-parse HEAD)
fails=0
expect() { # expect <what> <expected run list, comma-separated, sorted>
local what=$1 want=$2 got
head=$(git rev-parse HEAD)
got=$(python3 -I scripts/standards-touched.py "$base" "$head" | python3 -c 'import json,sys; print(",".join(sorted(json.load(sys.stdin)["run"])))')
if [ "$got" = "$want" ]; then echo "ok $what: runs [$got]"; else echo "FAIL $what: runs [$got], expected [$want]"; fails=$((fails+1)); fi
git reset -q --hard "$base"
}
echo y >> README.md && git commit -qam readme; expect "a file in no area" ""
echo y >> b/b-rs/src/lib.rs && git commit -qam b; expect "b's area, which a depends on by path" "a-rs,b-rs"
echo y >> a/a-rs/src/lib.rs && git commit -qam a; expect "a's own area" "a-rs"
echo y >> shared/data.txt && git commit -qam shared; expect "a file c's sources include" "c-rs"
echo y >> .github/workflows/standards-build.yml && git commit -qam wf; expect "the workflow itself" "a-rs,b-rs,c-rs"
echo y >> scripts/standards-touched.py && git commit -qam script; expect "the planning script" "a-rs,b-rs,c-rs"
got=$(python3 -I scripts/standards-touched.py "" "" | python3 -c 'import json,sys; print(",".join(sorted(json.load(sys.stdin)["run"])))')
[ "$got" = "a-rs,b-rs,c-rs" ] && echo "ok no pull request (a push): runs everything" || { echo "FAIL a push ran [$got]"; fails=$((fails+1)); }
got=$(python3 -I scripts/standards-touched.py "$base" "0000000000000000000000000000000000000bad" 2>/dev/null | python3 -c 'import json,sys; print(",".join(sorted(json.load(sys.stdin)["run"])))')
[ "$got" = "a-rs,b-rs,c-rs" ] && echo "ok a diff it cannot compute: runs everything" || { echo "FAIL an unknown head ran [$got]"; fails=$((fails+1)); }
out=$(GITHUB_OUTPUT="$tmp/out" python3 -I scripts/standards-touched.py --github-output "" "" >/dev/null; cat "$tmp/out")
printf '%s\n' "$out" | grep -q '"z3":true' && printf '%s\n' "$out" | grep -q '"feature_tests":"-p x --features y,z"' && printf '%s\n' "$out" | grep -q '^energy=false$' \
&& echo "ok the matrix entries keep their booleans and quoted values" || { echo "FAIL the emitted matrix: $out"; fails=$((fails+1)); }
if [ $fails -ne 0 ]; then echo "standards-touched-selftest: $fails failure(s)"; exit 1; fi
echo "standards-touched-selftest: the plan builds what a change can affect, and everything when unsure."