ci(coverage): integrate Codecov for backend coverage reporting - #168
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
There was a problem hiding this comment.
The coverage-comment path is broken for forked PR runs as written: the workflow only grants pull-requests: write, but the script uses github.rest.issues.* and needs write access to issues/comments. On pull_request from a fork, the token is read-only anyway, so this comment/update step will fail for the exact PR type this workflow is meant to support.
|
@fennoai 帮我看看有什么需要改动的吗? |
Review Result我看了固定范围
其它小点: 验证情况:已检查固定 SHA diff、确认 |
6e4f971 to
63667e8
Compare
相关已修改。 |
- Add pytest-cov>=5.0 to dev dependencies - Add [tool.pytest.ini_options] with --cov=packages --cov-report=term-missing - Pytest step: add --cov-report=xml and --cov-report=html flags - Upload HTML coverage report as Artifact (30-day retention) - PR auto-comment with line/branch coverage summary via github-script - Update existing comment instead of creating duplicates - Add pull-requests: write permission for PR comments Refs: 1024XEngineer#167
- Move PR comment from backend.yml to new coverage-comment.yml - Use workflow_run trigger to get write permissions on fork PRs - Backend CI uploads coverage.xml as artifact (1-day retention) - Coverage Comment workflow downloads artifact and posts PR comment - Fixes 'Resource not accessible by integration' 403 error Refs: 1024XEngineer#167
github.rest.issues.listComments/updateComment/createComment requires issues:write, not just pull-requests:write. Refs: 1024XEngineer#167
- Regenerate uv.lock to include pytest-cov (fixes uv sync --frozen) - Use workflow_run.pull_requests[0].number for PR lookup (fixes fork PR) - Merge download/parse/comment into single step (fixes artifact-not-found) - Remove emoji from coverage comment Refs: 1024XEngineer#167
63667e8 to
5402155
Compare
|
结论
如果目标是统一用 Codecov,下一步应在 |
这个貌似需要拿到codecov的key还是什么来着,需要放到setting中。 |
结论
你记得基本正确:通常需要把 Codecov token 配置到仓库的 GitHub Actions Secret,但要分情况:
另外,Codecov 不会自动覆盖前端。当前前端 CI 只是执行
所以当前建议是:可以迁移 Codecov,但需要仓库维护者处理 token / fork 策略;本 PR 当前只覆盖后端 coverage,尚未覆盖前端 coverage。 |
|
如果可以,尽量用 Codecov?现在的版本看上去是自己造了个类似的轮子 |
好的 |
- Add codecov/codecov-action@v5 to backend.yml for coverage upload - Remove coverage-comment.yml (superseded by Codecov native PR comments) - Add codecov.yml with informational status and backend flag config Refs: 1024XEngineer#167
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
补充一点:#193 前端上传时带了 |
|
已删除 HTML 报告上传步骤。既然已配置 Codecov,HTML artifact 不再需要,Codecov 提供更好的覆盖率可视化和趋势分析。 |
- Remove HTML coverage report artifact step (Codecov replaces it) - Remove --cov-report=html:htmlcov from pytest command - Add frontend flag to codecov.yml comment config
|
已在 codecov.yml 中添加 frontend flag 配置: comment:
flags:
backend:
paths:
- backend/
frontend:
paths:
- frontend/PR #193 前端覆盖率上传时带了 |
|
概述
为后端测试接入 Codecov 覆盖率上传,替换原有自造的 GitHub Actions PR 评论方案。
改动清单
backend/pyproject.tomlpytest-cov>=5.0依赖 + pytest 配置.github/workflows/backend.yml.github/workflows/coverage-comment.ymlcodecov.yml实现细节
backend.yml
coverage.xml) 和 HTML 报告codecov/codecov-action@v5上传覆盖率数据,flag 设为backendcoverage-xmlartifact 和 PR 评论机制codecov.yml
informational(不阻塞 PR 合并)backend/路径关联
验证