Skip to content

feat(ci): changed-line coverage on pull requests (diff-cover) #850

Closed

Description

@dan-petty

Context & Rationale

Coverage is gated only in total: fail_under = 90 (pyproject.toml:113), with no branch coverage. The total sits at 90.4-91%, so an untested new function inside a well-covered module passes every gate.

The data already exists and nothing reads it:

  • CI writes .data/coverage.xml (ci.yml:97, pyproject.toml:125).
  • Both rulesets carry a code_coverage rule (minimum 90, maximum drop 5) that nothing feeds.

Matching symbols to test names does not work here. 694 of 2,754 public symbols are never named in a test, mostly Typer commands tested through CliRunner. An exemption marker would also collide with #602.

This item is docs/ROADMAP.md:1010 rescoped. Per :1013, the local gate has no reliable PR base on release/**.

Scope & Deliverables

  • Deliverable:
    • Add diff-cover (10.6.0, 2026-09-22, Python 3.10-3.14) to the dev group.
    • In the Tests & Coverage job, for pull_request events only:
      • fetch the base ref with enough history to find the merge base;
      • after pytest, run diff-cover .data/coverage.xml --compare-branch=origin/<base ref>, with the ref passed through env;
      • write the result to $GITHUB_STEP_SUMMARY, and list any added pragma: no cover lines.
    • The step is advisory at first, with no --fail-under. The task file records a backtest over the last 10 merged PRs and the threshold at which the step becomes blocking. That threshold lives as a constant in config/constants.py.
    • Mark ROADMAP.md:1010 rescoped. Its vanished-test report stays for triage.
  • Acceptance criteria:
    • On a PR into release/**, the summary shows coverage measured against that release branch.
    • uv run devops ci is unchanged.
    • A test parses ci.yml and asserts that the step runs only on pull_request, uses the base ref, and has no --fail-under while it is advisory.
    • actionlint, uv lock --check and uv audit pass.
    • The step adds under 15 s to the job.
  • Key questions:
    • Should we rely on GitHub's native rule instead? (proposed) No: use diff-cover, and remove the native rule unless something feeds it.
    • When does the step become blocking? (proposed) When the backtest shows that fewer than 1 in 10 PRs would fail.
  • Constraint:
    • Never part of the pre-push gate.
    • Coordinate the ci.yml edits with the CI-parity item.

Strategic Alignment

  • Milestone: Backlog
  • Depends on: none

Owner decisions (2026-10-01)

From the agentic quality assessment (https://claude.ai/artifact/K7S7AkKJymFydhjwexigiN), decided by the owner. These replace any matching proposed answer above.

  • D4, the tool. Use diff-cover in the CI test job, reading the coverage.xml CI already writes, against the PR's own release/** base. It stays advisory until a 10-PR backtest picks a threshold, then blocks at the fail_under value. Remove the native code_coverage ruleset rule unless something feeds it, because a rule that is configured but inert looks like enforcement.

Activity

  1. added
    type/feature
    scope/github
    priority/p2-medium
    on Oct 1, 2026
  2. added
    scope/ci
    on Oct 2, 2026
  3. added this to the v0.2.32 milestone on Oct 8, 2026
  4. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    Placed in v0.2.32 on 2026-10-08 at the owner's request ("Populate 10 security and ci issues into each v0.2.30, v0.2.31, and v0.2.32 milestone"). This is a person's placement. Release theme: URLs and host keys read by the library that dials, ollama hardening, and pull-request test-quality tooling. Position 7 of 10 in the release's planned merge order. Its board Status is set to Ready, so the release-start fill keeps it.

  5. dan-petty-bot commented on Oct 9, 2026

    @dan-petty-bot
    Collaborator

    What changed

    #1511, merged into release/v0.2.32 as cc3bae8.

    Summary

    • On pull requests, the Tests & Coverage job runs a new advisory Changed-Line Coverage step after the gate step. It runs diff-cover 10.6.0 over the .data/coverage.xml the gate already writes, against the pull request's own base branch (origin/${BASE_REF}, with BASE_REF passed through env). The report goes to the job summary, followed by any pragma: no cover lines the pull request adds under src, with their file names. The checkout now fetches full history (fetch-depth: 0) so the merge base is always found.
    • The step is advisory: it has no --fail-under and is not a check row. No file under src/ changes, so uv run devops ci and the pre-push gate are unchanged.
    • diff-cover==10.6.0 is added to the dev group. uv.lock adds only diff-cover 10.6.0 and chardet 7.6.0.
    • tests/test_ci.py adds a test that parses ci.yml and checks the step's shape: it runs only on pull requests, takes the base ref through env, has no --fail-under and no ${{ in its script, the checkout has full history, and no check row runs diff-cover. The step also goes on the CI parity allowlist.
    • RELEASE_CYCLE.md (Step 3 and the CI note), changelog.d/850.md and the task file are updated.

    Backtest (last 10 merged release/** PRs that change src, measured at each squash commit): #1488 92.4%, #1487 79.7%, #1484 70.4%, #1483 89.3%, #1482 n/a, #1481 97.0%, #1480 87.0%, #1479 78.3%, #1477 n/a, #1476 100%. Five of ten fall below 90. The D4 rule says to block only…

    7 file(s) changed.

    How it was verified

    Check runs at 67385fc:

    • Prune PR DevContainer Images: pass
    • CodeQL: pass
    • Tests & Coverage: pass
    • Static Analysis: pass
    • Analyze (actions): pass
    • Analyze (python): pass
    • DevContainer Image: skipping
    • Service Image: skipping
    • Dependency Freshness: skipping

    Acceptance Criteria of docs/agent/tasks/task-850-changed-line-coverage-on-pull-requests.md:

    • On a pull request into release/**, the summary measures coverage against that release branch. The step runs diff-cover with --compare-branch="origin/${BASE_REF}", and BASE_REF is github.base_ref. Run locally under bash --noprofile --norc -eo pipefail with BASE_REF=release/v0.2.32, the step's script wrote a summary headed Diff: origin/release/v0.2.32...HEAD, and it listed an added pragma: no cover line under its file name.
    • uv run devops ci is unchanged: no src file changes, and no check row runs diff-cover.
    • test_changed_line_coverage_step_is_advisory_on_pull_requests in tests/test_ci.py parses ci.yml and asserts that the step follows the gate step, runs only on pull_request, takes the base ref through env, reads .data/coverage.xml, writes the summary and the pragma list, and has no --fail-under and no ${{ in its script. It also asserts that the checkout fetches full history and that no check row runs diff-cover.
    • The CI parity check (_validate_ci_workflow_parity) allowlists the step as an advisory report that is never a check row.
    • actionlint (with shellcheck), uv lock --check and uv audit pass.
    • The step adds under 15 s. diff-cover took 0-3 s per commit in the backtest, and the whole script ran in under 1 s locally.
    • Pending a person: the pull request's Tests & Coverage run summary shows Diff: origin/release/v0.2.32...HEAD, followed by the "Added pragma: no cover lines" section.
      • gh pr checks <pr>, then open the Tests & Coverage run's Summary page (gh run view <run-id> --web).
    • Pending a person: the step takes under 15 s on GitHub.
      • gh api repos/dan-petty/devops-cli/actions/jobs/<job-id> --jq '.steps[]|select(.name=="Changed-Line Coverage")|[.started_at,.completed_at]'
    • Pending a person (owner settings, the same step chore(github): required CI checks bind merges into release and main, and ADR 0004 records the verification policy #842 already lists as "without code_coverage"): remove the inert code_coverage rule from rulesets 21466414 and 23059172, since nothing feeds it.
      • gh api repos/dan-petty/devops-cli/rulesets/<id> --jq '{name,target,enforcement,conditions,bypass_actors,rules:[.rules[]|select(.type!="code_coverage")]}' > /tmp/rs.json && gh api -X PUT repos/dan-petty/devops-cli/rulesets/<id> --input /tmp/rs.json
  6. added a commit that references this issue on Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p2-mediumscope/ciscope/githubtype/feature

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions