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

Đang mở Phù hợp với người mới
#999 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
62/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python, yaml
Lĩnh vực
backend, tooling

Hướng nghiên cứu

Bắt đầu từ HasEnoughRequiredChanges._check_coverage_drop trong apps/worker/services/notification/notifiers/comment/conditions.py, khoảng dòng 147-159, nơi ngưỡng được đọc từ coverage.status.project. Bản sửa cần xem bên trong các mục trạng thái có tên, như default, chứ không phải bản thân map. Chạy các unit test cho điều kiện của comment và kiểm tra rằng mức giảm coverage nhỏ hơn ngưỡng đã cấu hình không còn đăng comment nữa.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Không có dữ liệu ngôn ngữ
Star
52
Fork
25
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của codecov/feedback

Tất cả issue của codecov/feedback

Issue tương tự

Thêm issue về Backend & API Design

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.