#!/usr/bin/env bash
#
# Pre-push test gate. The deploy server only ever PULLS, so the real place to
# stop broken code is right here — before anything leaves this machine.
#
# The suite needs no external database: integration tests spin up an in-process
# PGlite database per worker (see tests/helpers/integration-setup.ts), so
# `npm test` runs standalone. A real failure blocks the push; the run ends with a
# compact copy-pasteable summary (scripts/test-summary.mjs).
#
# Install once:   git config core.hooksPath .githooks
# Emergency skip: git push --no-verify
#
set -euo pipefail

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

echo "▶ pre-push: running the full test suite…"
node scripts/test-summary.mjs

echo "✓ all tests green — pushing."
