fix: test and coverage gracefully skip when tests/ or src/ not exists
CI / lint (push) Successful in -3m58s
CI / lint (pull_request) Successful in -3m58s
CI / test (push) Failing after -3m59s
CI / test (pull_request) Failing after -3m59s
CI / notify-on-failure (push) Successful in -4m3s
CI / notify-on-failure (pull_request) Successful in -4m3s

This commit is contained in:
cfdaily
2026-06-06 18:43:40 +08:00
parent b28d7cca9e
commit 073121f7ca
2 changed files with 15 additions and 3 deletions
+5 -1
View File
@@ -52,7 +52,11 @@ jobs:
- name: Run tests (exclude E2E)
run: |
.venv/bin/pytest tests/ -m "not e2e" -x -q
if [ -d tests ]; then
.venv/bin/pytest tests/ -m "not e2e" -x -q
else
echo "No tests/ directory, skipping tests"
fi
# ── Job 3: CI 失败通知 ───────────────────────────────
# v1.23 不支持 failure(),用 always() + shell 检查 commit status 替代
+10 -2
View File
@@ -34,11 +34,19 @@ jobs:
- name: Unit & Integration Tests
run: |
.venv/bin/pytest tests/ -m "not e2e" -x -q
if [ -d tests ]; then
.venv/bin/pytest tests/ -m "not e2e" -x -q
else
echo "No tests/ directory, skipping tests"
fi
- name: Coverage Report
run: |
.venv/bin/pytest tests/ -m "not e2e" --cov=src --cov-report=term-missing -q
if [ -d tests ] && [ -d src ]; then
.venv/bin/pytest tests/ -m "not e2e" --cov=src --cov-report=term-missing -q
else
echo "No tests/ or src/ directory, skipping coverage"
fi
# ── Job 2: 部署 ─────────────────────────────────────
deploy: