Last active
June 13, 2021 20:13
-
-
Save lucascorrea/80f3d57a7f97b2365ef39839eefe68a1 to your computer and use it in GitHub Desktop.
Fastfile to use with SonarQube - Coverage | Swift 4.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fileutils' | |
default_platform(:ios) | |
platform :ios do | |
before_all do | |
if !File.exists? "../DerivedData" | |
Dir.mkdir "../DerivedData" | |
end | |
end | |
desc "Generate metrics to the SonarQube" | |
lane :metrics do | |
#We need to put "../DerivedData" because when it is executed it is in folder fastlane | |
sh("xcodebuild -workspace ../brewdog.xcworkspace -scheme brewdog -sdk iphonesimulator -enableCodeCoverage YES -destination 'platform=iOS Simulator,name=iPhone 7,OS=11.3' GCC_GENERATE_TEST_COVERAGE_FILES=YES build test -derivedDataPath ../DerivedData") | |
sh("xcrun llvm-cov show -instr-profile=$(find ../DerivedData -iname 'Coverage.profdata') ../DerivedData/Build/Products/Debug-iphonesimulator/brewdog.app/brewdog > ../DerivedData/Coverage.report") | |
sonar | |
end | |
after_all do |lane| | |
if File.exists? "../DerivedData" | |
FileUtils.rm_rf("../DerivedData") | |
end | |
end | |
error do |lane, exception| | |
if File.exists? "../DerivedData" | |
FileUtils.rm_rf("../DerivedData") | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sonar.projectKey=brewdog | |
sonar.organization==<#YOURORGANIZATION#> | |
sonar.sources=brewdog | |
sonar.host.url=https://sonarcloud.io | |
sonar.login=<#YOURTOKEN#> | |
sonar.cfamily.build-wrapper-output.bypass=true | |
sonar.exclusions=Pods/**/*, brewdogTests/**/* | |
sonar.swift.workspace=brewdog.xcworkspace | |
sonar.swift.project=brewdog.xcodeproj | |
sonar.swift.appScheme=brewdog | |
sonar.swift.coverage.reportPath=DerivedData/Coverage.report |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment