multica/scripts/check.sh
Jiayuan Zhang 1ba0fb071a fix(web): fix stale state bugs, add real-time updates, and build verification pipeline
- Fix kanban board columns not adapting to available width (w-64 → flex-1)
- Fix workspace name not updating in sidebar after save in settings
- Fix comments leaking across issues when navigating between issue details
- Fix duplicate issue appearing on create (race between callback and WebSocket)
- Add real-time WebSocket listeners for agents and inbox pages
- Add `make check` one-click verification pipeline (typecheck + tests + E2E)
- Add E2E test fixtures for self-contained test data setup/teardown
- Add settings E2E test and updateWorkspace unit test
- Make `make start/setup` reuse existing PostgreSQL if already running
- Update CLAUDE.md with AI agent verification loop and E2E test patterns

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-22 12:44:49 +08:00

124 lines
4.2 KiB
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
# ==========================================================================
# Full verification pipeline: typecheck → unit tests → Go tests → E2E
# Usage: bash scripts/check.sh
# ==========================================================================
BACKEND_PID=""
FRONTEND_PID=""
STARTED_BACKEND=false
STARTED_FRONTEND=false
EXIT_CODE=0
# --------------------------------------------------------------------------
# Cleanup: kill only services this script started
# --------------------------------------------------------------------------
cleanup() {
echo ""
if [ "$STARTED_BACKEND" = true ] && [ -n "$BACKEND_PID" ]; then
kill "$BACKEND_PID" 2>/dev/null && wait "$BACKEND_PID" 2>/dev/null || true
echo " Stopped backend (PID $BACKEND_PID)"
fi
if [ "$STARTED_FRONTEND" = true ] && [ -n "$FRONTEND_PID" ]; then
kill "$FRONTEND_PID" 2>/dev/null && wait "$FRONTEND_PID" 2>/dev/null || true
echo " Stopped frontend (PID $FRONTEND_PID)"
fi
echo ""
if [ "$EXIT_CODE" -eq 0 ]; then
echo "✓ All checks passed."
else
echo "✗ Checks FAILED."
fi
exit "$EXIT_CODE"
}
trap cleanup EXIT
# --------------------------------------------------------------------------
# Utility: wait until a port responds
# --------------------------------------------------------------------------
wait_for_port() {
local port=$1 name=$2 max_wait=${3:-60} path=${4:-/}
local elapsed=0
echo " Waiting for $name on :$port..."
while ! curl -sf "http://localhost:${port}${path}" > /dev/null 2>&1; do
sleep 1
elapsed=$((elapsed + 1))
if [ "$elapsed" -ge "$max_wait" ]; then
echo " ERROR: $name did not start within ${max_wait}s"
EXIT_CODE=1
exit 1
fi
done
echo " $name ready (${elapsed}s)"
}
# --------------------------------------------------------------------------
# Step 0: Ensure DB
# --------------------------------------------------------------------------
echo "==> Checking PostgreSQL..."
if pg_isready -h localhost -p 5432 -U multica > /dev/null 2>&1; then
echo " Already running."
else
echo " Starting via docker compose..."
docker compose up -d
until docker compose exec -T postgres pg_isready -U multica > /dev/null 2>&1; do
sleep 1
done
echo " PostgreSQL ready."
fi
# --------------------------------------------------------------------------
# Step 1: TypeScript typecheck
# --------------------------------------------------------------------------
echo ""
echo "==> [1/5] TypeScript typecheck..."
pnpm typecheck || { EXIT_CODE=1; exit 1; }
# --------------------------------------------------------------------------
# Step 2: TypeScript unit tests (Vitest)
# --------------------------------------------------------------------------
echo ""
echo "==> [2/5] TypeScript unit tests..."
pnpm test || { EXIT_CODE=1; exit 1; }
# --------------------------------------------------------------------------
# Step 3: Go tests
# --------------------------------------------------------------------------
echo ""
echo "==> [3/5] Go tests..."
(cd server && go test ./...) || { EXIT_CODE=1; exit 1; }
# --------------------------------------------------------------------------
# Step 4: Start services for E2E (only if not already running)
# --------------------------------------------------------------------------
echo ""
echo "==> [4/5] Starting services for E2E..."
if curl -sf http://localhost:8080/health > /dev/null 2>&1; then
echo " Backend already running on :8080"
else
echo " Starting backend..."
(cd server && go run ./cmd/server) > /tmp/multica-check-backend.log 2>&1 &
BACKEND_PID=$!
STARTED_BACKEND=true
wait_for_port 8080 "Backend" 90 "/health"
fi
if curl -sf http://localhost:3000 > /dev/null 2>&1; then
echo " Frontend already running on :3000"
else
echo " Starting frontend..."
pnpm dev:web > /tmp/multica-check-frontend.log 2>&1 &
FRONTEND_PID=$!
STARTED_FRONTEND=true
wait_for_port 3000 "Frontend" 120 "/"
fi
# --------------------------------------------------------------------------
# Step 5: E2E tests (Playwright)
# --------------------------------------------------------------------------
echo ""
echo "==> [5/5] E2E tests (Playwright)..."
pnpm exec playwright test || { EXIT_CODE=1; exit 1; }