Skip to content

quality.yml: Coverage row silently dropped from every Quality Report — grep -o returns a multi-line TOTAL_STMTS #486

Description

@rubenvdlinde

The Coverage row is silently missing from every Quality Report

Found while diagnosing an unrelated E2E failure on softwarecatalog
(ConductionNL/softwarecatalog#539). Present in both the push and the
pull_request run of sha 68202d5b, and there is no reason it would be
repo-specific.

In .github/workflows/quality.yml, the report step does roughly:

TOTAL_STMTS=$(grep -oPm1 'statements="\K[0-9]+' coverage/clover.xml || echo "0")
...
[ "$TOTAL_STMTS" -gt 0 ] && ...

-m1 stops after the first matching line, but -o prints every match on
that line
. clover.xml carries more than one statements="…" attribute on the
same line, so TOTAL_STMTS is multi-line — 512\n0 in the observed run.

The comparison then errors and the Coverage line is dropped from the report:

/home/runner/work/_temp/….sh: line 186: [: 512
0: integer expression expected

Why this matters more than it looks

The job does not fail. The report renders, every other row is present, and
the only trace is one [: integer expression expected line buried in the log.
A coverage number that is never computed looks exactly like a coverage number
that had nothing to report — this is a measurement that quietly does not happen.

Suggested fix

Take the first match only, and make the guard robust to an empty value:

TOTAL_STMTS=$(grep -oPm1 'statements="\K[0-9]+' coverage/clover.xml | head -n1)
TOTAL_STMTS=${TOTAL_STMTS:-0}

⚠️ Worth checking at the same time whether the first match on that line is
actually the project-level total rather than a per-file figure — if it is not,
head -n1 fixes the crash while still reporting the wrong number, which is the
worse outcome. An xmllint --xpath read of /coverage/project/metrics/@statements
would be unambiguous.

Not verified by me

I did not run this fix; I only read the log and the script. Flagging it so
whoever owns the shared quality pipeline can confirm against a real
clover.xml.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions