#!/usr/bin/env bash
# coord developer pre-push hook.
#
# Runs the cheap half of CI locally before letting a push leave your
# machine. Catches lint, type, and unit-test breakage in ~30 seconds
# instead of burning a full GitHub Actions matrix run (~3 minutes).
#
# Skips the container smoke (docker-smoke) by default; add it yourself
# if you are touching Dockerfile or runtime code. Run `make verify`
# manually for the full local CI equivalent.
#
# To install:
#
#   ln -sf ../../scripts/git-hooks/pre-push .git/hooks/pre-push
#   chmod +x .git/hooks/pre-push
#
# To skip for a one-off push (e.g. docs-only change):
#
#   git push --no-verify
#
# Exit non-zero aborts the push.

set -euo pipefail

cd "$(git rev-parse --show-toplevel)"

if [ ! -x .venv/bin/pytest ]; then
  echo "pre-push: no .venv detected; run 'make install' first or 'git push --no-verify' to bypass." >&2
  exit 1
fi

echo "pre-push: running make check (ruff + mypy + pytest)..."
make check
echo "pre-push: OK"
