#!/usr/bin/env bash
# Pre-push hook: run local checks that match CI before allowing push.
# Install: git config core.hooksPath .githooks

set -euo pipefail

run_ci_like_checks() {
  echo ">>> pre-push: running local checks required before push"

  if ! command -v uv >/dev/null; then
    echo "[pre-push] Missing 'uv' in PATH. Install with: curl -LsSf https://astral.sh/uv/install.sh | sh" >&2
    exit 1
  fi

  echo "==> ruff check"
  uv run ruff check .

  echo "==> ruff format --check"
  uv run ruff format --check .

  echo "==> pyright"
  uv run pyright

  echo "==> pytest (non-exhaustive)"
  uv run pytest -m "not exhaustive" -x -q

  echo "==> pre-push checks passed"
}

run_ci_like_checks
