From f9831f6dcdfb2d74b5fa55bbdbf5883e64cc98be Mon Sep 17 00:00:00 2001 From: Simone Civetta Date: Sun, 19 Jun 2016 01:08:35 +0200 Subject: [PATCH] [Usage] Add Fastlane example doc --- README.md | 10 ++++----- docs/sonarqube-fastlane.md | 42 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 docs/sonarqube-fastlane.md diff --git a/README.md b/README.md index d53bbe81..cb6ff186 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,10 @@ The structure of the plugin is based on the [sonar-objective-c](https://github.c Checkout the [Releases](https://github.com/Backelite/sonar-swift/releases) page. +###Launching an analysis +If you use [Fastlane](https://fastlane.tools), please read [our Fastlane integration doc](docs/sonarqube-fastlane.md). +Otherwise, run the ```run-sonar-swift.sh``` script from your Xcode project root folder + ###Release history ####0.2.3 @@ -76,7 +80,7 @@ Checkout the [Releases](https://github.com/Backelite/sonar-swift/releases) page. ###Installation of xcpretty with JUnit reports fix -At the time, xcpretty needs to be fixed to work with SonarQube. +At the time, xcpretty needs to be fixed to work with SonarQube. To install the fixed version, follow those steps : @@ -97,10 +101,6 @@ To install the fixed version, follow those steps : **The good news is that you don't have to modify your Xcode project to enable SonarQube!**. Ok, there might be one needed modification if you don't have a specific scheme for your test target, but that's all. -###Analysis -- Run the script ```run-sonar-swift.sh``` in your Xcode project root folder -- Enjoy or file an issue! - ###Update (once per plugin update) - Install the lastest plugin version - Copy ```run-sonar-swift.sh``` somewhere in your PATH diff --git a/docs/sonarqube-fastlane.md b/docs/sonarqube-fastlane.md new file mode 100644 index 00000000..ec730215 --- /dev/null +++ b/docs/sonarqube-fastlane.md @@ -0,0 +1,42 @@ +# Using with Fastlane 🚀 + +If you already use Fastlane, you can simply setup a new lane performing the analysis as follows: + +```ruby +lane :metrics do + scan(scheme: "[SCHEME]", code_coverage: true, output_directory: "./reports") + slather(cobertura_xml: true, scheme: "[SCHEME]", output_directory: "./reports", proj: "./[PROJECT].xcodeproj") + sh("cd .. && lizard ./[SOURCE_FOLDER] -l swift --xml > ./reports/lizard-report.xml") + swiftlint(output_file: "./reports/swiftlint.txt", ignore_exit_status: true) + sonar +end + +``` + +## Options + +Fastlane's `sonar` action allows you to define or override a number of SonarQube properties, such as `sonar.project-version`. + +For instance: + +```ruby + sonar(project_version: "1.0b") +``` + +You can read the complete documentation of Fastlane's `sonar` action on your terminal via: + +```bash + fastlane action sonar +``` + +## `sonar-project.properties` + +Please note that, in order to have your analysis performed via the tools above, you'll need to setup your `sonar-project.properties` file accordingly, as per the following example. + +``` +sonar.junit.reportsPath=reports/ +sonar.junit.include=*.junit +sonar.swift.lizard.report=reports/lizard-report.xml +sonar.swift.coverage.reportPattern=reports/cobertura.xml +sonar.swift.swiftlint.report=reports/*swiftlint.txt +```