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

Aperta Adatta ai principianti
#999 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
62/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python, yaml
Ambito
backend, tooling

Direzione di ricerca

Inizia da HasEnoughRequiredChanges._check_coverage_drop in apps/worker/services/notification/notifiers/comment/conditions.py, intorno alle righe 147-159, dove la soglia viene letta da coverage.status.project. La correzione deve guardare dentro le voci di stato con nome, come default, e non nella mappa stessa. Esegui i test unitari per le condizioni del commento e verifica che un calo di copertura inferiore alla soglia configurata non pubblichi più il commento.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Nessun dato sulla lingua
Stelle
52
Fork
25
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di codecov/feedback

Tutte le issue di codecov/feedback

Issue simili

Altre issue su Backend & API Design

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.