From 073121f7caca142da01f006ac0727d11aa705a76 Mon Sep 17 00:00:00 2001 From: cfdaily Date: Sat, 6 Jun 2026 18:43:40 +0800 Subject: [PATCH] fix: test and coverage gracefully skip when tests/ or src/ not exists --- .gitea/workflows/ci.yml | 6 +++++- .gitea/workflows/deploy.yml | 12 ++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 17ed2bc..e3a4857 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -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 替代 diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 827510b..61b1cdf 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -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: