Files
ai4se-harness-suite/example-project/e2e-run.sh
ning-inspire fc7521d6f9 feat: overnight-runner 入 SDD、dev-build 全栈编排,并落地 ACC-account
将 overnight-runner skill 无前缀并入套件;dev-build 编排自测/UI/代码评审;指南左侧导航;example 实现账号能力与 progress。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-17 16:56:57 +08:00

87 lines
2.2 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "$0")" && pwd)"
BACKEND_DIR="$ROOT/containers/backend"
FRONTEND_DIR="$ROOT/containers/frontend"
E2E_DIR="$ROOT/e2e"
BACKEND_PORT=8080
FRONTEND_PORT=5173
BACKEND_PID=""
FRONTEND_PID=""
cleanup() {
echo ""
echo "🛑 Cleaning up..."
[ -n "$FRONTEND_PID" ] && kill "$FRONTEND_PID" 2>/dev/null && echo " Frontend (PID $FRONTEND_PID) stopped"
[ -n "$BACKEND_PID" ] && kill "$BACKEND_PID" 2>/dev/null && echo " Backend (PID $BACKEND_PID) stopped"
wait 2>/dev/null
echo "✅ Cleanup done"
}
trap cleanup EXIT INT TERM
# ── E2E 环境约定(ACC) ──
# 短信验证码固定码:Mock 短信通道(后端 sms.mock.fixed-code)
export SMS_MOCK_FIXED_CODE="${SMS_MOCK_FIXED_CODE:-123456}"
# 放开重发间隔限制,便于连续发码
export SMS_CODE_RESEND_INTERVAL_SECONDS="${SMS_CODE_RESEND_INTERVAL_SECONDS:-0}"
# ── Start backend ──
echo "🚀 Starting backend (port $BACKEND_PORT)..."
cd "$BACKEND_DIR"
mvn spring-boot:run -q > /tmp/e2e-backend.log 2>&1 &
BACKEND_PID=$!
echo " Backend PID: $BACKEND_PID"
echo " Waiting for backend..."
for i in $(seq 1 60); do
if curl -s -o /dev/null -w "%{http_code}" "http://localhost:$BACKEND_PORT/api/v1/health" 2>/dev/null | grep -q 200; then
echo " Backend ready after ${i}s"
break
fi
if [ "$i" -eq 60 ]; then
echo "❌ Backend failed to start within 60s"
tail -20 /tmp/e2e-backend.log
exit 1
fi
sleep 1
done
# ── Start frontend ──
echo "🚀 Starting frontend (port $FRONTEND_PORT)..."
cd "$FRONTEND_DIR"
npm run dev > /tmp/e2e-frontend.log 2>&1 &
FRONTEND_PID=$!
echo " Frontend PID: $FRONTEND_PID"
echo " Waiting for frontend..."
for i in $(seq 1 30); do
if curl -s -o /dev/null "http://localhost:$FRONTEND_PORT" 2>/dev/null; then
echo " Frontend ready after ${i}s"
break
fi
if [ "$i" -eq 30 ]; then
echo "❌ Frontend failed to start within 30s"
tail -10 /tmp/e2e-frontend.log
exit 1
fi
sleep 1
done
# ── Run E2E tests ──
echo ""
echo "🧪 Running E2E tests..."
cd "$E2E_DIR"
npx playwright test "$@"
EXIT_CODE=$?
echo ""
if [ $EXIT_CODE -eq 0 ]; then
echo "✅ All E2E tests passed!"
else
echo "❌ Some E2E tests failed (exit code: $EXIT_CODE)"
fi
exit $EXIT_CODE