- ALM used (GitHub)
- CI system used (Github Actions)
- Scanner command used when applicable:
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
sonar-project.properties file:
sonar.projectKey=xxx-ios
sonar.organization=xxx-ios-app
sonar.c.file.suffixes=-
sonar.cpp.file.suffixes=-
sonar.objc.file.suffixes=-
sonar.coverageReportPaths=sonar-generic-coverage.xml
sonar.sources=.
sonar.exclusions=Tests/**
sonar.tests=Tests
sonar.test.inclusions=Tests/*.swift
sonar.verbose=true
-
Languages of the repository: Swift
-
Steps to reproduce:
I have a github actions workflow job on a PR which executes the following to generate the code coverage report (uses xcode 13.2.1):
xcodebuild test-without-building -scheme "$scheme" -"$filetype_parameter" "$file_to_build" -destination "platform=$platform,name=$device" -enableCodeCoverage YES -resultBundlePath "CodeCoverage.xcresult"
Then the report is transformed using:
bash xcov-to-sonar-generic.sh CodeCoverage.xcresult > sonar-generic-coverage.xml
Since SonarScanner only runs on linux, and my xcodebuild runs on mac, I export the artifact for another github actions job:
uses: actions/upload-artifact@v2
with:
name: code-coverage
path: sonar-generic-coverage.xml
And in the following github actions job I execute the following:
sonar:
name: Run SonarCloud scan
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Download code coverage
uses: actions/download-artifact@v2
with:
name: code-coverage
- name: Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
However, I do not get the coverage in the scan analysis results, it stays at 0%. This is the log I get:
INFO: Sensor Generic Coverage Report
INFO: Parsing /github/workspace/sonar-generic-coverage.xml
INFO: Imported coverage data for 0 files
INFO: Coverage data ignored for 159 unknown files, including:
/Users/runner/work/ios/ios/qcast/Cells/Auth/AuthTextFieldTableCell.swift
My folder structure is as follows:
rootDir:
→ qcast
→ qcast.xcodeproj
→ qcast.xcworkspace
→ Tests