make dist (tools/dist.sh) checks the official export templates against tools/engine.sha512, installs only the Linux x86_64 ones into the repo-local engine data, exports the "Linux" preset, checks the binary is the verified release template, and packs build/dist/tidewall-<version>-linux-x86_64.tar.gz with a .sha256: tidewall.x86_64, tidewall.pck, a tidewall-server launcher that runs the same game headless with clean SIGTERM handling, an example server.cfg, README, VERSION, licences and asset provenance. BuildInfo gives the version (application/config/version, now 0.9.0) and the commit (build_commit.txt written by make dist, or .git in a checkout). The main menu shows "Version 0.9.0 (commit)" and the server's start log line carries version and commit. make dist-check (tools/dist_check.sh) unpacks the package outside the repo with HOME and XDG dirs in a temp dir and runs smoke against it (new SMOKE_DIST mode), a whole bot match, and the exported game joining the exported server over loopback. A release template crashes on a call on null (exit 139) and ignores invalid calls, so in package mode smoke's fault check expects only a non-zero exit. Closes #60 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
100 lines
5.0 KiB
Bash
Executable File
100 lines
5.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# R1: builds the release package with tools/dist.sh, unpacks it outside the repository
|
|
# and checks that it works there with nothing from the checkout:
|
|
# - its checksum, and that it holds exactly the files it should;
|
|
# - tools/smoke.sh against its server (SMOKE_DIST);
|
|
# - a whole bot-only match, lobby to results, on its server;
|
|
# - its game, headless with the autoplay script, joining its server over loopback UDP
|
|
# and playing (as tools/client_check.sh does from the repo);
|
|
# - the version and commit in the logs match its VERSION file.
|
|
#
|
|
# tools/dist_check.sh about 3 minutes
|
|
set -uo pipefail
|
|
|
|
repo="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
cd "$repo"
|
|
status=0
|
|
fail() {
|
|
echo "dist-check FAIL: $*"
|
|
status=1
|
|
}
|
|
|
|
tools/dist.sh >/dev/null || { echo "dist-check FAIL: tools/dist.sh failed"; tools/dist.sh 2>&1 | tail -n 10; exit 1; }
|
|
archive="$(ls -t build/dist/tidewall-*-linux-x86_64.tar.gz | head -n 1)"
|
|
name="$(basename "$archive" .tar.gz)"
|
|
|
|
work="$(mktemp -d)"
|
|
cleanup() {
|
|
[[ -n "${server_pid:-}" ]] && kill -TERM "$server_pid" 2>/dev/null
|
|
rm -rf "$work"
|
|
}
|
|
trap cleanup EXIT
|
|
(cd "$(dirname "$archive")" && sha256sum --check --quiet "$name.tar.gz.sha256") || fail "the checksum doesn't match"
|
|
tar -xzf "$archive" -C "$work"
|
|
package="$work/$name"
|
|
# Nothing the package runs may reach back into the checkout, and nothing it writes may
|
|
# land in the user's home.
|
|
export HOME="$work/home" XDG_DATA_HOME="$work/home/data" XDG_CONFIG_HOME="$work/home/config" XDG_CACHE_HOME="$work/home/cache" XDG_STATE_HOME="$work/home/state"
|
|
mkdir -p "$HOME"
|
|
|
|
expected="LICENSE LICENSE-ASSETS PROVENANCE.md README.md VERSION server.cfg tidewall-server tidewall.pck tidewall.x86_64"
|
|
actual="$(cd "$package" && ls -A | LC_ALL=C sort | tr '\n' ' ' | sed 's/ $//')"
|
|
[[ "$actual" == "$expected" ]] || fail "the package holds '$actual', expected '$expected'"
|
|
version="$(sed -n 's/^Tidewall //p' "$package/VERSION")"
|
|
commit="$(sed -n 's/^commit //p' "$package/VERSION")"
|
|
[[ -n "$version" && -n "$commit" ]] || fail "VERSION doesn't name a version and commit"
|
|
|
|
echo "dist-check: smoke against $name" >&2
|
|
(cd "$work" && SMOKE_DIST="$package" "$repo/tools/smoke.sh") | sed 's/^/ /' || fail "smoke failed against the package"
|
|
|
|
echo "dist-check: a whole bot match on the package's server" >&2
|
|
match_log="$work/match.log"
|
|
(cd "$work" && timeout --signal=KILL 600 nice -n 15 "$package/tidewall-server" --seed=2 --bots=24 --matches=1 --unthrottled >"$match_log" 2>&1)
|
|
code=$?
|
|
[[ "$code" -eq 0 ]] || fail "the bot match exited $code"
|
|
grep -q '"event":"results"' "$match_log" || fail "the bot match never reached its results"
|
|
grep -q '"errors":0,"event":"stop"' "$match_log" || fail "the bot match logged errors"
|
|
start="$(grep -m1 '"event":"start"' "$match_log")"
|
|
grep -q "\"version\":\"$version\"" <<<"$start" || fail "the server log doesn't give version $version"
|
|
grep -q "\"commit\":\"$commit\"" <<<"$start" || fail "the server log doesn't give commit $commit"
|
|
echo " bot match: results reached, version $version, commit $commit"
|
|
|
|
echo "dist-check: the package's game joins its server" >&2
|
|
port=$((20000 + RANDOM % 20000))
|
|
server_log="$work/server.log"
|
|
cd "$work"
|
|
TIDEWALL_STATE="$work/server-state" nice -n 15 "$package/tidewall-server" --listen --port="$port" --seed=2 --bots=1 --matches=1 >"$server_log" 2>&1 &
|
|
server_pid=$!
|
|
cd "$repo"
|
|
for _ in $(seq 1 100); do
|
|
grep -q '"event":"start"' "$server_log" 2>/dev/null && break
|
|
sleep 0.1
|
|
done
|
|
client_log="$work/client.log"
|
|
(cd "$work" && timeout --signal=KILL 120 nice -n 15 "$package/tidewall.x86_64" --headless -- --connect="127.0.0.1:$port" --name=Mara --autoplay --client-seconds=55 >"$client_log" 2>&1)
|
|
client_code=$?
|
|
kill -TERM "$server_pid" 2>/dev/null
|
|
wait "$server_pid"
|
|
server_code=$?
|
|
server_pid=""
|
|
report="$(grep -m1 '"event":"client"' "$client_log" || true)"
|
|
[[ "$client_code" -eq 0 ]] || fail "the game exited with $client_code"
|
|
[[ "$server_code" -eq 0 ]] || fail "the server exited with $server_code"
|
|
[[ -n "$report" ]] || fail "the game said nothing"
|
|
grep -q '"joined":true' <<<"$report" || fail "the game never joined"
|
|
grep -q '"phases":\["lobby","countdown","drop"' <<<"$report" || fail "the game didn't follow the match from the lobby into the drop"
|
|
grep -q '"bad_packets":0' <<<"$report" || fail "the game was sent packets it couldn't read"
|
|
playing="$(sed -n 's/.*"frames_playing":\([0-9]*\).*/\1/p' <<<"$report")"
|
|
[[ "${playing:-0}" -ge 300 ]] || fail "the game's player was in the match for only ${playing:-0} frames"
|
|
grep -q '"event":"player_joined".*"name":"Mara"' "$server_log" || fail "the server never saw the game join"
|
|
grep -q '"errors":0,"event":"stop"' "$server_log" || fail "the server logged errors"
|
|
echo " game: joined, in the match for ${playing:-0} frames"
|
|
if [[ -n "$(ls -A "$HOME/data" 2>/dev/null | grep -v '^godot$')" ]]; then
|
|
fail "the package wrote outside the engine's user data: $(ls -A "$HOME/data")"
|
|
fi
|
|
|
|
if [[ "$status" -eq 0 ]]; then
|
|
echo "dist-check: ok ($name works outside the repository: smoke, a bot match, and its game playing on its server)"
|
|
fi
|
|
exit "$status"
|