1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00

Merge pull request #1795 from mattbrictson/danger

Set up Danger!
This commit is contained in:
Lee Hambley 2016-12-05 15:56:29 +01:00 committed by GitHub
commit ca91d4fca3
3 changed files with 61 additions and 2 deletions

View file

@ -1,6 +1,6 @@
language: ruby
rvm:
- 2.3.0
- 2.3.1
- 2.2
- 2.1
- 2.0
@ -13,6 +13,10 @@ matrix:
include:
- rvm: rbx-2
script: bundle exec rake spec
# Run Danger only once, on 2.3.1
- rvm: 2.3.1
before_script: bundle exec danger
script: bundle exec rake spec rubocop
install: bundle install --jobs=1
cache: bundler

54
Dangerfile Normal file
View file

@ -0,0 +1,54 @@
# Adapted from https://github.com/ruby-grape/danger/blob/master/Dangerfile
# Q: What is a Dangerfile, anyway? A: See http://danger.systems/
# ------------------------------------------------------------------------------
# Additional pull request data
# ------------------------------------------------------------------------------
project_name = github.pr_json["base"]["repo"]["name"]
pr_number = github.pr_json["number"]
pr_url = github.pr_json["_links"]["html"]["href"]
# ------------------------------------------------------------------------------
# What changed?
# ------------------------------------------------------------------------------
has_lib_changes = !git.modified_files.grep(/^lib/).empty?
has_test_changes = !git.modified_files.grep(/^(features|spec)/).empty?
has_changelog_changes = git.modified_files.include?("CHANGELOG.md")
# ------------------------------------------------------------------------------
# You've made changes to lib, but didn't write any tests?
# ------------------------------------------------------------------------------
if has_lib_changes && !has_test_changes
warn("There are code changes, but no corresponding tests. "\
"Please include tests if this PR introduces any modifications in "\
"#{project_name}'s behavior.",
:sticky => false)
end
# ------------------------------------------------------------------------------
# Have you updated CHANGELOG.md?
# ------------------------------------------------------------------------------
if !has_changelog_changes && has_lib_changes
markdown <<-MARKDOWN
Here's an example of a CHANGELOG.md entry (place it immediately under the `* Your contribution here!` line):
```markdown
* [##{pr_number}](#{pr_url}): #{github.pr_title} - [@#{github.pr_author}](https://github.com/#{github.pr_author}).
```
MARKDOWN
warn("Please update CHANGELOG.md with a description of your changes. "\
"If this PR is not a user-facing change (e.g. just refactoring), "\
"you can disregard this.", :sticky => false)
end
# ------------------------------------------------------------------------------
# Did you remove the CHANGELOG's "Your contribution here!" line?
# ------------------------------------------------------------------------------
if has_changelog_changes
unless IO.read("CHANGELOG.md") =~ /^\* Your contribution here/i
fail(
"Please put the `* Your contribution here!` line back into CHANGELOG.md.",
:sticky => false
)
end
end

View file

@ -26,7 +26,8 @@ Gem::Specification.new do |gem|
gem.add_dependency "sshkit", ">= 1.9.0"
gem.add_dependency "capistrano-harrow"
gem.add_development_dependency "rspec"
gem.add_development_dependency "danger"
gem.add_development_dependency "mocha"
gem.add_development_dependency "rspec"
gem.add_development_dependency "rubocop"
end