Golang coverage monorepo doesn't work

Hi, I’m trying to have code coverage for Golang using monorepo, but Sonar doesn’t recognize the tests when the package is in subfolder and not in repository root .

I generate converage.out report, such as

mode: set
comps/golang/main.go:7.23,9.2 1 1
comps/golang/main.go:11.24,13.2 1 0
comps/golang/main.go:15.24,17.2 1 1
comps/golang/main.go:19.13,24.2 4 0

so, even I have this property sonar.go.coverage.reportPaths=/github/workspace/bin/cov.out

Sonar coverage doesn’t work because the package comps/golang is not accessible from repository root, it works if I create the package from repository root, but I can’t because it’s a monorepo

how to tell to SonarCloud to recognize the tests from subfolder and not from repository root?

here is the sonar-project.properties

service_sonar/sonar-project.properties at master · linksoft-dev/service_sonar (github.com)

this is the public repoistory (see sonarcloud complete log)
test · linksoft-dev/service_sonar@f11e1f2 (github.com)

0% coverage

Hey there

It looks like the logs are no longer available :confused: Can you try a fresh run?

Hi, I re run the latest action and set log retention for 10 days

Did you manage to resolve the issue? It look like coverage is now being reported: https://sonarcloud.io/summary/overall?id=linksoft-dev_service_sonar

Hi, the way I mentioned here, if I create go.mod at root and change the coverage.out to the path, it works, it’s an workaround, it should works without that