79 lines
3.5 KiB
Bash
79 lines
3.5 KiB
Bash
|
|
#!/usr/bin/env bash
|
||
|
|
# The release sweep: run before `dev` goes into `main`. Exhaustive, unlike the dev gate.
|
||
|
|
#
|
||
|
|
# Runs, in one shared time limit of 5x the suite budget (BUDGET_SECS in run_tests.sh):
|
||
|
|
# 1. every test suite (run_tests.sh --sweep)
|
||
|
|
# 2. a headless smoke run of the app with the sample spread
|
||
|
|
# 3. a soak run: the example board rolled many times, every choice answered at random
|
||
|
|
# 4. real-window runs (desktop and phone view) on a hidden virtual screen, with screenshots
|
||
|
|
# A step fails on its own failure or on a SCRIPT ERROR. Steps that don't fit the time are NOT RUN.
|
||
|
|
# Step 4 is NOT RUN while SteamVR or a Steam game runs (GPU runs then can crash the PC).
|
||
|
|
#
|
||
|
|
# Usage: tools/release_sweep.sh
|
||
|
|
# Exit codes: 0 all passed, 1 a step failed, 2 over the time limit (nothing failed).
|
||
|
|
set -u
|
||
|
|
cd "$(dirname "$0")/.." || exit 1
|
||
|
|
GODOT="${GODOT:-$HOME/apps/Godot_v4.7.2-stable_linux.x86_64}"
|
||
|
|
SWEEP_MULTIPLIER=5
|
||
|
|
budget_secs=$(grep -oP '^readonly BUDGET_SECS=\K[0-9]+' tools/run_tests.sh)
|
||
|
|
limit_secs=$(( budget_secs * SWEEP_MULTIPLIER ))
|
||
|
|
SHOTS="${SWEEP_SHOTS:-/tmp/tabletarot-sweep}"
|
||
|
|
mkdir -p "$SHOTS"
|
||
|
|
start_ms=$(date +%s%3N)
|
||
|
|
left_secs() { echo $(( limit_secs - ($(date +%s%3N) - start_ms) / 1000 )); }
|
||
|
|
|
||
|
|
failed=()
|
||
|
|
not_run=()
|
||
|
|
LOG="$(mktemp)"
|
||
|
|
trap 'rm -f "$LOG"' EXIT
|
||
|
|
|
||
|
|
# run_step NAME COMMAND...: runs at low priority in the time that is left.
|
||
|
|
run_step() {
|
||
|
|
local name="$1"; shift
|
||
|
|
local left; left=$(left_secs)
|
||
|
|
if (( left < 2 )); then not_run+=("$name"); echo "NOT RUN $name (no time left)"; return; fi
|
||
|
|
nice -n 10 timeout -s KILL "$left" "$@" >"$LOG" 2>&1
|
||
|
|
local code=$?
|
||
|
|
if (( code == 137 )); then not_run+=("$name"); echo "NOT RUN $name (stopped at the time limit)"
|
||
|
|
elif (( code != 0 )) || grep -q "SCRIPT ERROR" "$LOG"; then
|
||
|
|
failed+=("$name"); echo "FAIL $name"; grep -E "FAIL|SCRIPT ERROR|ERROR" "$LOG" | head -8
|
||
|
|
else echo "ok $name"; fi
|
||
|
|
}
|
||
|
|
|
||
|
|
# 1. Suites: run_tests.sh prints its own report.
|
||
|
|
left=$(left_secs)
|
||
|
|
timeout -s KILL "$left" tools/run_tests.sh --sweep | grep -vE "^ok "
|
||
|
|
case ${PIPESTATUS[0]} in
|
||
|
|
0) ;;
|
||
|
|
2|137) not_run+=("suites") ;;
|
||
|
|
*) failed+=("suites") ;;
|
||
|
|
esac
|
||
|
|
|
||
|
|
# 2. Smoke run.
|
||
|
|
run_step "smoke" "$GODOT" --headless --audio-driver Dummy --path . --quit-after 120 -- --sample
|
||
|
|
|
||
|
|
# 3. Soak run: exit code 1 means a roll hit an error or the action limit.
|
||
|
|
run_step "soak" "$GODOT" --headless --audio-driver Dummy --path . -s res://tools/simulate_board.gd -- \
|
||
|
|
--board=examples/logic_demo.json --start=start --runs=500 --quiet
|
||
|
|
|
||
|
|
# 4. Real windows on a hidden screen (never on the user's desktop).
|
||
|
|
if pgrep -x vrserver >/dev/null || pgrep -f "SteamLaunch" >/dev/null; then
|
||
|
|
not_run+=("windows"); echo "NOT RUN windows (SteamVR or a game is running)"
|
||
|
|
else
|
||
|
|
socket="tabletarot-sweep-$$"
|
||
|
|
kwin_wayland --virtual --no-lockscreen --socket "$socket" --width 1600 --height 1000 >/dev/null 2>&1 &
|
||
|
|
kwin_pid=$!
|
||
|
|
for _ in $(seq 50); do [[ -S "$XDG_RUNTIME_DIR/$socket" ]] && break; sleep 0.1; done
|
||
|
|
window_run=(env WAYLAND_DISPLAY="$socket" "$GODOT" --display-driver wayland --audio-driver Dummy --path . --)
|
||
|
|
run_step "window desktop" "${window_run[@]}" --sample --screenshot="$SHOTS/desktop.png"
|
||
|
|
run_step "window phone" "${window_run[@]}" --sample --mobile --screenshot="$SHOTS/phone.png"
|
||
|
|
kill "$kwin_pid" 2>/dev/null
|
||
|
|
echo "Screenshots: $SHOTS"
|
||
|
|
fi
|
||
|
|
|
||
|
|
took="$(( ($(date +%s%3N) - start_ms) / 1000 ))s of ${limit_secs}s"
|
||
|
|
(( ${#not_run[@]} )) && echo "NOT RUN: ${not_run[*]}"
|
||
|
|
if (( ${#failed[@]} )); then echo "RELEASE SWEEP FAILED: ${failed[*]} ($took)"; exit 1; fi
|
||
|
|
if (( ${#not_run[@]} )); then echo "RELEASE SWEEP OVER TIME ($took)"; exit 2; fi
|
||
|
|
echo "RELEASE SWEEP PASSED ($took)"
|