#!/bin/bash
# W2 #238 gate — kitsubito arm. Usage: w2_gate_linux.sh <sha> <branch>
set -u
SHA="$1"
BRANCH="${2:?branch required}"
export PATH="$HOME/.cargo/bin:$PATH"
cd "$HOME/gate-242-w1" || exit 9
run() { name=$1; shift; echo "=== $name: $*" >> GATE_driver.log; "$@" > "GATE_${name}.raw" 2>&1; echo $? > "GATE_${name}.exit"; }
git fetch origin "$BRANCH" >> GATE_driver.log 2>&1
git checkout -q "$SHA" || { echo "checkout failed" >> GATE_driver.log; exit 8; }
git log --oneline -1 >> GATE_driver.log
run fixtures cargo build -p mock-adapter --bins
run clippy cargo clippy --workspace --all-targets -- -D warnings
run nextest_proto cargo nextest run -p spt-proto
run nextest_store cargo nextest run -p spt-store
run nextest_daemon cargo nextest run -p spt-daemon
run nextest_spt cargo nextest run -p spt
run midturn_e2e cargo nextest run -p spt --test midturn_span_e2e
run neighbor_e2e cargo nextest run -p spt --test io_events_poll_e2e
echo DONE >> GATE_driver.log
