Danger in 15m

F116cb3be23153ec08b94e8bd4dbcfeb?s=47 Orta
September 08, 2016

Danger in 15m

A quick overview of Danger, it's mainly a summary of information which you can find on http://danger.systems

F116cb3be23153ec08b94e8bd4dbcfeb?s=128

Orta

September 08, 2016
Tweet

Transcript

  1. None
  2. None
  3. None
  4. WHAT IS DANGER Tests for team culture FEEDBACK SYSTEM DURING

    CODE REVIEW
  5. HOW does it work Sets up useful metadata git github

    gitlab bitbucket Runs your ruby code with those exposed OUTPUTS the status to your pull request
  6. MOYA Warn reviewers if PR is classed as Work In

    Progress Warn reviewers the PR has a lot of lines changed Fail if someone accidentally skipped all tests Fail if there is app code changes without a changelog entry Fail if there are new source files that are not reflected in Xcode Warn if there’s no documentation changes for big PRs
  7. MOYA

  8. MOYA # Sometimes it's a README fix, or something like

    that - which isn't relevant for # including in a project's CHANGELOG for example not_declared_trivial = !(github.pr_title.include? "#trivial") has_app_changes = !git.modified_files.grep(/Source/).empty? # 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]" # Warn when there is a big PR warn("Big PR") if git.lines_of_code > 500 # Don't let testing shortcuts get into master by accident fail("fit left in tests") if `grep -r "fit Demo/Tests/ `.length > 1 # 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 fail("Any changes to library code need a summary in the Changelog.") end # Added (or removed) library files need to be added (or removed) from the # Carthage Xcode project to avoid breaking things for our Carthage users. added_swift_library_files = git.added_files.grep(/Source.*\.swift/).empty? deleted_swift_library_files = git.deleted_files.grep(/Source.*\.swift/).empty? modified_carthage_xcode_project = !(git.deleted_files.grep(/Moya\.xcodeproj/).empty?) if (added_swift_library_files || deleted_swift_library_files) && modified_carthage_xcode_project fail("Added or removed library files require the Carthage Xcode project to be updated.") end missing_doc_changes = git.modified_files.grep(/docs/).empty? doc_changes_recommended = insertions > 15 if has_app_changes && missing_doc_changes && doc_changes_recommended warn("Consider adding supporting documentation to this change. Documentation can be found in the `docs` directory.") end # Run SwiftLint swiftlint.lint_files
  9. MOYA # 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]" # Warn when there is a big PR warn("Big PR") if git.lines_of_code > 500 # Don't let testing shortcuts get into master by accident fail("fit left in tests") if `grep -r "fit Demo/Tests/ `.length > 1
  10. MOYA # Sometimes it's a README fix, or something like

    that - which isn't relevant for # including in a project's CHANGELOG for example not_declared_trivial = !(github.pr_title.include? "#trivial") has_app_changes = !git.modified_files.grep(/Source/).empty? # 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 fail("Any changes to library code need a summary in the Changelog.") end missing_doc_changes = git.modified_files.grep(/docs/).empty? doc_changes_recommended = insertions > 15 if has_app_changes && missing_doc_changes && doc_changes_recommended warn("Consider adding supporting documentation to this change. Documentation can be found in the `docs` directory.") end
  11. MOYA # Added (or removed) library files need to be

    added (or removed) from the # Carthage Xcode project to avoid breaking things for our Carthage users. added_swift_library_files = git.added_files.grep(/Source.*\.swift/).empty? deleted_swift_library_files = git.deleted_files.grep(/Source.*\.swift/).empty? modified_carthage_xcode_project = !(git.deleted_files.grep(/Moya\.xcodeproj/).empty?) if (added_swift_library_files || deleted_swift_library_files) && modified_carthage_xcode_project fail("Added or removed library files require the Carthage Xcode project to be updated.") end # Run SwiftLint swiftlint.lint_files
  12. Paths for files that were added during the diff added_files

    [String] Paths for files that were removed during the diff deleted_files [String] Paths for files that changed during the diff modified_files [String] The overall lines of code added/removed in the diff lines_of_code Int The overall lines of code removed in the diff deletions Int The overall lines of code added in the diff insertions Int The log of commits inside the diff commits Git::Log Details for a specific file in this diff diff_for_file Git::Diff::DiffFile GIT
  13. The title of the Pull Request. pr_title String The body

    text of the Pull Request. pr_body String The username of the author of the Pull Request. pr_author String The labels assigned to the Pull Request. pr_labels String The base commit to which the PR is going to be merged as a parent. base_commit String The head commit to which the PR is requesting to be merged from. head_commit String The hash that represents the PR's JSON. pr_json Hash Provides access to an API client used inside Danger. Different per platform. api Octokit::Client Github gitlab bitbucket
  14. Print markdown to below the table markdown (message: String, file=nil:

    String, line=nil: String) Print out a generate message on the PR message (message: String, sticky=true: Boolean, file=nil: String, line=nil: String) Specifies a problem, but not critical warn (message: String, sticky=true: Boolean, file=nil: String, line=nil: String) Declares a CI blocking error fail (message: String, sticky=true: Boolean, file=nil: String, line=nil: String) A list of all messages passed to Danger, including the markdowns. status_report Hash A list of all violations passed to Danger, we don't anticipate users of Danger needing to use this. violation_report Hash Messaging
  15. Download a local or remote plugin and make it usable

    inside the Dangerfile. import_plugin (path_or_url: String) Import a Dangerfile. import_dangerfile (opts: Hash) DANGER
  16. PLUGINS DANGER INTENTIONALLY SMALL API PLUGINS{PROVIDE MAGIC SUPER EASY TO

    MAKE
  17. Spell Check Markdown Highlight JUnit Errors Highlight Xcode build issues

    Apply Commit Rules Enforce CHANGLOGs Only let certain developers touch some files Show slow swift compilation steps Keep your Git history short highlight undocumented methods Check if the author is in an org Ensure PR summaries Ensure each PR has a JIRA ticket Ensure developers write tests Only accept PRs to a specific branch Ensure all PRs have an assignee Warn when specific libs are added Fail big PRs Add links to build artifacts Run linters on your code, highlighting per line Ensure some files are never changed Ensure some texts are never added to files Ensure coupled files are both changed Prose check files Ensure PR title Merge OK PRs automatically
  18. None