Rightpoint / ios-template

A `cookiecutter` template for iOS projects
MIT License
94 stars 26 forks source link

Add Danger to CI #92

Closed chrisballinger closed 6 years ago

chrisballinger commented 6 years ago

https://danger.systems/ruby/

You can add rules to the Dangerfile to get automated PR comments. It is currently configured with a few basic rules, Swiftlint using our ruleset, and xcov code coverage reports.

For an example Dangerfile:

# Make it more obvious that a PR is a work in progress and shouldn't be merged yet.
has_wip_label = github.pr_labels.any? { |label| label.include? "WIP" }
has_wip_title = github.pr_title.include? "[WIP]"

if has_wip_label || has_wip_title
    warn("PR is classed as Work in Progress")
end

# Warn when there is a big PR.
warn("Big PR") if git.lines_of_code > 500

# Mainly to encourage writing up some reasoning about the PR, rather than just leaving a title.
if github.pr_body.length < 3 && git.lines_of_code > 10
  warn("Please provide a summary in the Pull Request description")
end

src_root = File.expand_path('../PRODUCTNAME/app', __FILE__)

xcov.report(
  workspace: "#{src_root}/PRODUCTNAME.xcworkspace",
  scheme: "debug-PRODUCTNAME",
  output_directory: "#{ENV['RZ_TEST_REPORTS']}",
   # For some reason coverage is on the "develop-" app target instead of "debug-"
  include_targets: "develop-PRODUCTNAME.app, Services.framework",
  ignore_file_path: "#{src_root}/fastlane/.xcovignore"
)

## ** SWIFT LINT ***
# Use the SwiftLint included via CocoaPods
swiftlint.binary_path = "#{src_root}/Pods/SwiftLint/swiftlint"
swiftlint.config_file = "#{src_root}/.swiftlint.yml"

# Run Swift-Lint and warn us if anything fails it
swiftlint.directory = src_root
swiftlint.lint_files inline_mode: true
raizlabs-oss-bot commented 6 years ago
1 Warning
:warning: Big PR

Current coverage for Services.framework is 68.68%

No files affecting coverage found


Current coverage for develop-PRODUCTNAME.app is 1.90%

Files changed - -
Actionable+AutoConformance.swift 0.00% :skull:
Storyboards.swift 0.00% :skull:
UIImage+Asset.swift 0.00% :skull:

Powered by xcov

Generated by :no_entry_sign: Danger

chrisballinger commented 6 years ago

This is what happens when you've violated Swiftlint:

screen shot 2018-04-10 at 2 50 23 pm