Some checks failed
Deploy API Server / build-and-deploy (push) Has been cancelled
- test/m-ai-01-09-integration.spec.ts: Active Recall/Feynman/Document Import E2E tests with real MySQL/Redis/BullMQ - test/run-integration-ci.sh: CI script (MySQL→Prisma→Build→API→Worker→Test) - npm run test:integration:worker: one-command integration test - Includes Active Recall chain audit (actual code paths with file:line) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
63 lines
1.6 KiB
Bash
63 lines
1.6 KiB
Bash
#!/bin/bash
|
|
# M-AI-01-09 CI Integration Test Runner
|
|
# Used by Gitea Actions workflow
|
|
set -e
|
|
|
|
echo "=== M-AI-01-09 Integration Test ==="
|
|
|
|
# 1. Start required services (handled by CI or docker-compose)
|
|
echo "[1/6] Checking MySQL..."
|
|
mysqladmin ping -h "${MYSQL_HOST:-127.0.0.1}" -P "${MYSQL_PORT:-3306}" -u root -p"${MYSQL_ROOT_PASSWORD}" --silent 2>/dev/null || {
|
|
echo "MySQL not available — starting via docker compose"
|
|
cd /opt/zhixi/backend
|
|
docker compose up -d mysql redis
|
|
sleep 10
|
|
}
|
|
|
|
echo "[2/6] Running Prisma migration..."
|
|
npx prisma migrate deploy
|
|
|
|
echo "[3/6] Building..."
|
|
npm run build
|
|
|
|
echo "[4/6] Starting API..."
|
|
NODE_ENV=test node dist/src/main.js &
|
|
API_PID=$!
|
|
sleep 5
|
|
|
|
echo "[5/6] Starting Worker..."
|
|
NODE_ENV=test node dist/src/worker.main.js &
|
|
WORKER_PID=$!
|
|
sleep 5
|
|
|
|
echo "API_PID=$API_PID"
|
|
echo "WORKER_PID=$WORKER_PID"
|
|
|
|
echo "[6/6] Running integration tests..."
|
|
DATABASE_URL="${DATABASE_URL}" \
|
|
REDIS_HOST="${REDIS_HOST:-127.0.0.1}" \
|
|
REDIS_PORT="${REDIS_PORT:-6379}" \
|
|
REDIS_PASSWORD="${REDIS_PASSWORD:-}" \
|
|
AI_PROVIDER=mock \
|
|
JWT_SECRET=test-secret \
|
|
INTERNAL_API_KEY=test-key \
|
|
CREDENTIAL_ENCRYPTION_KEY=test-credential-encryption-key32byte! \
|
|
npx jest --config test/jest-e2e.json --testPathPatterns="m-ai-01-09" --forceExit --verbose 2>&1
|
|
|
|
TEST_EXIT=$?
|
|
|
|
# Cleanup
|
|
echo "=== Cleaning up ==="
|
|
kill $WORKER_PID 2>/dev/null || true
|
|
kill $API_PID 2>/dev/null || true
|
|
wait $WORKER_PID 2>/dev/null || true
|
|
wait $API_PID 2>/dev/null || true
|
|
|
|
if [ $TEST_EXIT -eq 0 ]; then
|
|
echo "=== M-AI-01-09: PASS ==="
|
|
else
|
|
echo "=== M-AI-01-09: FAIL ==="
|
|
fi
|
|
|
|
exit $TEST_EXIT
|