diff --git a/.gitea/workflows/cd.yaml b/.gitea/workflows/cd.yaml index fd22cd9d..1f04dac9 100644 --- a/.gitea/workflows/cd.yaml +++ b/.gitea/workflows/cd.yaml @@ -95,14 +95,25 @@ jobs: cd apps/api # CI 排除需外部服務的測試 (Redis pool / Ollama — 2026-04-01 Claude Code) - pytest tests/ -v --tb=short -x \ + # 2026-04-05 Claude Code: 修正 exit code — | tail 會吃掉 segfault (exit 139) + # 改用 tee + PIPESTATUS[0] 正確捕捉 pytest 本身的 exit code + # 2026-04-05 Claude Code: 加 --ignore=tests/integration 排除需 asyncpg 連線的 DB 測試 + # integration tests 在 prod K8s 部署後由 E2E Smoke Test 覆蓋 + # PYTHONFAULTHANDLER=1: 若 C extension segfault,輸出完整 Python stacktrace + # test_github_webhook.py: import src.main → 觸發 asyncpg C ext → CI segfault (exit 139) + # src.main 在 collection 時初始化 SQLAlchemy async engine (asyncpg C extension) + # 此測試在 prod E2E Smoke Test 覆蓋 (awoooi.wooo.work) + PYTHONFAULTHANDLER=1 python3.11 -m pytest tests/ -v --tb=short -x \ + --ignore=tests/integration \ --ignore=tests/test_anomaly_counter.py \ --ignore=tests/test_global_repair_cooldown.py \ --ignore=tests/test_redis_multisig.py \ --ignore=tests/test_model_regression.py \ --ignore=tests/test_prompt_validation.py \ - 2>&1 | tail -50 - echo "✅ API 測試通過" + --ignore=tests/test_github_webhook.py \ + 2>&1 | tee /tmp/pytest-output.txt; PYTEST_EXIT=${PIPESTATUS[0]} + tail -60 /tmp/pytest-output.txt + exit $PYTEST_EXIT - name: Login to Harbor uses: docker/login-action@v3