My team just added our project’s repo to Sonarcloud, it succesfully scanned it automatically. We are currently receiving the reports both from scanning the repository globally and in every PR. However, we’re not getting data for code coverage in neither case.
On the other hand we’re using Bitrise as our CI tool, in one of our many steps we’re generating our tests report via fastlane with xcov. Is there a way to display our code coverage in the sonarcloud reports via our CI tool?
We tried adding both run-sonar-swift.sh scripts and sonar-project.properties but were unsuccessful.
If there’s any way you can help us or if there’s any info we could’ve missed,
we’d really appreciate it!
ALM used: GitHub
CI system used: Bitrise
Scanner command used when applicable (private details masked)
We actually came across that thread in one of our many attempts
at publishing test coverage in Sonarcloud. What we couldn’t figure out with that approach is the following:
If sonar cloud runs our unit tests in which folder path are they stored? For example, when we run our tests locally the results of that build are stored in DerivedData.
In the root folder of our project we have a fastfile for our CI tool. In one of those many lane steps, we generate a code coverage report through xcov (xcov - fastlane docs) and the tests results are stored in a separate folder (attached photo). We thought that maybe Fastlane is colliding with Sonarcloud’s scanner, but we wanted to confirm this with you guys.
We successfully implemented the manual configuration you suggested. These are our steps:
We created in the root directory of our project both sonar-project.properties and xccov-to-sonarqube-generic.sh script (since we use XCode 13.2.x, we followed the suggestions mentioned in this pull request).
This worked fine, the sonarqube-generic-coverage.xml was generated and we could publish our code coverage data to Sonarcloud. However, we discovered that running the generic data script takes a quite a while both when we run it locally and in our CI.
Do you know by any chance, or have additional info of a way to improve this?
Following the previous post, we tried a different approach to create our generic data xml file. Since we use Fastlane we added a slather lane (both in our Fastfile and as a step in Bitrise). In one of its parameters you can output a sonarqube-generic-coverage.xml file (and quite fast I might add).
Unfortunately, even though Sonar Scanner recognizes the generated file, it cannot read its content returning 0.0% in coverage. The only difference we could find was that the paths to the files that have coverage data are different: slather generates relative paths and the xccov-to-sonarqube-generic.sh script absolute paths.
My team agrees that this could be a great option to generate de required file for test coverage.
So once again, if you guys have more information or know of a way to get this file’s correctly we’d love to know!