63 lines
3.6 KiB
Bash
Executable File
63 lines
3.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Regression gate (#166, owner 2026-11-27 "make sure not to run into regressions again").
|
|
# Run before every LOCAL/OCTO/VPS install of natives, codec or content:
|
|
# ops/regression_gate.sh [host-build-dir] [content-candidate-dir]
|
|
# 1. builds the host tests and runs the whole CTest suite;
|
|
# 2. fails if any test fails that is not in ops/regression-baseline.txt (known, older failures);
|
|
# tests that left the baseline are reported so the baseline only shrinks;
|
|
# 3. with a content candidate: fails unless its parent build key is the newest
|
|
# published octo content key (a candidate stacked on an older parent drops shipped fixes).
|
|
set -uo pipefail
|
|
src=$(cd -- "$(dirname -- "$0")/.." && pwd)
|
|
# Read-only data audit mode does not build/run the full regression suite.
|
|
if [ "${1:-}" = "--hotfix-audit-only" ]; then
|
|
shift
|
|
exec python3 "$src/ops/hotfix_baked_audit.py" "$@"
|
|
fi
|
|
|
|
build=${1:-/mnt/Games/@project/gateway/runtime/claude-natives-integrate-20261122/host-master}
|
|
candidate=${2:-}
|
|
baseline="$src/ops/regression-baseline.txt"
|
|
rc=0
|
|
# Required profile-2 auth -> realm choice -> transport fixture (real SRW timeout guard).
|
|
ninja -C "$build" login-worker-lock-tests >/dev/null || { echo "GATE FAIL: login worker lock fixture build"; exit 1; }
|
|
ninja -C "$build" >/dev/null || { echo "GATE FAIL: host build"; exit 1; }
|
|
# full run only: a partial ctest run (-R/--rerun-failed) overwrites LastTestsFailed.log
|
|
(cd "$build" && rm -f Testing/Temporary/LastTestsFailed.log && ctest -j8 --timeout 240 --no-tests=error >/dev/null 2>&1)
|
|
ctest_status=$?
|
|
failed="$build/Testing/Temporary/LastTestsFailed.log"
|
|
now=$( [ -f "$failed" ] && cut -d: -f2 "$failed" | sort -u )
|
|
# CTest uses 8 for completed runs with test failures. Baselines may account
|
|
# for those failures, but cannot excuse a process/setup failure or empty run.
|
|
if [ "$ctest_status" -ne 0 ] && { [ "$ctest_status" -ne 8 ] || [ -z "$now" ]; }; then
|
|
echo "GATE FAIL: CTest did not complete a reportable test run (status $ctest_status)"
|
|
rc=1
|
|
fi
|
|
new=$(comm -13 <(grep -v '^#' "$baseline" | sort -u) <(printf '%s\n' "$now" | sed '/^$/d'))
|
|
gone=$(comm -23 <(grep -v '^#' "$baseline" | sort -u) <(printf '%s\n' "$now" | sed '/^$/d'))
|
|
if [ -n "$new" ]; then echo "GATE FAIL: new test failures:"; printf ' %s\n' $new; rc=1; fi
|
|
[ -n "$gone" ] && { echo "now passing (remove from baseline):"; printf ' %s\n' $gone; }
|
|
if [ -n "$candidate" ]; then
|
|
manifest=/mnt/Games/@project/patchserver/repo/octo/manifest.txt
|
|
parent=$(python3 -c "import json,sys;print(json.load(open(sys.argv[1]+'/stage-plan.json'))['parent_build_key'])" "$candidate")
|
|
head=$(python3 "$src/ops/patchserver/latest_content_key.py" "$manifest" 2>/dev/null)
|
|
if [ -z "$head" ]; then echo "GATE FAIL: cannot read published content head"; rc=1
|
|
elif [ "$parent" != "$head" ]; then echo "GATE FAIL: candidate parent ${parent:0:8} != published head ${head:0:8}"; rc=1; fi
|
|
fi
|
|
# Configure explicit current codec/baked inputs; never silently audit an old package.
|
|
if [ -n "${GW_HOTFIX_AUDIT_CONFIG:-}" ]; then
|
|
python3 - "$src" "$GW_HOTFIX_AUDIT_CONFIG" <<'PY_AUDIT' || rc=1
|
|
import json,subprocess,sys
|
|
from pathlib import Path
|
|
config=json.loads(Path(sys.argv[2]).read_text())
|
|
required={'package','closure','baked-dir','registry','defs','reader','output'}
|
|
if set(config)!=required: raise SystemExit('GATE FAIL: incomplete hotfix audit configuration')
|
|
args=[part for key,value in config.items() for part in ('--'+key,value)]
|
|
subprocess.run([sys.executable,sys.argv[1]+'/ops/hotfix_baked_audit.py',*args],check=True)
|
|
PY_AUDIT
|
|
else
|
|
echo "Hotfix/baked audit not configured: set GW_HOTFIX_AUDIT_CONFIG for current codec/content inputs"
|
|
fi
|
|
[ $rc = 0 ] && echo "GATE PASS"
|
|
exit $rc
|