| #!/usr/bin/env bash |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| set -euo pipefail |
|
|
| |
| RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m' |
| pass() { echo -e "${GREEN}✓ $1${NC}"; } |
| fail() { echo -e "${RED}✗ $1${NC}"; echo -e "${RED}Fix the above before pushing.${NC}"; exit 1; } |
| info() { echo -e "${YELLOW}→ $1${NC}"; } |
| divider() { echo -e "\n${YELLOW}────────────────────────────────────────${NC}"; } |
|
|
| ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" |
|
|
| echo "" |
| echo "╔══════════════════════════════════════╗" |
| echo "║ AITasker — Validation Suite ║" |
| echo "╚══════════════════════════════════════╝" |
|
|
| |
| divider |
| info "Layer 1: TypeScript compile check" |
| cd "$ROOT/backend" |
| if npx tsc --noEmit; then |
| pass "TypeScript: no type errors" |
| else |
| fail "TypeScript: compile errors found" |
| fi |
|
|
| |
| divider |
| info "Layer 2: ESLint" |
| if npm run lint -- --max-warnings 0; then |
| pass "ESLint: clean" |
| else |
| fail "ESLint: errors or warnings found" |
| fi |
|
|
| |
| divider |
| info "Layer 3: Unit tests (mocked deps, no DB)" |
| if npx jest --config jest.unit.config.js --passWithNoTests; then |
| pass "Unit tests: all passed" |
| else |
| fail "Unit tests: failures found" |
| fi |
|
|
| |
| divider |
| info "Layer 4: Integration + Swagger tests (starting test DB)" |
|
|
| cd "$ROOT" |
| docker compose -f backend/docker-compose.test.yml up -d --wait |
| info "Test DB healthy" |
|
|
| cd "$ROOT/backend" |
| DATABASE_URL="postgresql://aitasker_test:aitasker_test@localhost:5433/aitasker_test" \ |
| npx prisma migrate deploy |
| info "Migrations applied" |
|
|
| |
| set +e |
| npm run test:e2e |
| TEST_EXIT=$? |
| set -e |
|
|
| cd "$ROOT" |
| docker compose -f backend/docker-compose.test.yml down |
| info "Test DB stopped and wiped" |
|
|
| if [ $TEST_EXIT -ne 0 ]; then |
| fail "Integration/Swagger tests: failures found" |
| fi |
| pass "Integration + Swagger tests: all passed" |
|
|
| |
| divider |
| echo "" |
| echo -e "${GREEN}╔══════════════════════════════════════╗${NC}" |
| echo -e "${GREEN}║ All checks passed — safe to push ║${NC}" |
| echo -e "${GREEN}╚══════════════════════════════════════╝${NC}" |
| echo "" |