ci(sonarqube): populate the "Unit Tests" measure via a test-execution report #87

Merged
whitlocktech merged 1 commits from ci/sonar-test-execution-report into main 2026-07-21 06:26:43 +00:00
Member

What & why

Follow-up to #86. On the SonarQube dashboard, Coverage populates (from the LCOV reports) but the "Unit Tests" tile shows -. Those are two independent inputs: the Unit Tests measure is fed by a test-execution report via sonar.testExecutionReportPaths, in SonarQube's Generic Test Execution XML format — which none of Node's built-in reporters (lcov, junit, spec) produce. So the count was never reported.

This adds that missing report:

  • scripts/sonar-test-reporter.mjs — a dependency-free custom node:test reporter that emits the Generic Test Execution XML: repo-root-relative <file path> entries (matching sonar.tests), integer-millisecond durations, XML-escaped names, suites filtered out so the count matches the runner.
  • .gitea/workflows/sonarqube.yml — runs it as a third reporter on both the server and client coverage steps (alongside spec→stdout and lcov→file, all in one node --test invocation).
  • sonar-project.properties — declares sonar.testExecutionReportPaths for both suites.

How it was tested

Ran the exact CI command locally (all three reporters in one invocation):

server: 380 test cases   client: 43 test cases
  • XML validated well-formed by a strict parser (47 files / 380 cases for the server report).
  • <file path> entries come out repo-root-relative (server/test/…, client/test/…), matching sonar.tests.
  • lcov + execution reports generated side by side; node --test exits 0.

After this lands on main (the SonarQube workflow runs on push to main), the next analysis will show 423 unit tests instead of -.

Checklist

  • I have read CONTRIBUTING.md.
  • The change builds and existing tests/checks pass locally.
  • I have added or updated tests/docs where it makes sense.
  • My commits are reasonably scoped with clear messages.

AI-assisted contributions (required)

  • AI tools were used. Tool(s): Claude Code (Opus 4.8). I have reviewed and understand every change, and take responsibility for it. AI-authored commits are marked with a Co-Authored-By trailer.

License

  • I agree that my contribution is licensed under this project's license (GNU GPL v3.0 or later), and I have the right to contribute it.

🤖 Generated with Claude Code

## What & why Follow-up to #86. On the SonarQube dashboard, **Coverage** populates (from the LCOV reports) but the **"Unit Tests" tile shows `-`**. Those are two independent inputs: the Unit Tests measure is fed by a *test-execution report* via `sonar.testExecutionReportPaths`, in SonarQube's **Generic Test Execution XML** format — which none of Node's built-in reporters (`lcov`, `junit`, `spec`) produce. So the count was never reported. This adds that missing report: - **`scripts/sonar-test-reporter.mjs`** — a dependency-free custom `node:test` reporter that emits the Generic Test Execution XML: repo-root-relative `<file path>` entries (matching `sonar.tests`), integer-millisecond `duration`s, XML-escaped names, suites filtered out so the count matches the runner. - **`.gitea/workflows/sonarqube.yml`** — runs it as a third reporter on both the server and client coverage steps (alongside `spec`→stdout and `lcov`→file, all in one `node --test` invocation). - **`sonar-project.properties`** — declares `sonar.testExecutionReportPaths` for both suites. ## How it was tested Ran the exact CI command locally (all three reporters in one invocation): ``` server: 380 test cases client: 43 test cases ``` - XML validated well-formed by a strict parser (47 files / 380 cases for the server report). - `<file path>` entries come out repo-root-relative (`server/test/…`, `client/test/…`), matching `sonar.tests`. - lcov + execution reports generated side by side; `node --test` exits 0. After this lands on `main` (the SonarQube workflow runs on push to `main`), the next analysis will show **423** unit tests instead of `-`. ## Checklist - [x] I have read CONTRIBUTING.md. - [x] The change builds and existing tests/checks pass locally. - [x] I have added or updated tests/docs where it makes sense. - [x] My commits are reasonably scoped with clear messages. ## AI-assisted contributions (required) - [x] AI tools were used. Tool(s): `Claude Code (Opus 4.8)`. I have reviewed and understand every change, and take responsibility for it. AI-authored commits are marked with a `Co-Authored-By` trailer. ## License - [x] I agree that my contribution is licensed under this project's license (**GNU GPL v3.0 or later**), and I have the right to contribute it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
wtclaude added 1 commit 2026-07-21 06:16:43 +00:00
ci(sonarqube): report test execution so the Unit Tests measure populates
All checks were successful
PR Checks / bot-install (pull_request) Successful in 14s
PR Checks / client-build (pull_request) Successful in 23s
PR Checks / server-tests (pull_request) Successful in 9m25s
2f3e8f7df5
The lcov reports only feed SonarQube's Coverage metric — the "Unit Tests" tile
stayed "-" because we never provided a test-execution report (a separate input
via sonar.testExecutionReportPaths, in SonarQube's own Generic Test Execution
XML format, which the lcov/junit reporters don't produce).

Add a dependency-free custom node:test reporter (scripts/sonar-test-reporter.mjs)
that emits that XML — repo-root-relative <file path> entries matching sonar.tests,
integer-ms durations — and wire it into both the server and client coverage runs
in sonarqube.yml, plus sonar.testExecutionReportPaths in sonar-project.properties.

Verified locally: server 380 + client 43 test cases, well-formed XML, all three
reporters (spec/lcov/sonar) coexist in one `node --test` invocation.

Co-Authored-By: Claude <noreply@anthropic.com>
whitlocktech approved these changes 2026-07-21 06:17:08 +00:00
whitlocktech scheduled this pull request to auto merge when all checks succeed 2026-07-21 06:17:12 +00:00
whitlocktech merged commit 4993470fa2 into main 2026-07-21 06:26:43 +00:00
whitlocktech deleted branch ci/sonar-test-execution-report 2026-07-21 06:26:43 +00:00
Sign in to join this conversation.
No description provided.