Skip to content

Add coverage-check and print-section scripts - #42

Merged
hugo-goncalves-kununu merged 1 commit into
mainfrom
add-coverage-check
Sep 15, 2026
Merged

hugo-goncalves-kununu merged 1 commit into
mainfrom
add-coverage-check

Conversation

@hugo-goncalves-kununu

@hugo-goncalves-kununu hugo-goncalves-kununu commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

Description

The objective of this PR is to add two helper executables to the package, coverage-check and print-section, and to use both in this repository's own ci script.

Both are shipped through the bin entry in composer.json, so consuming projects get them in vendor/bin alongside code-tools and php-in-k8s.

Details

  • bin/coverage-check
    • Reads a Cobertura XML report and compares its line coverage (lines-covered over lines-valid) against a minimum percentage.
    • Prints the result in green or red, and exits non-zero when the coverage is below the minimum, so it works as a gate rather than as a report.
    • Validates both arguments and the report itself, reporting each failure on STDERR with exit code 1.
  • bin/print-section
    • Prints a centered section header, 80 characters wide by default, to separate the steps of a multi-tool script.
    • The label is measured in UTF-8 characters, so multibyte labels stay centered.
    • It is generic and knows nothing about any tool, so it is equally usable from a shell script or a CI job.
  • Both scripts
  • composer.json
    • test-coverage now also writes a Cobertura report, next to the existing Clover, JUnit and HTML ones.
    • New coverage-check script, pinned at the 95% minimum that CONTRIBUTING.md already asks for.
    • ci prints a header before each of its steps and ends with the coverage check.
    • ext-simplexml is declared, since coverage-check parses the report with it.
  • psalm.xml.dist and composer-dependency-analyser.php
    • Psalm ignores bin/, and the dependency analyser ignores the unused-dependency report for ext-simplexml, which is only used from bin/.
  • Documentation
    • New docs/CoverageCheck/ and docs/PrintSection/ pages, one folder per tool, following the rest of docs/.
    • Indexed from README.md, and referenced from CONTRIBUTING.md and AGENTS.md.

Introduce two executables, both shipped to the consumer's vendor/bin:

- bin/coverage-check
  - Reads a Cobertura XML report, compares its line coverage against a
    minimum percentage and exits non-zero when it falls below it.
- bin/print-section
  - Prints a centered section header, so the output of the individual
    tools in a multi-step script stays easy to tell apart.

Wire both into composer.json:

- PHPUnit now also writes a Cobertura report next to the existing ones.
- The ci script prints a header before each step and ends with a new
  coverage-check script pinned at 95%.
- ext-simplexml is declared, as coverage-check parses the report with it.
- psalm.xml.dist ignores bin/, and composer-dependency-analyser.php
  ignores the unused-dependency report for ext-simplexml.

Document both tools under docs/, one folder per tool, and index them
from README.md, CONTRIBUTING.md and AGENTS.md.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@hugo-goncalves-kununu
hugo-goncalves-kununu marked this pull request as ready for review September 15, 2026 08:50
@hugo-goncalves-kununu
hugo-goncalves-kununu requested a review from a team as a code owner September 15, 2026 08:50
@hugo-goncalves-kununu
hugo-goncalves-kununu merged commit d481580 into main Sep 15, 2026
5 checks passed
@hugo-goncalves-kununu
hugo-goncalves-kununu deleted the add-coverage-check branch September 15, 2026 09:10
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.

2 participants