Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 56ccf06

Browse files
committedAug 20, 2016
Added Dager, PR linting.
1 parent 39a07cb commit 56ccf06

File tree

8 files changed

+132
-39
lines changed

8 files changed

+132
-39
lines changed
 

‎.travis.yml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
rvm:
2-
- 1.9.3
3-
- 2.0.0
4-
- 2.1
5-
- 2.2
6-
- 2.3.0
7-
- rbx-2
8-
- jruby-19mode
9-
- ruby-head
10-
- jruby-head
1+
language: ruby
2+
3+
sudo: false
114

125
matrix:
6+
include:
7+
- rvm: 2.3.1
8+
script:
9+
- bundle exec danger
10+
- rvm: 2.3.1
11+
- rvm: 2.3.0
12+
- rvm: 2.2.5
13+
- rvm: rbx-2
14+
- rvm: ruby-head
15+
- rvm: jruby-head
1316
allow_failures:
1417
- rvm: ruby-head
1518
- rvm: jruby-head
1619
- rvm: rbx-2
1720

18-
before_install:
19-
- gem install bundler
21+
bundler_args: --without development

‎CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
### 0.8.2 (Next)
22

3-
Your contribution here.
3+
* [#105](https://github.com/codegram/hyperclient/pull/105): Added Danger, PR linter - [@dblock](https://github.com/dblock).
4+
* Your contribution here.
45

56
### 0.8.1 (March 15, 2016)
67

‎Dangerfile

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# --------------------------------------------------------------------------------------------------------------------
2+
# Has any changes happened inside the actual library code?
3+
# --------------------------------------------------------------------------------------------------------------------
4+
has_app_changes = !git.modified_files.grep(/lib/).empty?
5+
has_spec_changes = !git.modified_files.grep(/spec/).empty? && !git.modified_files.grep(/features/).empty?
6+
has_changelog_changes = git.modified_files.include?('CHANGELOG.md')
7+
has_dangerfile_changes = git.modified_files.include?('Dangerfile')
8+
has_rakefile_changes = git.modified_files.include?('Rakefile')
9+
has_code_changes = has_app_changes || has_dangerfile_changes || has_rakefile_changes
10+
11+
# --------------------------------------------------------------------------------------------------------------------
12+
# You've made changes to lib, but didn't write any tests?
13+
# --------------------------------------------------------------------------------------------------------------------
14+
if has_app_changes && !has_spec_changes
15+
warn("There're library changes, but not tests. That's OK as long as you're refactoring existing code.", sticky: false)
16+
end
17+
18+
# --------------------------------------------------------------------------------------------------------------------
19+
# You've made changes to specs, but no library code has changed?
20+
# --------------------------------------------------------------------------------------------------------------------
21+
if !has_app_changes && has_spec_changes
22+
message('We really appreciate pull requests that demonstrate issues, even without a fix. That said, the next step is to try and fix the failing tests!', sticky: false)
23+
end
24+
25+
# --------------------------------------------------------------------------------------------------------------------
26+
# Have you updated CHANGELOG.md?
27+
# --------------------------------------------------------------------------------------------------------------------
28+
if !has_changelog_changes && has_code_changes
29+
pr_number = github.pr_json['number']
30+
markdown <<-MARKDOWN
31+
Here's an example of a CHANGELOG.md entry:
32+
33+
```markdown
34+
* [##{pr_number}](https://github.com/ruby-grape/grape/pull/#{pr_number}): #{github.pr_title} - [@#{github.pr_author}](https://github.com/#{github.pr_author}).
35+
```
36+
MARKDOWN
37+
warn("Unless you're refactoring existing code, please update CHANGELOG.md.", sticky: false)
38+
end
39+
40+
# --------------------------------------------------------------------------------------------------------------------
41+
# Is the CHANGELOG.md format correct?
42+
# --------------------------------------------------------------------------------------------------------------------
43+
44+
your_contribution_here = false
45+
errors = 0
46+
File.open('CHANGELOG.md').each_line do |line|
47+
# ignore lines that aren't changes
48+
next unless line[0] == '*'
49+
# notice your contribution here
50+
if line == "* Your contribution here.\n"
51+
your_contribution_here = true
52+
next
53+
end
54+
# match the PR format, with or without PR number
55+
next if line =~ %r{^\*\s[\`[:upper:]].* \- \[\@[\w\d\-\_]+\]\(https:\/\/github\.com\/.*[\w\d\-\_]+\)\.$}
56+
next if line =~ %r{^\*\s\[\#\d+\]\(https:\/\/github\.com\/.*\d+\)\: [\`[:upper:]].* \- \[\@[\w\d\-\_]+\]\(https:\/\/github\.com\/.*[\w\d\-\_]+\)\.$}
57+
errors += 1
58+
markdown <<-MARKDOWN
59+
```markdown
60+
#{line}```
61+
MARKDOWN
62+
end
63+
64+
fail("One of the lines below found in CHANGELOG.md doesn't match the expected format. Please make it look like the other lines, pay attention to periods and spaces.", sticky: false) if errors > 0
65+
fail('Please put back the `* Your contribution here.` line into CHANGELOG.md.', sticky: false) unless your_contribution_here
66+
67+
# --------------------------------------------------------------------------------------------------------------------
68+
# Don't let testing shortcuts get into master by accident,
69+
# ensuring that we don't get green builds based on a subset of tests.
70+
# --------------------------------------------------------------------------------------------------------------------
71+
72+
(git.modified_files + git.added_files - %w(Dangerfile)).each do |file|
73+
next unless File.file?(file)
74+
contents = File.read(file)
75+
if file.start_with?('spec')
76+
fail("`xit` or `fit` left in tests (#{file})") if contents =~ /^\w*[xf]it/
77+
fail("`fdescribe` left in tests (#{file})") if contents =~ /^\w*fdescribe/
78+
end
79+
end

‎Gemfile

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,29 @@ source 'https://rubygems.org'
22

33
gemspec
44

5-
gem 'rake'
6-
gem 'growl'
7-
gem 'guard'
8-
gem 'guard-minitest'
9-
gem 'guard-spinach'
10-
gem 'pry'
11-
12-
gem 'yard', '~> 0.8'
13-
gem 'yard-tomdoc'
14-
gem 'simplecov', require: false
15-
gem 'rubocop', '~> 0.33.0', require: false
5+
group :development do
6+
gem 'growl'
7+
gem 'guard'
8+
gem 'guard-minitest'
9+
gem 'guard-spinach'
10+
gem 'pry'
11+
end
12+
13+
group :development, :test do
14+
gem 'yard', '~> 0.8'
15+
gem 'yard-tomdoc'
16+
gem 'rake'
17+
gem 'simplecov', require: false
18+
gem 'rubocop', '~> 0.33.0', require: false
19+
end
20+
21+
group :test do
22+
gem 'futuroscope', github: 'codegram/futuroscope'
23+
gem 'danger', '~> 2.1', require: false
24+
gem 'minitest'
25+
gem 'turn'
26+
gem 'webmock'
27+
gem 'mocha'
28+
gem 'rack-test'
29+
gem 'spinach'
30+
end

‎Rakefile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env rake
2-
begin
3-
require 'bundler/setup'
4-
rescue LoadError
5-
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6-
end
2+
require 'rubygems'
3+
require 'bundler'
4+
Bundler.setup :default, :test, :development
5+
6+
Bundler::GemHelper.install_tasks
77

88
if ENV['COVERAGE']
99
require 'simplecov'
@@ -40,3 +40,5 @@ require 'rubocop/rake_task'
4040
RuboCop::RakeTask.new(:rubocop)
4141

4242
task default: [:rubocop, :test, :spinach]
43+
44+
task default: [:test, :spinach]

‎features/support/env.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
require 'minitest/spec'
22
require 'webmock'
33
require 'hyperclient'
4-
require 'pry'

‎hyperclient.gemspec

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,4 @@ Gem::Specification.new do |gem|
2121
gem.add_dependency 'uri_template'
2222
gem.add_dependency 'net-http-digest_auth'
2323
gem.add_dependency 'faraday-digestauth'
24-
25-
gem.add_development_dependency 'minitest'
26-
gem.add_development_dependency 'turn'
27-
gem.add_development_dependency 'webmock'
28-
gem.add_development_dependency 'mocha'
29-
gem.add_development_dependency 'rack-test'
30-
gem.add_development_dependency 'spinach'
3124
end

‎test/test_helper.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
$LOAD_PATH << 'lib'
2-
gem 'minitest'
32

43
require 'minitest/spec'
54
require 'minitest/autorun'
65
require 'mocha/setup'
76
require 'turn'
87
require 'json'
9-
require 'pry'
108

119
MiniTest::Unit::TestCase.class_eval do
1210
def stub_request(conn, adapter_class = Faraday::Adapter::Test, &stubs_block)
1311
adapter_handler = conn.builder.handlers.find { |h| h.klass < Faraday::Adapter }
1412
conn.builder.swap(adapter_handler, adapter_class, &stubs_block)
1513
end
1614
end
15+
16+
require 'futuroscope'
17+
require 'futuroscope/pools/no_pool'
18+
Futuroscope.default_pool = Futuroscope::Pools::NoPool.new

0 commit comments

Comments
 (0)
Please sign in to comment.