43 lines
1.4 KiB
Bash
43 lines
1.4 KiB
Bash
#!/usr/bin/env bash
|
|
# qihuaiflow minimal CI gate - git pre-push hook.
|
|
#
|
|
# Runs backend pytest + frontend vitest INSIDE the long-lived qihu-aiflow
|
|
# container before any `git push` leaves this host. If a suite fails the
|
|
# push is blocked (exit non-zero), so a broken tree can never be published.
|
|
#
|
|
# Install (on the deploy host, inside the repo):
|
|
# cp scripts/git-hooks/pre-push .git/hooks/pre-push
|
|
# chmod +x .git/hooks/pre-push
|
|
#
|
|
# This is a self-contained bash gate (no python dependency on the host).
|
|
# The canonical, documented version lives in scripts/ci_gate.py.
|
|
set -uo pipefail
|
|
|
|
CONTAINER="qihu-aiflow"
|
|
|
|
if ! docker ps --format '{{.Names}}' | grep -qx "$CONTAINER"; then
|
|
echo "[CI Gate] ERROR: container $CONTAINER is not running - aborting push" >&2
|
|
exit 2
|
|
fi
|
|
|
|
echo "=== [CI Gate] backend pytest ==="
|
|
docker exec "$CONTAINER" bash -c 'cd /app/backend/python && .venv/bin/python -m pytest -c pytest.ini -q'
|
|
backend_rc=$?
|
|
if [ "$backend_rc" -ne 0 ]; then
|
|
echo "[CI Gate] backend pytest FAILED (rc=$backend_rc) - push blocked" >&2
|
|
exit 1
|
|
fi
|
|
echo "[CI Gate] backend pytest OK"
|
|
|
|
echo "=== [CI Gate] frontend vitest ==="
|
|
docker exec "$CONTAINER" bash -c 'cd /app/frontend && npx vitest run --reporter=dot'
|
|
frontend_rc=$?
|
|
if [ "$frontend_rc" -ne 0 ]; then
|
|
echo "[CI Gate] frontend vitest FAILED (rc=$frontend_rc) - push blocked" >&2
|
|
exit 1
|
|
fi
|
|
echo "[CI Gate] frontend vitest OK"
|
|
|
|
echo "[CI Gate] PASSED - all suites green - push allowed"
|
|
exit 0
|