Run :backend:check, frontend coverage, and :e2e:check as sibling tasks with org.gradle.parallel=true. Move E2E Docker compose into an e2e subproject so Playwright can start while unit tests run. Copy e2e/ in the E2E backend image so settings.gradle resolves inside Docker. Co-authored-by: Cursor <cursoragent@cursor.com>
31 lines
1.4 KiB
Bash
Executable file
31 lines
1.4 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Runs the same verification as CI before allowing a commit.
|
|
# Install: ./scripts/install-pre-commit-hook.sh
|
|
#
|
|
# Fails if line/branch coverage falls below project thresholds:
|
|
# Backend: 70% lines, 60% branches (JaCoCo jacocoTestCoverageVerification)
|
|
# Frontend: 70% lines, 60% branches, 70% functions (Vitest test:coverage)
|
|
|
|
set -euo pipefail
|
|
|
|
ROOT="$(git rev-parse --show-toplevel)"
|
|
cd "$ROOT"
|
|
|
|
export POSTGRES_DB="${POSTGRES_DB:-bilhej}"
|
|
export POSTGRES_USER="${POSTGRES_USER:-bilhej}"
|
|
export POSTGRES_PASSWORD="${POSTGRES_PASSWORD:-test_pw_ci_123}"
|
|
export JWT_SECRET="${JWT_SECRET:-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}"
|
|
export STRIPE_SECRET_KEY="${STRIPE_SECRET_KEY:-sk_test_fake}"
|
|
export STRIPE_WEBHOOK_SECRET="${STRIPE_WEBHOOK_SECRET:-whsec_fake}"
|
|
export STRIPE_PRICE_ID="${STRIPE_PRICE_ID:-price_fake}"
|
|
|
|
echo "pre-commit: running ./gradlew check (lint, coverage thresholds, E2E)..."
|
|
if ! ./gradlew check --no-daemon; then
|
|
echo ""
|
|
echo "pre-commit: FAILED."
|
|
echo " - Backend coverage: ./gradlew :backend:jacocoTestCoverageVerification (70% lines, 60% branches)"
|
|
echo " - Frontend coverage: cd frontend && npm run test:coverage (70% lines, 60% branches, 70% functions)"
|
|
echo " - Reports: backend/build/reports/jacoco/test/html/ frontend/coverage/"
|
|
exit 1
|
|
fi
|
|
echo "pre-commit: all checks passed (including line and branch coverage thresholds)."
|