Skip to content

GH-78: Enforce the coverage target and audit resolved dependencies in CI - #132

Merged
magicsunday merged 1 commit into
mainfrom
GH-78
Jul 21, 2026
Merged

GH-78: Enforce the coverage target and audit resolved dependencies in CI#132
magicsunday merged 1 commit into
mainfrom
GH-78

Conversation

@magicsunday

Copy link
Copy Markdown
Owner

Overview

Closes #78. Two CI gaps: the documented "coverage ≥ 90 %" definition of done was never machine-checked, and composer audit ran nowhere (dependency-review only inspects what a PR changes).

Coverage gate

A new coverage job (PHP 8.3, pcov) runs the suite, emits a Clover report, and .github/scripts/coverage-gate.php reads its project-level line metrics and fails the build below the threshold. Single interpreter — line coverage does not vary by PHP version. The threshold (90) is an argument so it lives in one place; a non-numeric or out-of-range threshold, or a missing/unparsable report, exits non-zero so a misconfiguration fails loud rather than silently disabling the gate. Current line coverage is 97.97 %.

Dependency audit

A new composer-audit job in security.yml runs on every push, PR, and the existing weekly cron. This library does not commit composer.lock, so the job resolves fresh against the declared constraints — the set a consumer install produces — and audits that, rather than a lock file that is not shipped.

Maintainer action required

The two new jobs report red on failure but do not block a merge until they are added to main's required status checks. Please add the contexts Coverage gate and Composer audit to branch protection (the existing required set is only build (8.3/8.4/8.5)) — a change this PR cannot make.

Verification

ci:test green (505 tests); the manifest validates; the resolved-set audit reports no advisories; the coverage gate reports 97.97 % ≥ 90 %. The gate script passes PHPStan level max and was verified on every path (pass, below-threshold, non-numeric/out-of-range threshold, missing/malformed report). Reviewed by the workflow, shell, PHP and Codex reviewers; their findings (the --locked-without-a-lockfile break, threshold validation, libxml warning suppression) are folded in.

🤖 Generated with Claude Code

Two CI gaps the issue names.

Coverage was documented as a definition of done ("coverage >= 90 %") but never
machine-checked: the coverage script produced an HTML report nothing read. A new
`coverage` job runs the suite under pcov, emits a Clover report, and a small
gate script (`.github/scripts/coverage-gate.php`) reads its project-level line
metrics and fails the build below the threshold. The gate is a single job on one
interpreter - line coverage does not vary by PHP version - and the threshold
(90) is passed as an argument so the target lives in one place. Current line
coverage is 97.97 %, so the gate passes with headroom while catching a future
regression below 90 %. The gate rejects a non-numeric or out-of-range threshold
and a missing/unparsable report with exit 2, so a misconfiguration fails loud
rather than silently disabling the gate.

The dependency audit ran nowhere. dependency-review only inspects what a pull
request changes, so an advisory published against an existing dependency was
never caught. A new `composer-audit` job in security.yml resolves dependencies
fresh - this library does not commit composer.lock, so it audits the set a
consumer install produces, not a lock file - and runs `composer audit` on every
push and pull request AND on the existing weekly cron.

The gate script is covered by the existing PHPStan-max analysis of
`.github/scripts/` and was verified on every path (pass at 90, below-threshold,
non-numeric and out-of-range thresholds, missing and malformed reports).
AGENTS.md now records that the coverage target is machine-enforced.

Note for the maintainer: the two new jobs report red on failure but do not block
a merge until they are added to the protected branch's required status checks
("Coverage gate", "Composer audit") - a branch-protection change this commit
cannot make.

Verified: the ci:test suite is green (505 tests); the manifest validates; the
resolved-set audit reports no advisories; the coverage gate reports 97.97 %
which clears the 90 % target.
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@magicsunday

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@magicsunday
magicsunday merged commit 7a1e73c into main Jul 21, 2026
17 checks passed
@magicsunday
magicsunday deleted the GH-78 branch July 21, 2026 17:25
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.

CI: add a coverage gate and a composer audit step

1 participant