Skip to content

Commit bad3433

Browse files
ortadblock
authored andcommitted
Add Danger (#1455)
1 parent 048b00c commit bad3433

8 files changed

+41
-4
lines changed

.rubocop.yml

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
AllCops:
2+
Include:
3+
- Dangerfile
4+
25
Exclude:
36
- vendor/**/*
47
- bin/**/*

.travis.yml

+3
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ gemfile:
2323
- gemfiles/rack_1.5.2.gemfile
2424

2525
bundler_args: --without development
26+
27+
before_script:
28+
- bundle exec danger

CHANGELOG.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55

66
* [#1440](https://github.com/ruby-grape/grape/pull/1441): Supports only Ruby 2.2.2 and later - [@jlfaber](https://github.com/jlfaber).
77
* [#1393](https://github.com/ruby-grape/grape/pull/1393): Middleware can be inserted before or after default Grape middleware - [@ridiculous](https://github.com/ridiculous).
8-
* [#1390](https://github.com/ruby-grape/grape/pull/1390): Allow inserting middleware at arbitrary points in the middleware stack - [@Rosa](https://github.com/Rosa).
9-
* [#1366](https://github.com/ruby-grape/grape/pull/1366): Store `message_key` on `Grape::Exceptions::Validation` - [@mkou](https://github.com/mkou).
10-
* [#1398](https://github.com/ruby-grape/grape/pull/1398): Added `rescue_from :grape_exceptions` - allow Grape to use the built-in `Grape::Exception` handing and use `rescue :all` behavior for everything else - [@mmclead](https://github.com/mmclead).
11-
* [#1443](https://github.com/ruby-grape/grape/pull/1443): Extended `given` to receive a `Proc` - [@glaucocustodio](https://github.com/glaucocustodio).
8+
* [#1390](https://github.com/ruby-grape/grape/pull/1390): Allows inserting middleware at arbitrary points in the middleware stack - [@Rosa](https://github.com/Rosa).
9+
* [#1366](https://github.com/ruby-grape/grape/pull/1366): Stores `message_key` on `Grape::Exceptions::Validation` - [@mkou](https://github.com/mkou).
10+
* [#1398](https://github.com/ruby-grape/grape/pull/1398): Adds `rescue_from :grape_exceptions` - allow Grape to use the built-in `Grape::Exception` handing and use `rescue :all` behavior for everything else - [@mmclead](https://github.com/mmclead).
11+
* [#1443](https://github.com/ruby-grape/grape/pull/1443): Extends `given` to receive a `Proc` - [@glaucocustodio](https://github.com/glaucocustodio).
12+
* [#1455](https://github.com/ruby-grape/grape/pull/1455): Adds an automated PR linter - [@orta](https://github.com/orta).
13+
1214
* Your contribution here.
1315

1416
#### Fixes

Dangerfile

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Has any changes happened inside the lib dir?
2+
has_app_changes = !git.modified_files.grep(/lib/).empty?
3+
4+
if git.modified_files.include?('CHANGELOG.md') == false && !declared_trivial && has_app_changes
5+
pr_number = github.pr_json['number']
6+
markdown <<-MARKDOWN
7+
Here's an example of your CHANGELOG entry:
8+
9+
```markdown
10+
* [##{pr_number}](https://github.com/ruby-grape/grape/pull/#{pr_number}): #{github.pr_title} - [@#{github.pr_author}](https://github.com/#{github.pr_author}).
11+
```
12+
fail('No CHANGELOG changes made in CHANGELOG.md when there are library changes.', sticky: false)
13+
MARKDOWN
14+
end
15+
16+
# Don't let testing shortcuts get into master by accident,
17+
# ensuring that we don't get green builds based on a subset of tests.
18+
(git.modified_files + git.added_files - %w(Dangerfile)).each do |file|
19+
next unless File.file?(file)
20+
contents = File.read(file)
21+
if file.start_with?('spec')
22+
raise("`xit` or `fit` left in tests (#{file})") if contents =~ /^\w*[xf]it/
23+
raise("`fdescribe` left in tests (#{file})") if contents =~ /^\w*fdescribe/
24+
end
25+
end

Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ group :test do
2828
gem 'cookiejar'
2929
gem 'rack-contrib'
3030
gem 'mime-types', '< 3.0'
31+
gem 'danger', '~> 2.0'
3132
end

gemfiles/rack_1.5.2.gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ group :test do
2828
gem 'cookiejar'
2929
gem 'rack-contrib'
3030
gem 'mime-types', '< 3.0'
31+
gem 'danger', '~> 2.0'
3132
end
3233

3334
gemspec path: '../'

gemfiles/rails_3.gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ group :test do
2929
gem 'cookiejar'
3030
gem 'rack-contrib'
3131
gem 'mime-types', '< 3.0'
32+
gem 'danger', '~> 2.0'
3233
end
3334

3435
gemspec path: '../'

gemfiles/rails_4.gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ group :test do
2828
gem 'cookiejar'
2929
gem 'rack-contrib'
3030
gem 'mime-types', '< 3.0'
31+
gem 'danger', '~> 2.0'
3132
end
3233

3334
gemspec path: '../'

0 commit comments

Comments
 (0)