We are using sonarqube 10.5.1 enterprise and have a repository that has both C# .net 4 code and angular 16 code in it. Is there a way in a windows-latest runner in github actions, to upload the code coverage for both C# and angular at the same time?
You should just need to include both parameters for importing test coverage (sonar.javascript.lcov.reportPaths
and whatever the appropriate .NET parameter is) when executing your analysis command.
I have verified the opencover.xml ang lcov.info files exist where I am pointing the scanner and it appears that they are processing the files to some extent. In sonarqube, I am seeing no coverage statistics at all.
..sonar\scanner\dotnet-sonarscanner begin /k:“omitted” /d:sonar.cs.opencover.reportsPaths=/TestResults//*.opencover.xml /d:sonar.token=“${{ secrets.SONAR_TOKEN }}” /d:sonar.host.url=“${{ secrets.SONAR_HOST_URL }}” /d:sonar.javascript.lcov.reportPaths=Source/app.AngularUI/coverage/karma-coverage/lcov.info
Any ideas on what to try?
What do the logs say about the import of code coverage?
I see the lcov file is being picked up an it is erroring:
INFO: Analysing [coverage\karma-coverage\lcov.info]
[5254]WARN: Could not resolve 3 file paths in [coverage\karma-coverage\lcov.info]
[5255]WARN: First unresolved path: src\app\common\component\welcome-back-modal\welcome-back-modal.component.ts (Run in DEBUG mode to get full list of unresolved paths)
It appears that the scanner is producing a path that is not exactly what the actual path is on the server. Is there a way to have the scanner start at a certain path for the lcov file?
I am scratching my head on this one. The sonar scanner appears to be loading the lcov file and processing through at least a part of the file and then further down the log I get this information:
INFO: Sensor JavaScript/TypeScript Coverage [javascript]
INFO: No LCOV files were found using coverage\karma-coverage\lcov.info
WARN: No coverage information will be saved because all LCOV files cannot be found.
INFO: Sensor JavaScript/TypeScript Coverage [javascript] (done) | time=30ms
What am I missing? I am not seeing any obvious messages that files are missing.
Hey @phil.shaff
Sorry for the late response.
The Sensor JavaScript/TypeScript Coverage [javascript]
runs a few times during an analysis. Once for the project overall, and once for each project (think .csproj
) in a solution. These are also known as modules (and it’s easier to call them modules in this case, so as not to confuse it with the SonarQube project).
Because modules inherit properties set at the project-level, they end up being executed for each module. You can usually safely ignore this, but since it’s causing issues, I think you would do well to try two things:
- Set
sonar.javascript.lcov.reportPaths
for the specific module inside the relevant sub-project’s.csproj
file - Continue to only configure the project-level
sonar.javascript.lcov.reportPaths
, but ensure that absolute paths (or at least, paths reaching back to the root project) are included in the.lcov
file instead of starting at the module root