TX-17248: Generate Go coverage profile for SonarQube (prep)#265
Open
deathbird wants to merge 1 commit into
Open
TX-17248: Generate Go coverage profile for SonarQube (prep)#265deathbird wants to merge 1 commit into
deathbird wants to merge 1 commit into
Conversation
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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MZU3nmRBDZVe42dZnb4qHY
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to TX-17248: Provide Transifex test coverage metrics
Problem
The CLI has no SonarQube integration, and
go test -cover ./...only prints per-package percentages to stdout — it writes no machine-readable profile. So there is nothing a scanner could ingest, and the repo cannot report coverage.What this PR does (prep)
scripts/tests.sh: generate a coverage profile —go test -covermode=atomic -coverprofile=coverage.out ./...(was-cover).atomickeeps counts correct under concurrent tests;./...writes one merged profile across all packages.sonar-project.properties(new): Go scan config rooted at the module so import paths resolve —sonar.sources=., tests declared via**/*_test.go, andsonar.go.coverage.reportPaths=coverage.out..gitignore: ignorecoverage.out.scripts/tests.cmd(Windows) is left on-coveron purpose — the profile only needs to be produced by the one CI OS that uploads it.What is intentionally deferred
The CI step that runs the scanner is not wired up in this PR. This repo runs on GitHub Actions, and the internal Sonar host
sonar.svc.transifex.netis an in-cluster address that GitHub-hosted runners can't reach. So the host + runner decision is a follow-up:Option A — self-hosted runner → internal Sonar (keeps the CLI on the same server as the rest of the org's licence). Add to the
ubuntu-latesttest job in.github/workflows/test.yml, after tests:(job must run on a self-hosted runner label with network access to the host;
coverage.outmust already exist from the test step)Option B — SonarCloud (works from GitHub-hosted runners; separate server from the internal instance): same action with
SONAR_HOST_URL: https://sonarcloud.io+ asonar.organizationinsonar-project.properties.Generating coverage from a single OS (
ubuntu-latest) is recommended to avoid Windows path-separator differences in the profile.How to test
Verified locally that the new command produces a valid merged Go profile:
Entries are keyed by import path (
github.com/transifex/cli/pkg/assert/assert.go:...), which the Sonar Go analyzer maps to files via thego.modmodule path when the scan runs from the module root (sonar.sources=.). Full-suite generation happens via the existingscripts/tests.shin CI.