|
| 1 | +# Reference: http://danger.systems/reference.html |
| 2 | + |
| 3 | +# A pull request summary is required. Add a description of the pull request purpose. |
| 4 | +# Changelog must be updated for each pull request that changes code. |
| 5 | +# Warnings will be issued for: |
| 6 | +# Pull request with more than 400 lines of code changed |
| 7 | +# Pull reqest that change more than 5 lines without test changes |
| 8 | +# Failures will be issued for: |
| 9 | +# Pull request without summary |
| 10 | +# Pull requests with code changes without changelog entry |
| 11 | + |
| 12 | +def code_changes? |
| 13 | + code = %w(libraries attributes recipes resources files templates) |
| 14 | + code.each do |location| |
| 15 | + return true unless git.modified_files.grep(/#{location}/).empty? |
| 16 | + end |
| 17 | + false |
| 18 | +end |
| 19 | + |
| 20 | +def test_changes? |
| 21 | + tests = %w(spec test kitchen.yml kitchen.dokken.yml) |
| 22 | + tests.each do |location| |
| 23 | + return true unless git.modified_files.grep(/#{location}/).empty? |
| 24 | + end |
| 25 | + false |
| 26 | +end |
| 27 | + |
| 28 | +failure 'Please provide a summary of your Pull Request.' if github.pr_body.length < 10 |
| 29 | + |
| 30 | +warn 'This is a big Pull Request.' if git.lines_of_code > 400 |
| 31 | + |
| 32 | +warn 'This is a Table Flip.' if git.lines_of_code > 2000 |
| 33 | + |
| 34 | +# Require a CHANGELOG entry for non-test changes. |
| 35 | +if !git.modified_files.include?('CHANGELOG.md') && code_changes? |
| 36 | + failure 'Please include a CHANGELOG entry.' |
| 37 | +end |
| 38 | + |
| 39 | +# Require Major Minor Patch version labels |
| 40 | +unless github.pr_labels.grep /minor|major|patch/i |
| 41 | + warn 'Please add a release label to this pull request' |
| 42 | +end |
| 43 | + |
| 44 | +# A sanity check for tests. |
| 45 | +if git.lines_of_code > 5 && code_changes? && !test_changes? |
| 46 | + warn 'This Pull Request is probably missing tests.' |
| 47 | +end |
0 commit comments