I would like to reach out to community again regarding the sonar scan analysis for Carma-Platform, there are gcov files but it is not moving to output directory which was working previously. Could you please help me with what I’m missing here. Thank you!
It looks like SonarCloud is still behaving as expected – parsing the .gcov files that it has access to. I would suggest reviewing the script that generates/moves these files, as @necto suggested before.
Specifically you probably want to look at what changed between November 3rd (when coverage was still reported) and December 14th.
Once the coverage files are in the right place, SonarCloud should do its job and read them. Up to that point – SonarCloud isn’t involved.
Hi Colin,
sorry of the late response, I don’t see any major changes except the below CI jobs restrict changes, I was trying to update the Gcov version to 5.0 and see if it publishes any reports to sonar cloud.
File changed on NOV 1st 2021(make_with_coverage.bash):
from this:
colcon build --cmake-args -DCMAKE_CXX_FLAGS=“${COVERAGE_FLAGS}” -DCMAKE_C_FLAGS=“${COVERAGE_FLAGS}” -DCMAKE_BUILD_TYPE=“Debug”
I do have additional question in our build step I see the GCC Code Coverage Report details with 0% of cover and missing lines. Not sure if this is causing the issue.
Also, I see below error in run c++ test step seems like the script is running anyway
/home/carma/.ci-image/engineering_tools/code_coverage/make_with_coverage.bash: line 59: [: missing `]. Any inputs would help me here. Thanks!
Please let me know if you need any other information. Thank you!
At the end of the day, the scanner is only finding two coverage files.
INFO: Parsing /opt/carma/coverage_reports/gcov/CMakeCCompilerId.c.gcov
WARN: File not analysed by Sonar, so ignoring coverage: /opt/carma/src/CARMAPlatform/platooning_strategic/CMakeCCompilerId.c
INFO: Parsing /opt/carma/coverage_reports/gcov/CMakeCXXCompilerId.cpp.gcov
WARN: File not analysed by Sonar, so ignoring coverage: /opt/carma/src/CARMAPlatform/platooning_strategic/CMakeCXXCompilerId.cpp
INFO: Sensor gcov [cpp] (done) | time=1ms
You’ll have to find out why the other files aren’t in /opt/carma/coverage_reports/gcov/ – and we (Sonar) won’t be able to help you adjust your script. If you still face coverage issues once that folder is properly populated, we’ll be happy to help.
I went back and gone through the github history for the changes between Nov 3rd to Dec 15th there was no major changes to collect_gcovr.bash file but there are few changes in make_with_coverage.bash file to build our source code for ROS2, we tried changing few things and still the gcov files were not moving to output directory. I would like to change to generate the reports in XML formate I used the below command to execute in our current directory and directly move to output directory.
I have updated the sonar.properties with below path but I don’t see any coverage sonar.coverageReportPaths=/opt/carma/coverage_reports/gcov/coverage.xml
Could you please help me here if I’m missing anything. Thank you so much!
INFO: Parsing /opt/carma/coverage_reports/gcov/coverage.xml
INFO: Imported coverage data for 0 files
INFO: Coverage data ignored for 4995 unknown files, including:
build/approximate_intersection/CMakeFiles/3.16.3/CompilerIdC/CMakeCCompilerId.c
build/approximate_intersection/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp
build/arbitrator/CMakeFiles/3.16.3/CompilerIdC/CMakeCCompilerId.c
build/arbitrator/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp
build/asn1c/CMakeFiles/3.16.3/CompilerIdC/CMakeCCompilerId.c
It looks like SonarCloud is having trouble with the paths in the generated report. Since gcovr/gcovr maintains the SonarQube reporter, you might want to raise an issue on their GitHub repository.
And, before changing your coverage strategy, it really seems like making sure files are moved to the appropriate directory is a solvable problem (and doesn’t involve SonarCloud at all).
SonarCloud is just reading reports, it’s not involved in producing them – and that’s about as much support as this community can provide.
we have updated the coverage scripts and few of the projects are able to generate the reports in sonarcloud but few of them are failing at sonar scanner step in CI, Here is the new ticket I have created could you please help me here. Thanks!