From e8d3da749e85fc25d636ff63291df3ee5594b313 Mon Sep 17 00:00:00 2001 From: Jack Dimas Date: Sun, 19 Jul 2026 20:40:50 +0300 Subject: [PATCH] TX-17248: generate Go coverage profile for SonarQube (prep) Prepare the CLI for test-coverage upload to SonarQube. This repo had no Sonar integration and `go test -cover` only printed to stdout, so there was nothing for a scanner to ingest. - scripts/tests.sh: write a coverage profile (-coverprofile=coverage.out, -covermode=atomic) instead of printing only - sonar-project.properties: Go scan config rooted at the module (key cli, sources=., tests via *_test.go, go.coverage.reportPaths=coverage.out) - .gitignore: ignore coverage.out The CI step that actually runs the scanner is intentionally NOT wired up: the internal Sonar host (sonar.svc.transifex.net) is unreachable from GitHub-hosted runners, so the host + runner choice (self-hosted runner vs SonarCloud) is a follow-up. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01MZU3nmRBDZVe42dZnb4qHY --- .gitignore | 1 + scripts/tests.sh | 6 +++++- sonar-project.properties | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 sonar-project.properties diff --git a/.gitignore b/.gitignore index 9749474..8eb946c 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ cli .DS_Store local_example/ .envrc +coverage.out diff --git a/scripts/tests.sh b/scripts/tests.sh index e60191c..4e2bd87 100755 --- a/scripts/tests.sh +++ b/scripts/tests.sh @@ -1,3 +1,7 @@ #!/bin/sh -go test -cover ./... +# -coverprofile writes a machine-readable profile (coverage.out) for SonarQube +# (sonar.go.coverage.reportPaths); -covermode=atomic keeps counts correct under +# concurrent tests. Profile entries are module-import paths, resolved by the +# scanner from the module root (sonar.sources=.). +go test -covermode=atomic -coverprofile=coverage.out ./... diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..2c76315 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,14 @@ +# SonarQube configuration for the Transifex CLI (Go). +# Scan is run from the module root so the import paths in coverage.out resolve. +# +# NOTE: the CI step that runs the scanner is NOT wired up yet. The internal +# Sonar host (sonar.svc.transifex.net) is unreachable from GitHub-hosted +# runners, so the host + runner choice (self-hosted runner vs SonarCloud) is a +# follow-up. sonar.host.url and the auth token are supplied by that CI step, +# not here. +sonar.projectKey=cli +sonar.sources=. +sonar.tests=. +sonar.test.inclusions=**/*_test.go +sonar.exclusions=**/*_test.go,**/vendor/**,examples/**,build/** +sonar.go.coverage.reportPaths=coverage.out