ci: 拆 e2e batch 最多 6 个 spec,避免 Electron 挂死
All checks were successful
PR Preview / test (pull_request) Has been skipped
Deploy Production / test (push) Successful in 8s
PR Preview / teardown-preview (pull_request) Successful in 15s
Test / unit-test (push) Successful in 7s
PR Preview / deploy-preview (pull_request) Has been skipped
Test / build-check (push) Successful in 4s
Deploy Production / deploy (push) Successful in 7s
Test / e2e-test (push) Successful in 3m14s
All checks were successful
PR Preview / test (pull_request) Has been skipped
Deploy Production / test (push) Successful in 8s
PR Preview / teardown-preview (pull_request) Successful in 15s
Test / unit-test (push) Successful in 7s
PR Preview / deploy-preview (pull_request) Has been skipped
Test / build-check (push) Successful in 4s
Deploy Production / deploy (push) Successful in 7s
Test / e2e-test (push) Successful in 3m14s
之前 batch 2 跑 10 个 spec 经常挂在第 5 个 spec 前后:runner log 显示 Cypress 完全静默 4+ 分钟,到 300s 外层 timeout 被 kill。本地跑同样批 次 60s 就结束,判断是 runner 资源紧张下 Electron 进程内存吃满、主 线程卡死;单次 run 的 spec 数越多越容易触发。 拆成 7 个小 batch(每批 ≤6 spec),单批结束回收 Cypress 进程+浏览 器,避免跨 spec 累积内存压力。同时把 batch 结果汇总从 3 个变量改 成 FAIL flag 里累加,方便扩展。
This commit was merged in pull request #44.
This commit is contained in:
@@ -62,35 +62,48 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Run all specs in 3 batches to avoid Electron memory crashes
|
||||
# Run specs in smaller batches (≤6 per run) to avoid Electron memory
|
||||
# hangs seen when a single cypress run handles 10+ specs on the CI runner.
|
||||
cd frontend
|
||||
CYPRESS_CFG="video=false,defaultCommandTimeout=5000,pageLoadTimeout=10000,requestTimeout=5000,responseTimeout=10000,baseUrl=http://localhost:$FE_PORT,experimentalMemoryManagement=true,numTestsKeptInMemory=0"
|
||||
FAIL=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=$?
|
||||
run_batch() {
|
||||
local name="$1"; shift
|
||||
echo "=== $name ==="
|
||||
timeout 300 npx cypress run \
|
||||
--spec "$1" \
|
||||
--config "$CYPRESS_CFG" --env "ADMIN_TOKEN=$ADMIN_TOKEN"
|
||||
local rc=$?
|
||||
if [ $rc -ne 0 ]; then
|
||||
echo "!!! $name failed (rc=$rc)"
|
||||
FAIL=1
|
||||
fi
|
||||
}
|
||||
|
||||
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=$?
|
||||
run_batch "Batch 1a: API parity" \
|
||||
"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"
|
||||
run_batch "Batch 1b: features" \
|
||||
"cypress/e2e/registration-flow.cy.js,cypress/e2e/pr27-features.cy.js,cypress/e2e/kit-export.cy.js"
|
||||
|
||||
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/oil-smart-paste.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=$?
|
||||
run_batch "Batch 2a: auth & nav" \
|
||||
"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"
|
||||
run_batch "Batch 2b: user flows" \
|
||||
"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"
|
||||
|
||||
run_batch "Batch 3a: misc flows" \
|
||||
"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"
|
||||
run_batch "Batch 3b: pages & perf" \
|
||||
"cypress/e2e/notification-flow.cy.js,cypress/e2e/oil-reference.cy.js,cypress/e2e/oil-smart-paste.cy.js,cypress/e2e/performance.cy.js,cypress/e2e/price-display.cy.js,cypress/e2e/projects-flow.cy.js"
|
||||
run_batch "Batch 3c: responsive & admin" \
|
||||
"cypress/e2e/responsive.cy.js,cypress/e2e/search-advanced.cy.js,cypress/e2e/user-management-flow.cy.js,cypress/e2e/visual-check.cy.js"
|
||||
|
||||
# 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
|
||||
if [ $FAIL -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user