#!/usr/bin/env bash # Runs the test suite before allowing a push. Install this hook with: # git config core.hooksPath .githooks # (or copy it into .git/hooks/pre-push directly). set -euo pipefail repo_root="$(git rev-parse --show-toplevel)" cd "$repo_root" if [ -x ".venv/bin/pytest" ]; then PYTEST=".venv/bin/pytest" elif command -v pytest >/dev/null 2>&1; then PYTEST="pytest" else echo "pre-push: pytest not found (expected .venv/bin/pytest or pytest on PATH)." >&2 echo "Install dev deps first: pip install -r requirements-dev.txt" >&2 exit 1 fi echo "pre-push: running test suite..." if ! "$PYTEST" -q; then echo "pre-push: tests failed, aborting push." >&2 exit 1 fi