GitHub
CI system used:
GitHub Actions (ubuntu-latest runner)
Scanner command used:
bash
CopyEdit
dotnet sonarscanner begin \
/k:"mdog-Mcd.McDog.Kpi" \
/d:sonar.token="${{ secrets.SONAR_TOKEN }}" \
/d:sonar.host.url="https://sonarqube.mcd.com/" \
/d:sonar.cs.cobertura.reportsPaths="coverage-report/Cobertura.xml" \
/d:sonar.coverage.exclusions="**/obj/**,**/Migrations/**" \
/d:sonar.sources="Docker/Kpi/src" \
/d:sonar.verbose=true \
/d:sonar.debug=true
dotnet build Docker/Kpi/Mcd.McDog.Kpi.sln --no-restore
dotnet sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
Languages of the repository:
- C# (.NET 8)
- Terraform (with exclusions)
- Python scripts (minimal)
Error observed:
Despite generating valid Cobertura XML and including it in the scanner command, SonarQube reports 0% coverage.
bash
CopyEdit
SonarQube says: “No coverage information found for the files”
However, we verified the coverage report exists and contains:
xml
CopyEdit
<sources>
<source>Docker/Kpi/src</source>
</sources>
<class name="SampleClass" filename="Mcd.McDog.Kpi.Api/Controllers/TestController.cs" ...
<line number="10" hits="1" branch="false"/>
We also normalize paths with:
bash
CopyEdit
sed -i "s|/home/runner/work/${{ github.repository }}/${{ github.repository }}/Docker/Kpi/src/|Docker/Kpi/src/|g" coverage-report/Cobertura.xml
Steps to reproduce:
- GitHub Action runs
dotnet test --collect:"XPlat Code Coverage"
- Generates
.coverage
binary file - Runs ReportGenerator:
bash
CopyEdit
reportgenerator -reports:"TestResults/**/coverage.cobertura.xml" -targetdir:"coverage-report" -reporttypes:"Cobertura"
- Normalize
<source>
paths inCobertura.xml
- Execute SonarQube analysis using dotnet scanner
- SonarQube shows “0% coverage”
Potential workaround:
None found yet.
We confirmed:
coverage-report/Cobertura.xml
exists<source>
matches/d:sonar.sources
<filename>
values point to valid .cs files- GitHub runner sees those
.cs
files under the same paths
Please advise:
- Is there another way to debug why coverage mapping fails?
- Are there additional logs or verbose flags to enable?
- Can a mismatch still occur even if paths appear correct?
Thanks in advance,
Sanjeev