#!/usr/bin/env bash # The definition of "done" for every lane (CLAUDE.md, Swift standards): # 1. swift-format lint --strict is clean # 2. swift build with warnings as errors is clean # 3. swift test is green, under the runaway guard # Exit 0 only if all three pass. Run from anywhere; operates on the repo # that contains this script (so it works inside a lane worktree). # # Usage: tools/gates.sh [--no-test] set -euo pipefail root=$(cd "$(dirname "$0")/.." && pwd) cd "$root" run_tests=1 [ "${1:-}" = "--no-test" ] && run_tests=0 echo "== gate 1/3: swift-format lint --strict" xcrun swift-format lint --strict --recursive Sources Tests Package.swift echo "== gate 2/3: swift build -Xswiftc -warnings-as-errors" swift build -Xswiftc -warnings-as-errors 2>&1 | grep -v '^\[' || true # grep swallows the exit status; re-check with a cheap incremental build. swift build -Xswiftc -warnings-as-errors >/dev/null if [ "$run_tests" = 1 ]; then echo "== gate 3/3: swift test (guarded: 8 GB / 15 min)" # pipefail is set, so a guard kill or a failing test fails this line. tools/guard.sh -m 8 -t 900 -- swift test 2>&1 | grep -E "Executed|error:|failed|passed after" | tail -20 else echo "== gate 3/3: skipped (--no-test)" fi echo "== gates: all green"