Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Pull Requests: One tool to rule them all - Danger

Artheyn
January 18, 2018

Pull Requests: One tool to rule them all - Danger

A quick presentation of the great Danger (http://danger.systems/) which allows you to automatically verify Pull Requests against your own rules.

Artheyn

January 18, 2018
Tweet

More Decks by Artheyn

Other Decks in Programming

Transcript

  1. About Danger “Danger acts as a way of creating unit

    tests at code review level. It gives you the ability to write tests that say: “has this file changed?”, ”does the contents of new files include this string?”…” 3 Ortha Therox
  2. Integration Workflow 4 git push Danger runs after your CI,

    automating your team's conventions surrounding code review. Any CI service
  3. Swift Available languages 5 Ruby Javascript - Created and supported

    by the community
 
 - No plugins architecture for the moment
  4. Danger API - Changes from Git - Changes from GitHub/GitLab/BitBucket

    - Directly interact with Danger 6 e.g.: git.modified_files e.g.: github.pr_title e.g.: warn("You have not included a CHANGELOG entry.")
  5. Dangerfile (Ruby) # Warn when there is a big PR


    warn("Big PR, try to keep changes smaller if you can") if git.lines_of_code > 500 7 # Make it more obvious that a PR is a work in progress and shouldn't be merged yet warn("PR is classed as Work in Progress") if github.pr_title.include? "WIP" # Changelog entries are required for changes to library files. no_changelog_entry = !git.modified_files.include?("Changelog.md") if has_app_changes && no_changelog_entry && not_declared_trivial warn("Any changes to library code should be reflected in the Changelog.") end
  6. iAdvize/Danger 10 # Warn when there is a big PR

    warn("Big PR, try to keep changes smaller if you can") if git.lines_of_code > 500 # Configure code coverage tool slather.configure("IAdvize.xcodeproj", "IAdvize", options: { workspace: "IAdvize.xcworkspace" }) # Show coverage in Github PR slather.show_coverage # Display the associated JIRA ticket jira.check( key: ["INT", "MOB"], url: "https://iadvize.atlassian.net/browse" ) # Display Xcode summary (Warnings/Errors…) xcode_summary.report 'xcodebuild.json'