|
21 | 21 | # scripts/ci-local.sh --quick # FAST inner-loop tier: the cheap TS-centric |
22 | 22 | # # gates only (leak-scan, pom parity, fixture- |
23 | 23 | # # lint, ts build+typecheck, ts conformance, |
24 | | -# # completeness, drift). Skips the other- |
| 24 | +# # completeness on the CHANGED files only, drift). |
| 25 | +# # Skips the other- |
25 | 26 | # # language ports, the reactor, and docker. |
26 | 27 | # scripts/ci-local.sh --only <section> [--only <section> ...] |
27 | 28 | # # Run one or more named sections. Mutually |
|
31 | 32 | # # leak-scan → the public-repo leak scan ALONE |
32 | 33 | # # (hygiene.yml's PR gate; also in gates) |
33 | 34 | # # ts → ts build+typecheck, ts conformance, |
34 | | -# # completeness-gate, full unit suites |
| 35 | +# # completeness-gate (changed files), |
| 36 | +# # full unit suites |
35 | 37 | # # (ts-unit), integration-tests ts |
36 | 38 | # # ts-fast → build+typecheck, conformance, |
37 | | -# # completeness (the pure-code signal) |
| 39 | +# # completeness (the pure-code signal). |
| 40 | +# # Its mutation step mutates only the |
| 41 | +# # stryker.conf.mjs `mutate` files this |
| 42 | +# # change touches vs the base branch, and |
| 43 | +# # prints a SKIP when it touches none |
| 44 | +# # (MO_CI_MUTATION_SCOPE=full forces all; |
| 45 | +# # MO_CI_MUTATION_BASE sets the base ref) |
| 46 | +# # mutation → the FULL mutation pass over every |
| 47 | +# # `mutate` file (~10-45 min). For release |
| 48 | +# # prep and on demand; the flagless run |
| 49 | +# # and conformance.yml also run it. It |
| 50 | +# # replaces ts-fast's diff-scoped step |
| 51 | +# # when both are selected |
38 | 52 | # # ts-unit → full per-package unit suites for |
39 | 53 | # # metadata/render/runtime-ts + the |
40 | 54 | # # client/web packages — runs in |
@@ -136,8 +150,8 @@ while [ $# -gt 0 ]; do |
136 | 150 | --no-integration) NO_INTEG=1 ;; |
137 | 151 | --integration-only) INTEG_ONLY=1 ;; |
138 | 152 | --only) shift; case "${1:-}" in |
139 | | - gates|leak-scan|ts|ts-fast|ts-unit|ts-slow|java|java-fast|java-slow|python|csharp|cube) ONLY="$ONLY ${1}" ;; |
140 | | - *) echo "--only expects gates|leak-scan|ts|ts-fast|ts-unit|ts-slow|java|java-fast|java-slow|python|csharp|cube, got '${1:-}'" >&2; exit 2 ;; |
| 153 | + gates|leak-scan|ts|ts-fast|ts-unit|ts-slow|mutation|java|java-fast|java-slow|python|csharp|cube) ONLY="$ONLY ${1}" ;; |
| 154 | + *) echo "--only expects gates|leak-scan|ts|ts-fast|ts-unit|ts-slow|mutation|java|java-fast|java-slow|python|csharp|cube, got '${1:-}'" >&2; exit 2 ;; |
141 | 155 | esac ;; |
142 | 156 | -h|--help) awk 'NR==1{next} /^set -uo/{exit} {sub(/^# ?/,""); print}' "$0"; exit 0 ;; |
143 | 157 | *) echo "unknown arg: $1 (see --help)" >&2; exit 2 ;; |
@@ -635,8 +649,9 @@ gate_conf_ts() { |
635 | 649 | # conformance gate runs only NAMED conformance files in metadata/render, so the rest |
636 | 650 | # of those suites (and runtime-ts + the client/web packages) ran nowhere — which is |
637 | 651 | # how a @formExclude regression sat red on `main`. Deliberately its OWN lane rather |
638 | | -# than folded into ts-fast: ts-fast carries the 30-min mutation gate, which flakes |
639 | | -# under runner contention, and a mutation flake must not mask a unit-test failure. |
| 652 | +# than folded into ts-fast: ts-fast carries the mutation gate (diff-scoped since |
| 653 | +# 2026-11; the full pass took up to ~45 min and flaked under runner contention), and a |
| 654 | +# mutation flake must not mask a unit-test failure. |
640 | 655 | # Measured ~5s total, so the independent signal is nearly free. |
641 | 656 | # NOTE: per-package `bun test` only — a bare root `bun test` walks java/python/ |
642 | 657 | # csharp/fixtures and takes many minutes. |
@@ -783,7 +798,87 @@ gate_java_reactor() { |
783 | 798 | # themselves (two concurrent `mvn install`s clobber the shared module jars). When the reactor |
784 | 799 | # step is not selected — `--integration-only` — this installs it without its tests. |
785 | 800 | gate_java_install() { ( cd server/java && mvn -q -DskipTests -Djacoco.skip=true install ); } |
786 | | -gate_completeness() { ( cd server/typescript/packages/metadata && bun run conformance:mutation ); } |
| 801 | +# ── The mutation (completeness) gate: two scopes over ONE file list ─────────── |
| 802 | +# Stryker mutates the files listed in `mutate` in server/typescript/packages/metadata/ |
| 803 | +# stryker.conf.mjs — the ONLY copy of that list; both scopes read it from there. |
| 804 | +# |
| 805 | +# FULL (gate_completeness): every listed file. ~10–45 min of CPU on a contended host. |
| 806 | +# Runs in the flagless full run's `mutation` lane, in `--only mutation` (release prep |
| 807 | +# and on demand), and wherever MO_CI_MUTATION_SCOPE=full is set — conformance.yml does, |
| 808 | +# so its tag (`v*`, the release gate), nightly and dispatch runs mutate everything. |
| 809 | +# DIFF (gate_completeness_diff): only the listed files this change touches. This is |
| 810 | +# the step in ts-fast / --quick / --only ts, and so in the no-mistakes gate's Test |
| 811 | +# step (.no-mistakes.yaml). It used to run the full pass on every gate round, which |
| 812 | +# was most of that step's wall time and most of the machine's load. |
| 813 | +# |
| 814 | +# "Touches" = differs between the merge base with the base branch and the working tree. |
| 815 | +# The base is MO_CI_MUTATION_BASE when set, else origin/$GITHUB_BASE_REF on a GitHub PR, |
| 816 | +# else whichever of origin/main and origin/release/* HEAD is fewest commits ahead of (a |
| 817 | +# branch cut from release/1.2 diffs against release/1.2, not main). When no base resolves |
| 818 | +# (a shallow checkout, no remote refs) the step says so and runs the FULL pass — it never |
| 819 | +# guesses a smaller scope. A change to stryker.conf.mjs itself also runs the full pass. |
| 820 | +# When none of the listed files changed it prints a SKIP banner naming the base and the |
| 821 | +# reason, and passes: there is nothing new to mutate, and the full lane still covers the |
| 822 | +# whole list. Thresholds and concurrency come from stryker.conf.mjs unchanged. |
| 823 | +# |
| 824 | +# Why --mutate on the diff rather than Stryker's incremental mode: incremental keeps a |
| 825 | +# results file between runs, and a cache shared across branches and worktrees can report |
| 826 | +# a mutant killed by tests another branch has. The diff scope keeps no state at all. |
| 827 | +# |
| 828 | +# Sandboxes: when DEV_SCRATCH names a directory (a RAM scratch area), Stryker's sandbox |
| 829 | +# goes there instead of the package's .stryker-tmp/, and is removed when the step ends. |
| 830 | +MUTATION_PKG="server/typescript/packages/metadata" |
| 831 | +stryker_run() { # stryker_run [stryker args...] — in the metadata package, sandbox in DEV_SCRATCH when set |
| 832 | + local tmp="" rc |
| 833 | + if [ -n "${DEV_SCRATCH:-}" ] && [ -d "${DEV_SCRATCH}" ]; then |
| 834 | + tmp="${DEV_SCRATCH%/}/stryker/metaobjects-$(printf '%s' "$ROOT" | cksum | cut -d' ' -f1)-$$" |
| 835 | + mkdir -p "$tmp" || return 1 |
| 836 | + fi |
| 837 | + ( cd "$MUTATION_PKG" && bun run conformance:mutation ${tmp:+--tempDirName "$tmp"} "$@" ); rc=$? |
| 838 | + [ -n "$tmp" ] && rm -rf "$tmp" |
| 839 | + return "$rc" |
| 840 | +} |
| 841 | +gate_completeness() { bun_install || return 1; stryker_run; } |
| 842 | +mutation_base() { # prints the base ref the diff scope compares against; empty when none resolves |
| 843 | + local ref best="" best_n="" mb n |
| 844 | + if [ -n "${MO_CI_MUTATION_BASE:-}" ]; then echo "$MO_CI_MUTATION_BASE"; return 0; fi |
| 845 | + if [ -n "${GITHUB_BASE_REF:-}" ]; then echo "origin/$GITHUB_BASE_REF"; return 0; fi |
| 846 | + for ref in origin/main $(git for-each-ref --format='%(refname:short)' 'refs/remotes/origin/release/*'); do |
| 847 | + git rev-parse --verify -q "$ref^{commit}" >/dev/null 2>&1 || continue |
| 848 | + mb="$(git merge-base HEAD "$ref" 2>/dev/null)" || continue |
| 849 | + n="$(git rev-list --count "$mb..HEAD")" |
| 850 | + if [ -z "$best_n" ] || [ "$n" -lt "$best_n" ]; then best="$ref"; best_n="$n"; fi |
| 851 | + done |
| 852 | + echo "$best" |
| 853 | +} |
| 854 | +gate_completeness_diff() { |
| 855 | + if [ "${MO_CI_MUTATION_SCOPE:-diff}" = "full" ]; then |
| 856 | + echo " mutation scope: FULL (MO_CI_MUTATION_SCOPE=full)"; gate_completeness; return |
| 857 | + fi |
| 858 | + local base mb files changed |
| 859 | + base="$(mutation_base)" |
| 860 | + if [ -z "$base" ] || ! mb="$(git merge-base HEAD "$base" 2>/dev/null)"; then |
| 861 | + echo " mutation scope: FULL — no merge base with '${base:-origin/main or origin/release/*}' resolves here (shallow checkout or no remote refs), so the changed files cannot be computed" |
| 862 | + gate_completeness; return |
| 863 | + fi |
| 864 | + files="$(cd "$MUTATION_PKG" && bun -e 'const c = (await import("./stryker.conf.mjs")).default; console.log(c.mutate.join("\n"))')" || { |
| 865 | + echo " ✖ could not read the mutate list from $MUTATION_PKG/stryker.conf.mjs" >&2; return 1; } |
| 866 | + if ! git diff --quiet "$mb" -- "$MUTATION_PKG/stryker.conf.mjs"; then |
| 867 | + echo " mutation scope: FULL — stryker.conf.mjs changed since $base (merge base ${mb:0:12})" |
| 868 | + gate_completeness; return |
| 869 | + fi |
| 870 | + # shellcheck disable=SC2086 # the mutate entries are plain paths, one per line |
| 871 | + changed="$(cd "$MUTATION_PKG" && git diff --name-only --relative "$mb" -- $files)" |
| 872 | + if [ -z "$changed" ]; then |
| 873 | + echo "" |
| 874 | + echo " ⊘ SKIP mutation: none of the $(echo "$files" | wc -l | tr -d ' ') files in stryker.conf.mjs 'mutate' changed since $base (merge base ${mb:0:12})." |
| 875 | + echo " The full pass runs in the flagless run's mutation lane, in --only mutation, and in conformance.yml." |
| 876 | + return 0 |
| 877 | + fi |
| 878 | + echo " mutation scope: changed files only, vs $base (merge base ${mb:0:12}):" |
| 879 | + echo "$changed" | sed 's/^/ /' |
| 880 | + stryker_run --mutate "$(echo "$changed" | paste -sd, -)" |
| 881 | +} |
787 | 882 | gate_doc_template_drift() { |
788 | 883 | bash scripts/sync-doc-templates.sh \ |
789 | 884 | && git diff --exit-code -- \ |
@@ -1185,7 +1280,8 @@ lane_ts() { |
1185 | 1280 | if want ts; then step_if bun "conformance: typescript" gate_conf_ts; fi |
1186 | 1281 | if want ts; then step_if bun "ts unit suites" gate_ts_unit; fi |
1187 | 1282 | } |
1188 | | -lane_mutation() { if want ts; then step_if bun "completeness-gate (mutation)" gate_completeness; fi; } |
| 1283 | +# The full run's mutation lane is the FULL pass over every file stryker.conf.mjs lists. |
| 1284 | +lane_mutation() { if want ts; then step_if bun "completeness-gate (mutation, full)" gate_completeness; fi; } |
1189 | 1285 | # ts-slow's half: the two real-PG suites plus the TS integration suite. |
1190 | 1286 | lane_ts_integ() { |
1191 | 1287 | integ_ready || return 0 |
@@ -1284,13 +1380,19 @@ if [ "$PARALLEL" -eq 0 ]; then |
1284 | 1380 | run_gates_bun |
1285 | 1381 | # The ts port is split into two lanes so CI can run them as separate jobs (see |
1286 | 1382 | # .github/workflows/local-ci.yml): a FAST lane (build+typecheck, conformance, |
1287 | | - # completeness — the pure-code correctness signal, no docker) and a SLOW lane |
| 1383 | + # completeness on the changed files — the pure-code correctness signal, no docker) and a SLOW lane |
1288 | 1384 | # (docker/sidecar integration). Isolating integration means a docker/sidecar |
1289 | 1385 | # hiccup no longer fails the code signal, and vice versa. `--only ts` still runs both. |
1290 | 1386 | if want_any ts ts-fast; then step_if bun "ts build + typecheck" gate_ts_build_typecheck; fi |
1291 | 1387 | if want_any ts ts-fast; then step_if bun "conformance: typescript" gate_conf_ts; fi |
1292 | 1388 | if want_any ts ts-unit; then step_if bun "ts unit suites" gate_ts_unit; fi |
1293 | | - if want_any ts ts-fast; then step_if bun "completeness-gate (mutation)" gate_completeness; fi |
| 1389 | + # The DIFF-scoped mutation step (see gate_completeness_diff); `--only mutation` asks for |
| 1390 | + # the full pass instead, and gets it in place of this step rather than as well. |
| 1391 | + if [ -n "$ONLY" ] && want mutation; then |
| 1392 | + step_if bun "completeness-gate (mutation, full)" gate_completeness |
| 1393 | + elif want_any ts ts-fast; then |
| 1394 | + step_if bun "completeness-gate (mutation, changed files)" gate_completeness_diff |
| 1395 | + fi |
1294 | 1396 | run_drift_gates |
1295 | 1397 |
|
1296 | 1398 | if [ "$QUICK" -eq 1 ]; then |
|
0 commit comments