`comment.require_changes: coverage_drop` ignores the project status threshold

未关闭 适合新手
#999 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
62/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python, yaml
领域
backend, tooling

调研方向

从 apps/worker/services/notification/notifiers/comment/conditions.py 中的 HasEnoughRequiredChanges._check_coverage_drop 开始,大约在第 147-159 行,这里从 coverage.status.project 读取阈值。修复需要查看具名状态条目(例如 default)内部的值,而不是映射本身。运行评论条件的单元测试,并确认覆盖率下降幅度小于已配置阈值时不再发布评论。

由索引模型根据 Issue 内容生成。

描述

Describe the bug

The pull request comment docs say that coverage_drop "respects project status threshold, if configured (i.e. drop needs to be bigger than the configured threshold for the comment to be posted)". It does not: with a valid threshold configured, a comment is posted on any drop of more than 0.01%.

HasEnoughRequiredChanges._check_coverage_drop (conditions.py#L147-L159) reads the threshold one level too high:

project_status_config = read_yaml_field(
    comparison.comparison.current_yaml, ("coverage", "status", "project"), {}
)
threshold = 0
if isinstance(project_status_config, dict):
    threshold = Decimal(project_status_config.get("threshold", 0))

coverage.status.project is a map of named statuses (user_schema.py#L405-L418), so threshold lives under a status name such as default. project_status_config.get("threshold") therefore always returns the default 0. The shape the unit tests use, {"coverage": {"status": {"project": {"threshold": 10}}}}, is rejected by the validator: Error at ['coverage', 'status', 'project', 'threshold']: must be of ['dict', 'boolean'] type.

To Reproduce

  1. Use this codecov.yml (the validator accepts it and parses the condition to [6]):

    coverage:
      status:
        project:
          default:
            threshold: 0.5%
    comment:
      require_changes: "coverage_drop OR uncovered_patch"
    
  2. On a pull request with no existing Codecov comment and reports for both base and head, upload coverage that lowers project coverage by more than 0.01 but less than 0.5 percentage points, with no uncovered changed lines.

  3. Codecov posts the comment. In umputun/remark42#2390, coverage went from 78.58% to 78.56% (-0.03%), codecov/project passed, codecov/patch reported "Coverage not affected", and the comment was posted.

Expected behavior

No initial comment, because the project coverage drop is below the configured 0.5 percentage-point threshold and no changed lines are uncovered.

主要语言
没有语言数据
星标
52
派生
25
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

codecov/feedback 的其他 Issue

查看 codecov/feedback 的全部 Issue

相似的 Issue

更多 Backend & API Design Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。