ci(sonarqube): generate and report server test coverage #85
Reference in New Issue
Block a user
No description provided.
Delete Branch "ci/sonar-test-coverage"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
SonarQube reports 0% test coverage for
runic-gateway-websiteeven though the server has a fullnode --testsuite.Root cause is two gaps working together:
sonarqube.ymlnever runs the tests or produces a coverage report. The job just checks out the repo and runssonarqube-scan-action. The Sonar scanner does static analysis only — it does not executenode --test, so it has no coverage data to report.sonar-project.propertiesdefined nosonar.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-inlcovcoverage 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 LCOVSF:paths are emitted asserver/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: addsonar.javascript.lcov.reportPaths=server/coverage/lcov.infoand excludeserver/coverage/**from sources..gitignore: ignore the generatedserver/coverage/.Verification
Ran the exact coverage command locally: 122 source files instrumented, ~63% overall line coverage, valid LCOV written to
server/coverage/lcov.infowith repo-root-relativeSF:paths. On the Linux runner these are forward-slashed and matchsonar.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