Skip to content

Commit ddc46d3

Browse files
committed
ci: enforce codegen sync + raise coverage thresholds from 0%
加两道 CI 卡点,把 SDK 的回归保护从"形同虚设"提到"防得住典型回归"。 开发者改了 `__xxx_async_template.py` 但忘跑 `make codegen`,对应的 `xxx.py` 就和 template 脱节,下次别人跑 codegen 会被覆盖。CI 现在 跑 `make codegen && git diff --exit-code`,发现 diff 直接 fail 并提示 本地补跑 `make codegen` 后提交。 零风险:当前 main 上 `make codegen` 输出零 diff,新 step 立即就能过。 `coverage.yaml` 之前 full / incremental 全设 0,等于不卡。 基于本地实测当前覆盖率(line 90.74% / branch 82.85%)设: - 全量阈值:line 85 / branch 78(留 ~5% buffer 防 CI 抖动误伤) - 增量阈值:line 85 / branch 75(推动新代码自带测试) - directory_overrides: - utils: 90/90(基础设施代码,保持高线) - knowledgebase: 95/90(历史高覆盖) - memory_collection: 80/50(历史短板,不严于现状,先不回退) - conversation_service: 65/60(历史短板,同上) `uv run --python 3.10 --all-extras python scripts/check_coverage.py` 本地跑通 23 项检查全 ✅。 - pyink/isort 格式 check:当前 19 个存量文件不合规(含 `tests/e2e/test_workspace_id.py` 等),需要先 reformat 再加 check。 - ruff/pylint lint check - 多 Python 版本矩阵(目前只跑 3.10) - E2E on CI(需要 Secret 配 AccessKey) Change-Id: I8bd1fb2f3262fe77143d606e5f0ebb9125cf0932 Co-developed-by: Claude <noreply@anthropic.com>
1 parent 333f548 commit ddc46d3

2 files changed

Lines changed: 70 additions & 19 deletions

File tree

.github/workflows/ci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ jobs:
4545
run: |
4646
make mypy-check
4747
48+
# 校验 codegen 产物是否同步:开发者改了 __xxx_async_template.py 必须跑 make codegen
49+
# / Verify codegen output is in sync: editing __xxx_async_template.py requires make codegen
50+
- name: Verify codegen is up-to-date
51+
run: |
52+
make codegen
53+
if ! git diff --exit-code; then
54+
echo "::error::codegen output is out of sync. Run 'make codegen' locally and commit the result." >&2
55+
git status
56+
exit 1
57+
fi
58+
4859
- name: Run tests with coverage
4960
run: |
5061
make coverage

coverage.yaml

Lines changed: 59 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,82 @@
33
#
44
# 注意:文件排除配置已迁移到 pyproject.toml 的 [tool.coverage.*] 部分
55
# Note: File exclusion settings have been moved to [tool.coverage.*] in pyproject.toml
6+
#
7+
# 调整策略 / Calibration strategy:
8+
# - 全量阈值取自当前真实覆盖率(line 90.74% / branch 82.85%)下方约 5% 的 buffer,
9+
# 作为"不回退"闸;既能挡住明显回归,又不会被 CI 抖动误伤。
10+
# - 增量阈值更高一些,推动新增代码自带测试;首次新建文件等极端情况下仍可通过。
11+
# - memory_collection 和 conversation_service 历史覆盖率较低,单独 override
12+
# 到不严于当前现状的水位,等待后续专项补测试再统一上调。
13+
#
14+
# Calibration strategy:
15+
# - Full thresholds sit ~5% below current real coverage (line 90.74% / branch 82.85%)
16+
# to act as a "no regression" gate without flapping on CI noise.
17+
# - Incremental thresholds are higher to drive tests for new code.
18+
# - memory_collection / conversation_service have historically lower coverage;
19+
# their overrides sit no stricter than today and will be tightened in a
20+
# dedicated test-improvement pass later.
621

722
# ============================================================================
823
# 全量代码覆盖率要求
924
# ============================================================================
1025
full:
1126
# 分支覆盖率要求 (百分比)
12-
branch_coverage: 0
27+
branch_coverage: 78
1328
# 行覆盖率要求 (百分比)
14-
line_coverage: 0
29+
line_coverage: 85
1530

1631
# ============================================================================
1732
# 增量代码覆盖率要求 (相对于基准分支的变更代码)
1833
# ============================================================================
1934
incremental:
2035
# 分支覆盖率要求 (百分比)
21-
branch_coverage: 0
36+
branch_coverage: 75
2237
# 行覆盖率要求 (百分比)
23-
line_coverage: 0
38+
line_coverage: 85
2439

2540
# ============================================================================
2641
# 特定目录的覆盖率要求
2742
# 可以为特定目录设置不同的覆盖率阈值
2843
# ============================================================================
2944
directory_overrides:
30-
# 示例:为特定目录设置不同的阈值
31-
agentrun/knowledgebase:
32-
full:
33-
branch_coverage: 0
34-
line_coverage: 0
35-
incremental:
36-
branch_coverage: 0
37-
line_coverage: 0
38-
agentrun/utils:
39-
full:
40-
branch_coverage: 90
41-
line_coverage: 90
42-
incremental:
43-
branch_coverage: 90
44-
line_coverage: 90
45+
# utils 模块要求高覆盖率(基础设施代码)
46+
# / utils module is infrastructure code, requires high coverage
47+
agentrun/utils:
48+
full:
49+
branch_coverage: 90
50+
line_coverage: 90
51+
incremental:
52+
branch_coverage: 90
53+
line_coverage: 90
54+
55+
# knowledgebase 历史保持高覆盖率
56+
# / knowledgebase has historically maintained high coverage
57+
agentrun/knowledgebase:
58+
full:
59+
branch_coverage: 90
60+
line_coverage: 95
61+
incremental:
62+
branch_coverage: 90
63+
line_coverage: 90
64+
65+
# memory_collection 历史 branch 覆盖率较低(56.11%),先放行不回退
66+
# / memory_collection has historically low branch coverage (56.11%); allow
67+
# current state, plan to tighten later
68+
agentrun/memory_collection:
69+
full:
70+
branch_coverage: 50
71+
line_coverage: 80
72+
incremental:
73+
branch_coverage: 75
74+
line_coverage: 85
75+
76+
# conversation_service 历史覆盖率较低(line 70.68% / branch 64.94%)
77+
# / conversation_service has historically lower coverage; allow current state
78+
agentrun/conversation_service:
79+
full:
80+
branch_coverage: 60
81+
line_coverage: 65
82+
incremental:
83+
branch_coverage: 75
84+
line_coverage: 85

0 commit comments

Comments
 (0)