Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions Dangerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
def validate_template(pr_body)

failure("You did not complete the `Type of change(s)` checklist") if !meets_types_lines(pr_body)
failure("You did not complete the `Before you begin` checklist") if !meets_required_lines(pr_body)

end

def meets_required_lines(pr_body)
lines = Array.new

pr_body.each_line do |line|
if line.include?("<!-- require_") && line.start_with?("- [x]")

lines.push(line)
end
end

return !lines.empty?

end

def meets_types_lines(pr_body)
lines = Array.new

pr_body.each_line do |line|
if line.include?("<!-- type_") && line.start_with?("- [x]")
lines.push(line)
end
end
return !lines.empty?
end

validate_template(github.pr_body)

# Sometimes it's a README fix, or something like that - which isn't relevant for
# including in a project's CHANGELOG for example
declared_trivial = github.pr_title.include? "#trivial"

# 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]" || github.pr_labels.any? { |label| label.downcase.include? "wip" }

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

#suggest squashing if there are a lot of commits
warn("Consider squashing this PR") if git.commits.count > 10
failure("You must squash this PR") if git.commits.count > 50


#Basic rules around PR requirements
failure("You need a meaningful description of this PR") if github.pr_body.length < 5

failure("Please add the JIRA ticket to the title") if !github.pr_title.include?("CNBCMAPP")

errors = danger.status_report[:errors].count
if errors > 0
message = "### Danger Completed with #{errors} errors\n"
message << "![Uh Uh Uh!](https://media.giphy.com/media/5ftsmLIqktHQA/giphy.gif)"
markdown message
else
the_coding_love.random
end

9 changes: 9 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

# gem "rails"
gem 'danger'
gem 'danger-the_coding_love'
62 changes: 62 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
claide (1.0.2)
claide-plugins (0.9.2)
cork
nap
open4 (~> 1.3)
colored2 (3.1.2)
cork (0.3.0)
colored2 (~> 3.1)
danger (5.16.0)
claide (~> 1.0)
claide-plugins (>= 0.9.2)
colored2 (~> 3.1)
cork (~> 0.1)
faraday (~> 0.9)
faraday-http-cache (~> 1.0)
git (~> 1.5)
kramdown (~> 1.5)
no_proxy_fix
octokit (~> 4.7)
terminal-table (~> 1)
danger-plugin-api (1.0.0)
danger (> 2.0)
danger-the_coding_love (0.0.6)
danger-plugin-api (~> 1.0)
nokogiri (>= 1.8.5)
faraday (0.15.4)
multipart-post (>= 1.2, < 3)
faraday-http-cache (1.3.1)
faraday (~> 0.8)
git (1.5.0)
kramdown (1.17.0)
mini_portile2 (2.4.0)
multipart-post (2.0.0)
nap (1.1.0)
no_proxy_fix (0.1.2)
nokogiri (1.10.1)
mini_portile2 (~> 2.4.0)
octokit (4.13.0)
sawyer (~> 0.8.0, >= 0.5.3)
open4 (1.3.4)
public_suffix (3.0.3)
sawyer (0.8.1)
addressable (>= 2.3.5, < 2.6)
faraday (~> 0.8, < 1.0)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
unicode-display_width (1.4.1)

PLATFORMS
ruby

DEPENDENCIES
danger
danger-the_coding_love

BUNDLED WITH
2.0.1
38 changes: 16 additions & 22 deletions pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,42 @@
## Type of change(s)

<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->

- [ ] New feature (non-breaking change which adds functionality)
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] Hotfix / Breakfix (fix or feature that would cause existing functionality to change)
- [ ] Refactoring (changes in code organization without major change in functionality)
- [ ] Documentation addition / update (changes in stored documentation that does not affect functionality)
- [ ] CI/CD change (changes to any versioned CI related configuration / tools)
- [ ] New feature (non-breaking change which adds functionality) <!-- type_feature -->
- [ ] Bug fix (non-breaking change which fixes an issue) <!-- type_bug -->
- [ ] Hotfix / Breakfix (fix or feature that would cause existing functionality to change) <!-- type_hotfix -->
- [ ] Refactoring (changes in code organization without major change in functionality) <!-- type_refactor -->
- [ ] Documentation addition / update (changes in stored documentation that does not affect functionality) <!-- type_docs -->
- [ ] CI/CD change (changes to any versioned CI related configuration / tools) <!-- type_ci -->

<!--- Provide a general summary of your changes in the Title above -->

## Before You Begin

<!--- Before beginning ensure your PR adheres to the following: -->
<!-- Put an `x` in all the boxes that apply: -->

- [ ] Builds clean without any errors?
- [ ] Jira ticket URL has been added to the title above (e.g. CNBCMAPP-420)
- [ ] I have added / updated tests to cover my changes.
- [ ] Have all new and existing tests passed?
- [ ] I have updated the documentation accordingly.
- [ ] Has this been signed off by Product or Design?
- [ ] Builds clean without any errors? <!-- require_clean_build -->
- [ ] Jira ticket URL has been added to the title above (e.g. CNBCMAPP-420) <!-- require_jira_ticket -->
- [ ] I have added / updated tests to cover my changes. <!-- require_tests -->
- [ ] Have all new and existing tests passed? <!-- require_tests_pass -->
- [ ] I have updated the documentation accordingly. <!-- require_docs -->
- [ ] Has this been signed off by Product or Design?<!-- require_signoff -->

##### If any of the above are not checked please explain why:

## Description of Your Changes

## Description of Your Changes
<!--- Describe your changes in detail -->



## How Has This Been Tested?

<!--- Please provide relevant url(s) to this work and necessary steps to review -->
Provide the steps to test this

## Device / Form Factor Checklist

## Device / Form Factor Checklist
This PR has been tested with the following devices:

- [ ] Not Applicable
- [ ] iPhone
- [ ] Large (Plus, Max)
- [ ] X (X, Xr, Xs)
Expand All @@ -56,14 +53,11 @@ This PR has been tested with the following devices:
## Screenshots (if appropriate):

## Dependencies

Provide details on other PRs that are dependent on this / this PR is dependent on:

## Documentation

If you created / updated documentation, necessary documentation & links (if applicable):
<!-- e.g. [link to Google!](http://google.com) -->

## Notes

<!--- Any additional notes or comments? Please share! -->
<!--- Any additional notes or comments? Please share! -->