Require coverage diagnostics before badge gate results
Dandaedre/agent-tasks/pipeline/head This commit looks good Details

This commit is contained in:
Dandaedre 2026-10-05 00:59:16 +02:00
parent 22a2024251
commit 9d58d1b78c
1 changed files with 48 additions and 5 deletions

View File

@ -76,13 +76,44 @@ After every required test stage succeeds, create:
coverage/.tests-passed-${BUILD_NUMBER}
```
After coverage succeeds, extract and validate the overall percentage from a temporary machine-readable summary, render `coverage/coverage.svg`, delete the summary, and create:
Separate coverage measurement from the pass/fail decision. Always display the
actual measured line coverage and required floor in the CI console before
reporting success or failing the coverage stage, for example:
```text
Line coverage: 76.42%; required minimum: 80.00%
Coverage gate: FAIL (below required minimum)
```
Run coverage once and retain its exit status while processing its temporary
machine-readable summary. Ensure a below-threshold run still produces that
summary: if the tool cannot do so with its built-in threshold enabled, generate
the report first and enforce the same floor explicitly afterward. Do not let
shell fail-fast behavior or Jenkins' default `sh` failure handling abort before
printing diagnostics; capture the status explicitly and propagate failure after
reporting. Do not swallow errors with `|| true` or lose them through a logging
pipeline.
For a complete, valid report from the current build, extract and validate the
overall percentage, print it alongside the floor, render `coverage/coverage.svg`,
and create the following marker even if the measured coverage is below the floor:
```text
coverage/.coverage-ready-${BUILD_NUMBER}
```
Do not create either marker early.
The coverage-ready marker means a fresh, valid measurement and badge are ready;
it does not mean the coverage gate passed. Compare the unrounded measurement
against the floor, then print an explicit PASS or FAIL and fail the stage on a
threshold violation or any test, tool, parsing, or rendering error. Badge
rounding must not affect the gate. Retain the original tool failure diagnostics
and exit status in the console even if a report is available.
If coverage cannot be measured, print `Line coverage: unavailable`, the required
floor, and the concrete reason before failing. Never fabricate a percentage or
use a stale or partial report. Delete temporary summaries only after diagnostics
and badge processing; cleanup must also remove them on failure. Do not create
either marker before its own prerequisites are satisfied.
## Jenkins cleanup, archival, and publication
@ -96,7 +127,12 @@ Finalize badges in `post { cleanup { ... } }`, which runs on both successful and
6. Archive exactly those three SVGs with fingerprinting and `allowEmptyArchive: false`.
7. On the resolved default branch only, publish all three badges.
Publication must run from cleanup rather than only from the success handler: a failed default-branch build must replace stale green status with `failing` and stale measured coverage with neutral `-%`.
Publication must run from cleanup rather than only from the success handler.
On a failed default-branch build, publish the current test status according to
the test marker and preserve fresh measured coverage, including a value below
the floor. Publish neutral `-%` only when no valid current-build coverage badge
is ready. Never replace a valid measurement with neutral coverage merely
because the coverage gate or a later stage failed.
Branches other than the default branch generate and archive their badges but do not modify the public default-branch files. Confirm that the Jenkins job type actually supplies the branch variable used by the predicate.
@ -122,7 +158,7 @@ The script must:
Place the three live public badge references directly below the README title and require each resolved URL exactly once. Remove tracked generated badges and obsolete status snapshots.
Document the exact local coverage command, enforced floor, authoritative version source, temporary summary, three archived files, publication directory, and public URLs. Update Jenkins success and failure summaries to mention tests, coverage, and badge generation accurately.
Document the exact local coverage command, enforced floor, authoritative version source, temporary summary, three archived files, publication directory, and public URLs. Update Jenkins success and failure summaries to mention tests, coverage, and badge generation accurately. Both summaries must include the measured coverage and floor, or explicitly state why coverage is unavailable.
If server configuration is outside the repository, only record that public assets should be mounted read-only, directory listing disabled, SVG served with a restrictive content security policy, and mutable URLs revalidated or given a short cache lifetime.
@ -131,7 +167,14 @@ If server configuration is outside the repository, only record that public asset
Before reporting repository implementation complete:
1. Run the repository’s formatting, check/build, test, lint, and documentation gates.
2. Run the exact coverage command and confirm the enforced floor.
2. Run the exact coverage command and confirm the enforced floor. Exercise
above-floor, exactly-at-floor, below-floor, tool/test failure, and
missing/invalid report cases using fixtures or stubs where practical.
Verify that the measurement and floor (or an explicit unavailable reason)
appear before the stage's PASS/FAIL decision, errors still fail the job,
and a valid below-floor badge survives cleanup and is selected for
archival/publication. Confirm an unavailable measurement produces neutral
coverage and never reuses a previous build's value.
3. Exercise default and customized badge rendering, normal and long versions, passing and failing tests, all coverage color bands, neutral coverage, custom sizing, and XML-sensitive text.
4. Confirm invalid kinds, options, values, dimensions, and colors fail without replacing a valid output.
5. Parse every generated SVG as XML.