A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
#!/usr/bin/env bash
# One command for "does my change pass?": the same checks CI runs, in order, cheapest first. Needs dotnet and uv, not
# Unity (Unity edit-mode tests are not run by CI either; CONTRIBUTING.md, "What CI runs").
# Where a Unity editor and a unity/Library exist, it also compiles unity/ with dotnet (scripts/unity_compile/).
# Stops at the first failure, prints the last lines of that step's output and exits non-zero. The failing step's
# whole log is kept in .superpowers/check-logs/ (git ignores it), and its path printed; passing runs keep nothing.
#
# Usage: scripts/check.sh [BASE_REF] BASE_REF defaults to $CHECK_BASE, then origin/main.
# The changelog step compares BASE_REF...HEAD, so it sees committed changes only (as CI does). Set
# CHECK_NO_CHANGELOG=1 if the pull request carries the no-changelog label. CHECK_TAIL sets the lines shown (default 40).
set -uo pipefail
cd "$(dirname "$0")/.."
base="${1:-${CHECK_BASE:-origin/main}}"
tail_lines="${CHECK_TAIL:-40}"
export UV_PYTHON="${UV_PYTHON:-3.12}" # the Python CI uses (UV_PYTHON in .github/workflows/ci.yml)
export PYTHONUTF8=1 # so check.sh reads and writes UTF-8 on any system locale (Windows cp1255)
log="$(mktemp)"
trap 'rm -f "$log"' EXIT
for tool in dotnet uv; do
command -v "$tool" >/dev/null || { echo "missing: $tool (see docs/dev-setup.md)"; exit 2; }
done
git rev-parse --verify --quiet "$base^{commit}" >/dev/null || { echo "base ref not found: $base (try: git fetch origin)"; exit 2; }
skip=false
[ "${CHECK_NO_CHANGELOG:-}" = 1 ] && skip=true
run() {
local name="$1"; shift
echo "== $name"
if ! "$@" >"$log" 2>&1; then
echo "FAILED: $name"
echo "-- last $tail_lines lines of: $*"
tail -n "$tail_lines" "$log"
# Keep the whole log (the trap deletes the temp one), so a flaky failure's message is not lost.
local slug kept
slug="$(printf '%s' "$name" | sed 's/[^A-Za-z0-9._-]\{1,\}/-/g; s/^-//; s/-$//')"
kept="$PWD/.superpowers/check-logs/$slug-$(date -u +%Y%m%dT%H%M%SZ).log"
if mkdir -p "${kept%/*}" && cp "$log" "$kept"; then echo "kept the failing step's log: $kept"; fi
exit 1
fi
tail -n 3 "$log"
}
run "changelog (against $base)" uv run scripts/oss/changelog_check.py --base "$base" --skip-label "$skip"
run "reviewed_by guard (against $base)" uv run scripts/oss/reviewed_by_guard.py --base "$base"
run "gdd lint" uv run scripts/oss/gdd_lint.py
run "policy checker tests" uv run --with pytest==9.1.1 --with pyyaml==6.0.3 --with requests==2.32.5 pytest scripts/oss/tests -q
run "repo policy" uv run scripts/oss/check_repo.py
run "rule ids" uv run scripts/oss/rule_ids.py
run "sim build, warnings as errors" dotnet build sim/Statecraft.sln -c Release --nologo -warnaserror
# Optional (T72): compile unity/ with dotnet, outside Unity, in about 2 s and with no Unity licence. It is skipped only
# when the project's editor or unity/Library is missing (CI, most contributors), and says so; any other problem fails.
unity_version="$(sed -n 's/^m_EditorVersion: //p' unity/ProjectSettings/ProjectVersion.txt)"
[ -n "$unity_version" ] || { echo "FAILED: unity compile: no m_EditorVersion in unity/ProjectSettings/ProjectVersion.txt"; exit 1; }
unity_contents="${CHECK_UNITY_CONTENTS:-/Applications/Unity/Hub/Editor/$unity_version/Unity.app/Contents}"
# The Linux (and Windows) editor has no Unity.app/Contents; its Editor/Data holds the same Managed and NetStandard folders.
linux_data="$HOME/Unity/Hub/Editor/$unity_version/Editor/Data"
if [ -z "${CHECK_UNITY_CONTENTS:-}" ] && [ ! -d "$unity_contents" ] && [ -d "$linux_data" ]; then unity_contents="$linux_data"; fi
if [ ! -d "$unity_contents" ]; then
echo "== unity compile: SKIPPED, no Unity $unity_version editor at $unity_contents"
elif [ ! -d unity/Library ]; then
echo "== unity compile: SKIPPED, no unity/Library (open the project in Unity once, or clone a Library)"
else
run "unity compile (dotnet, outside Unity)" scripts/unity_compile/compile.sh "$unity_contents"
fi
# TreatNoTestsAsError: zero tests found is a failure, not a pass (#2532); pytest already exits 5 on no tests.
run "sim and content tests" dotnet test sim/Statecraft.sln -c Release --nologo -- RunConfiguration.TreatNoTestsAsError=true
run "data tool tests" uv run --with pytest==9.1.1 --with rasterio==1.5.2 --with numpy==2.5.3 --with pyyaml==6.0.3 --with pillow==12.3.0 --with requests==2.32.5 --with pyproj==3.8.0 pytest tools/tests -q
echo
echo "ALL CHECKS PASSED"