ci(sonarqube): generate and report server test coverage #85

Merged
whitlocktech merged 1 commits from ci/sonar-test-coverage into main 2026-07-21 04:57:08 +00:00
Member

Problem

SonarQube reports 0% test coverage for runic-gateway-website even though the server has a full node --test suite.

Root cause is two gaps working together:

  1. sonarqube.yml never runs the tests or produces a coverage report. The job just checks out the repo and runs sonarqube-scan-action. The Sonar scanner does static analysis only — it does not execute node --test, so it has no coverage data to report.
  2. sonar-project.properties defined no sonar.javascript.lcov.reportPaths — even if a report existed, the scanner wasn't told where to find it.

Fix

  • sonarqube.yml: before the scan, set up Node 22 (required for Node's built-in lcov coverage reporter), npm ci --prefix server, and generate an LCOV report with Node's built-in --experimental-test-coverage. The step runs from the repo root (not --prefix server) so the LCOV SF: paths are emitted as server/src/..., which the scanner resolves against the project base dir. The server tests stub their models and point the DB pool at a dead port, so no MariaDB is required.
  • sonar-project.properties: add sonar.javascript.lcov.reportPaths=server/coverage/lcov.info and exclude server/coverage/** from sources.
  • .gitignore: ignore the generated server/coverage/.

Verification

Ran the exact coverage command locally: 122 source files instrumented, ~63% overall line coverage, valid LCOV written to server/coverage/lcov.info with repo-root-relative SF: paths. On the Linux runner these are forward-slashed and match sonar.sources=server/src.

The workflow remains non-blocking (push-to-main / dashboard only); it does not gate PRs.

AI disclosure

Authored with assistance from Claude (Claude Code).

🤖 Generated with Claude Code

## Problem SonarQube reports **0% test coverage** for `runic-gateway-website` even though the server has a full `node --test` suite. Root cause is two gaps working together: 1. **`sonarqube.yml` never runs the tests or produces a coverage report.** The job just checks out the repo and runs `sonarqube-scan-action`. The Sonar scanner does *static* analysis only — it does not execute `node --test`, so it has no coverage data to report. 2. **`sonar-project.properties` defined no `sonar.javascript.lcov.reportPaths`** — even if a report existed, the scanner wasn't told where to find it. ## Fix - **`sonarqube.yml`**: before the scan, set up Node 22 (required for Node's built-in `lcov` coverage reporter), `npm ci --prefix server`, and generate an LCOV report with Node's built-in `--experimental-test-coverage`. The step runs from the **repo root** (not `--prefix server`) so the LCOV `SF:` paths are emitted as `server/src/...`, which the scanner resolves against the project base dir. The server tests stub their models and point the DB pool at a dead port, so no MariaDB is required. - **`sonar-project.properties`**: add `sonar.javascript.lcov.reportPaths=server/coverage/lcov.info` and exclude `server/coverage/**` from sources. - **`.gitignore`**: ignore the generated `server/coverage/`. ## Verification Ran the exact coverage command locally: 122 source files instrumented, ~63% overall line coverage, valid LCOV written to `server/coverage/lcov.info` with repo-root-relative `SF:` paths. On the Linux runner these are forward-slashed and match `sonar.sources=server/src`. The workflow remains non-blocking (push-to-main / dashboard only); it does not gate PRs. ## AI disclosure Authored with assistance from Claude (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
wtclaude added 1 commit 2026-07-21 04:47:08 +00:00
ci(sonarqube): generate and report server test coverage
All checks were successful
PR Checks / bot-install (pull_request) Successful in 18s
PR Checks / server-tests (pull_request) Successful in 44s
PR Checks / client-build (pull_request) Successful in 9m24s
e515fc0c9d
SonarQube reported 0% coverage because the analysis workflow never ran
the test suite — the scanner does static analysis only and was handed no
coverage report, and sonar-project.properties defined no report path.

Generate an LCOV report in sonarqube.yml before the scan using Node's
built-in test coverage (run from the repo root so SF: paths are
server/src/... and resolve against the project base dir), and point
the scanner at it via sonar.javascript.lcov.reportPaths. Node's lcov
coverage reporter needs Node >= 22, so the coverage job pins node 22.

Co-Authored-By: Claude <noreply@anthropic.com>
whitlocktech approved these changes 2026-07-21 04:47:28 +00:00
whitlocktech scheduled this pull request to auto merge when all checks succeed 2026-07-21 04:47:32 +00:00
whitlocktech merged commit b474303052 into main 2026-07-21 04:57:08 +00:00
whitlocktech deleted branch ci/sonar-test-coverage 2026-07-21 04:57:08 +00:00
Sign in to join this conversation.
No description provided.