Skip to content

ci: enforce patch coverage of changed lines - #378

Merged
TheWitness merged 2 commits into
developfrom
ci/enforce-patch-coverage
Sep 29, 2026
Merged

TheWitness merged 2 commits into
developfrom
ci/enforce-patch-coverage

Conversation

@TheWitness

Copy link
Copy Markdown
Member

What

Brings this plugin's CI in line with plugin_thold by enforcing patch
coverage
— coverage of the production PHP lines a pull request actually
changes — and cleans up an inert env var.

Changes:

  • Add tests/bin/patch-coverage.php (mirrors plugin_thold).
  • Add an Enforce coverage of changed lines CI step, gated to
    pull_request events, that fails when production lines a PR adds/modifies
    are left uncovered by the Pest suite.
  • Set fetch-depth: 0 on the plugin checkout so the gate can diff against
    the PR base commit.
  • Remove COMPOSER_ROOT_VERSION: 1.3.0-dev from the Pest step. It only
    influences Composer root-version detection, which does not run in that
    step, so it was inert.

Why

Whole-file coverage is not meaningful for a Cacti plugin: most code only
runs inside a live Cacti, so the repository figure sits near zero regardless
of test quality. What is enforceable — and what a reviewer cares about — is
that the lines a change introduces are exercised. This is the same gate
plugin_thold already uses; this PR is part of harmonizing it across the
plugin fleet.

Notes

  • The gate only runs on pull requests. On this PR it has no production PHP
    lines to measure (only workflow YAML and the tests/ helper changed), so
    it reports "no measured lines changed" and passes.
  • patch-coverage.php's $unmeasured_allowlist starts empty; entry points
    that cannot be loaded into the isolated unit process can be added there
    per repo, each with a one-line justification, as the need arises.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Renamed PHP files can bypass the gate, while edits to production files excluded from Clover can fail it regardless of their tests.

Review effort: Balanced
Findings: None

What changed in this PR

This PR adds a changed-line coverage gate to the Syslog plugin’s pull-request CI, following the approach used by plugin_thold.

Changes:

  • Add a helper that compares changed PHP lines with Clover coverage.
  • Run the gate on pull requests, fetch the base history, and remove an inert Composer environment variable.
File Description
tests/​bin/​patch-coverage.php Calculates coverage for changed production PHP lines.
.github/​workflows/​plugin-ci-workflow.yml Adds the pull-request gate and fetches the history it needs.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Adds tests/bin/patch-coverage.php and an "Enforce coverage of changed
lines" CI step (pull_request only) that fails when production PHP lines a
PR changes are left uncovered, mirroring plugin_thold. Whole-file
coverage is not meaningful for a Cacti plugin (most code only runs inside
a live Cacti), so the gate measures only the lines a change adds.

Also sets fetch-depth: 0 on the plugin checkout so the gate can diff
against the PR base, and removes the inert COMPOSER_ROOT_VERSION env from
the Pest step (it only affects composer root-version detection, which does
not run in that step).
@TheWitness
TheWitness force-pushed the ci/enforce-patch-coverage branch from 2924ba4 to 335cfd2 Compare September 29, 2026 18:55
@TheWitness
TheWitness merged commit 059fc70 into develop Sep 29, 2026
7 checks passed
@TheWitness
TheWitness requested a review from xmacan September 29, 2026 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants