All checks were successful
PR Preview / test (pull_request) Has been skipped
PR Preview / teardown-preview (pull_request) Successful in 15s
PR Preview / deploy-preview (pull_request) Has been skipped
Deploy Production / test (push) Successful in 13s
Deploy Production / deploy (push) Successful in 7s
Test / unit-test (push) Successful in 7s
Test / build-check (push) Successful in 4s
Test / e2e-test (push) Successful in 2m59s
Batch3跑16个spec时内存累积导致最后一个超时。均衡分配。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
103 lines
4.3 KiB
YAML
103 lines
4.3 KiB
YAML
name: Test
|
|
on: [push]
|
|
|
|
jobs:
|
|
unit-test:
|
|
runs-on: test
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install & Run unit tests
|
|
run: cd frontend && npm ci && npx vitest run --reporter=verbose
|
|
|
|
e2e-test:
|
|
runs-on: test
|
|
needs: unit-test
|
|
timeout-minutes: 15
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install frontend deps
|
|
run: cd frontend && npm ci
|
|
|
|
- name: Install backend deps
|
|
run: python3 -m venv /tmp/ci-venv && /tmp/ci-venv/bin/pip install -q -r backend/requirements.txt
|
|
|
|
- name: E2E tests
|
|
run: |
|
|
# Dynamic ports to avoid conflicts
|
|
BE_PORT=$(shuf -i 9000-9999 -n 1)
|
|
FE_PORT=$(shuf -i 4000-4999 -n 1)
|
|
DB_FILE="/tmp/ci_oil_test_${BE_PORT}.db"
|
|
echo "Using backend=$BE_PORT frontend=$FE_PORT db=$DB_FILE"
|
|
|
|
# Known admin token for E2E tests
|
|
ADMIN_TOKEN="cypress_ci_admin_token_e2e_$(echo $BE_PORT)"
|
|
export ADMIN_TOKEN
|
|
|
|
# Start backend
|
|
DB_PATH="$DB_FILE" FRONTEND_DIR=/dev/null ADMIN_TOKEN="$ADMIN_TOKEN" \
|
|
/tmp/ci-venv/bin/uvicorn backend.main:app --port $BE_PORT &
|
|
BE_PID=$!
|
|
|
|
# Start frontend with proxy to dynamic backend port
|
|
(cd frontend && VITE_API_PORT=$BE_PORT npx vite --port $FE_PORT) &
|
|
FE_PID=$!
|
|
|
|
# Wait for both servers (max 30s, fail fast)
|
|
READY=0
|
|
for i in $(seq 1 30); do
|
|
if curl -sf http://localhost:$BE_PORT/api/oils > /dev/null 2>&1 && \
|
|
curl -sf http://localhost:$FE_PORT/ > /dev/null 2>&1; then
|
|
echo "Both servers ready in ${i}s"
|
|
READY=1
|
|
break
|
|
fi
|
|
sleep 1
|
|
done
|
|
|
|
if [ "$READY" = "0" ]; then
|
|
echo "ERROR: Servers failed to start within 30s"
|
|
kill $BE_PID $FE_PID 2>/dev/null
|
|
rm -f "$DB_FILE"
|
|
exit 1
|
|
fi
|
|
|
|
# Run all specs in 3 batches to avoid Electron memory crashes
|
|
cd frontend
|
|
CYPRESS_CFG="video=false,defaultCommandTimeout=5000,pageLoadTimeout=10000,requestTimeout=5000,responseTimeout=10000,baseUrl=http://localhost:$FE_PORT,experimentalMemoryManagement=true,numTestsKeptInMemory=0"
|
|
|
|
echo "=== Batch 1: API & data tests ==="
|
|
timeout 300 npx cypress run \
|
|
--spec "cypress/e2e/api-crud.cy.js,cypress/e2e/api-health.cy.js,cypress/e2e/oil-data-integrity.cy.js,cypress/e2e/recipe-cost-parity.cy.js,cypress/e2e/endpoint-parity.cy.js,cypress/e2e/registration-flow.cy.js,cypress/e2e/pr27-features.cy.js,cypress/e2e/kit-export.cy.js" \
|
|
--config "$CYPRESS_CFG" --env "ADMIN_TOKEN=$ADMIN_TOKEN"
|
|
B1=$?
|
|
|
|
echo "=== Batch 2: UI flow tests ==="
|
|
timeout 300 npx cypress run \
|
|
--spec "cypress/e2e/auth-flow.cy.js,cypress/e2e/admin-flow.cy.js,cypress/e2e/navigation.cy.js,cypress/e2e/recipe-detail.cy.js,cypress/e2e/recipe-search.cy.js,cypress/e2e/manage-recipes.cy.js,cypress/e2e/diary-flow.cy.js,cypress/e2e/favorites.cy.js,cypress/e2e/inventory-flow.cy.js,cypress/e2e/demo-walkthrough.cy.js" \
|
|
--config "$CYPRESS_CFG" --env "ADMIN_TOKEN=$ADMIN_TOKEN"
|
|
B2=$?
|
|
|
|
echo "=== Batch 3: Remaining tests ==="
|
|
timeout 300 npx cypress run \
|
|
--spec "cypress/e2e/app-load.cy.js,cypress/e2e/account-settings.cy.js,cypress/e2e/audit-log-advanced.cy.js,cypress/e2e/batch-operations.cy.js,cypress/e2e/bug-tracker-flow.cy.js,cypress/e2e/category-modules.cy.js,cypress/e2e/notification-flow.cy.js,cypress/e2e/oil-reference.cy.js,cypress/e2e/performance.cy.js,cypress/e2e/price-display.cy.js,cypress/e2e/projects-flow.cy.js,cypress/e2e/responsive.cy.js,cypress/e2e/search-advanced.cy.js,cypress/e2e/user-management-flow.cy.js,cypress/e2e/visual-check.cy.js" \
|
|
--config "$CYPRESS_CFG" --env "ADMIN_TOKEN=$ADMIN_TOKEN"
|
|
B3=$?
|
|
|
|
# Cleanup
|
|
kill $BE_PID $FE_PID 2>/dev/null
|
|
pkill -f "Cypress" 2>/dev/null || true
|
|
rm -f "$DB_FILE"
|
|
|
|
echo "Results: Batch1=$B1 Batch2=$B2 Batch3=$B3"
|
|
if [ $B1 -ne 0 ] || [ $B2 -ne 0 ] || [ $B3 -ne 0 ]; then
|
|
exit 1
|
|
fi
|
|
|
|
build-check:
|
|
runs-on: test
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Build frontend
|
|
run: cd frontend && npm ci && npm run build
|