From b9b53edc54d63e03c52161f62f6dfa5af46e7aa2 Mon Sep 17 00:00:00 2001 From: Ash Furrow Date: Sun, 3 Jul 2016 14:31:26 -0400 Subject: [PATCH 1/4] Added changelog. --- Changelog.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Changelog.md diff --git a/Changelog.md b/Changelog.md new file mode 100644 index 0000000..b38bdba --- /dev/null +++ b/Changelog.md @@ -0,0 +1,9 @@ +# Changelog + +## Current master branch + +- Nothing yet! + +## 0.1.0 + +- Initial release of Aeryn. From 93cf3fdc6834a41c6fc53daca2d3cb531288114b Mon Sep 17 00:00:00 2001 From: Ash Furrow Date: Sun, 3 Jul 2016 14:45:13 -0400 Subject: [PATCH 2/4] Adds danger. --- Dangerfile | 26 ++++++++++++++++++++++++++ Gemfile | 2 ++ Gemfile.lock | 17 +++++++++++++++++ circle.yml | 5 +++++ 4 files changed, 50 insertions(+) create mode 100644 Dangerfile create mode 100644 circle.yml diff --git a/Dangerfile b/Dangerfile new file mode 100644 index 0000000..94e6467 --- /dev/null +++ b/Dangerfile @@ -0,0 +1,26 @@ +has_app_changes = !git.modified_files.grep(/lib/).empty? +has_test_changes = !git.modified_files.grep(/spec/).empty? + +# 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 = 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 pr_title.include? '[WIP]' + +# Warn when there is a big PR +warn('Big PR') if lines_of_code > 500 + +# Add a CHANGELOG entry for app changes +if !modified_files.include?('CHANGELOG.md') && has_app_changes + fail('Please include a CHANGELOG entry.') +end + +# Warn about un-updated tests +if has_app_changes && !has_test_changes + warn "Tests were not updated" +end + +if github.pr_body.length < 5 + fail 'Please provide a summary in the Pull Request description' +end diff --git a/Gemfile b/Gemfile index d26716a..91e6052 100644 --- a/Gemfile +++ b/Gemfile @@ -18,4 +18,6 @@ group :test do gem 'guard-rspec' gem 'capybara' gem 'rspec-mocks' + + gem 'danger' end diff --git a/Gemfile.lock b/Gemfile.lock index 817809d..57c35d4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,13 +9,27 @@ GEM rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) + claide (1.0.0) coderay (1.1.1) + colored (1.2) + cork (0.1.0) + colored (~> 1.2) + danger (0.8.4) + claide (~> 1.0) + colored (~> 1.2) + cork (~> 0.1) + faraday (~> 0) + git (~> 1) + octokit (~> 4.2) + redcarpet (~> 3.3) + terminal-table (~> 1) diff-lcs (1.2.5) extlib (0.9.16) faraday (0.9.2) multipart-post (>= 1.2, < 3) ffi (1.9.10) formatador (0.2.5) + git (1.3.0) guard (2.14.0) formatador (>= 0.2.4) listen (>= 2.7, < 4.0) @@ -70,6 +84,7 @@ GEM rb-fsevent (0.9.7) rb-inotify (0.9.7) ffi (>= 0.5.0) + redcarpet (3.3.4) rspec (3.5.0) rspec-core (~> 3.5.0) rspec-expectations (~> 3.5.0) @@ -106,6 +121,7 @@ GEM diff-lcs (>= 1.1.2) extlib (>= 0.9.5) highline (>= 1.4.0) + terminal-table (1.6.0) thor (0.19.1) tilt (2.0.5) unicode-display_width (1.1.0) @@ -117,6 +133,7 @@ PLATFORMS DEPENDENCIES capybara + danger guard-rspec guard-rubocop json diff --git a/circle.yml b/circle.yml new file mode 100644 index 0000000..97f151f --- /dev/null +++ b/circle.yml @@ -0,0 +1,5 @@ +test: + override: + - bundle exec rspec + - bundle exec rubocop + - bundle exec danger From d9314d1ccf16e75ad0a3ce36c550d53c0c7fb91a Mon Sep 17 00:00:00 2001 From: Ash Furrow Date: Sun, 3 Jul 2016 16:24:18 -0400 Subject: [PATCH 3/4] Integrate Rubocop into Danger. --- .rubocop.yml | 3 --- Dangerfile | 21 ++++++++++++++++++++- Gemfile | 1 + Gemfile.lock | 5 +++++ circle.yml | 1 - rubocop.json | 1 + 6 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 rubocop.json diff --git a/.rubocop.yml b/.rubocop.yml index 50cacdf..8ac116c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,3 @@ -AllCops: - DisplayCopNames: true - Metrics/LineLength: Max: 120 diff --git a/Dangerfile b/Dangerfile index 94e6467..c264ab7 100644 --- a/Dangerfile +++ b/Dangerfile @@ -18,9 +18,28 @@ end # Warn about un-updated tests if has_app_changes && !has_test_changes - warn "Tests were not updated" + warn 'Tests were not updated' end if github.pr_body.length < 5 fail 'Please provide a summary in the Pull Request description' end + +# TODO: This could be a danger plugin +files_to_lint = (modified_files + added_files).select { |f| f.end_with? 'rb' } +rubocop_results = files_to_lint.map { |f| JSON.parse(`bundle exec rubocop -f json #{f}`)['files'] }.flatten +offending_files = rubocop_results.select { |f| f['offenses'].count > 0 } + +unless offending_files.empty? + message = '### Rubocop violations' + message << 'File | Line | Reason |\n' + message << '| --- | ----- | ----- |\n' + + offending_files.each do |f| + f['offenses'].each do |o| + message << "#{f['path']} | #{o['location']['line']} | #{o['message']} \n" + end + end + + markdown message +end diff --git a/Gemfile b/Gemfile index 91e6052..d6ecef8 100644 --- a/Gemfile +++ b/Gemfile @@ -20,4 +20,5 @@ group :test do gem 'rspec-mocks' gem 'danger' + gem 'rspec_junit_formatter' end diff --git a/Gemfile.lock b/Gemfile.lock index 57c35d4..1262fb3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,6 +3,7 @@ GEM specs: addressable (2.4.0) ast (2.3.0) + builder (3.2.2) capybara (2.4.4) mime-types (>= 1.16) nokogiri (>= 1.3.3) @@ -100,6 +101,9 @@ GEM rspec-sinatra (0.1.2) templater (>= 1.0.0) rspec-support (3.5.0) + rspec_junit_formatter (0.2.3) + builder (< 4) + rspec-core (>= 2, < 4, != 2.12.0) rubocop (0.41.1) parser (>= 2.3.1.1, < 3.0) powerpack (~> 0.1) @@ -142,6 +146,7 @@ DEPENDENCIES rspec rspec-mocks rspec-sinatra + rspec_junit_formatter rubocop sinatra diff --git a/circle.yml b/circle.yml index 97f151f..a450b5b 100644 --- a/circle.yml +++ b/circle.yml @@ -1,5 +1,4 @@ test: override: - bundle exec rspec - - bundle exec rubocop - bundle exec danger diff --git a/rubocop.json b/rubocop.json new file mode 100644 index 0000000..511287f --- /dev/null +++ b/rubocop.json @@ -0,0 +1 @@ +{"metadata":{"rubocop_version":"0.41.1","ruby_engine":"ruby","ruby_version":"2.2.5","ruby_patchlevel":"319","ruby_platform":"x86_64-darwin15"},"files":[{"path":"config.ru","offenses":[]},{"path":"Gemfile","offenses":[]},{"path":"Guardfile","offenses":[]},{"path":"lib/api.rb","offenses":[]},{"path":"lib/ping_checker.rb","offenses":[{"severity":"convention","message":"Extra empty line detected at class body beginning.","cop_name":"Style/EmptyLinesAroundClassBody","corrected":false,"location":{"line":2,"column":1,"length":1}},{"severity":"convention","message":"Space inside square brackets detected.","cop_name":"Style/SpaceInsideBrackets","corrected":false,"location":{"line":4,"column":10,"length":1}}]},{"path":"lib/server.rb","offenses":[]},{"path":"lib/signature_verifier.rb","offenses":[]},{"path":"spec/api_spec.rb","offenses":[]},{"path":"spec/ping_checker_spec.rb","offenses":[]},{"path":"spec/server_spec.rb","offenses":[]},{"path":"spec/signature_verifier_spec.rb","offenses":[]},{"path":"spec/spec_helper.rb","offenses":[]}],"summary":{"offense_count":2,"target_file_count":12,"inspected_file_count":12}} \ No newline at end of file From 51037218062bca3c9a4de9691d55e72da651b6e5 Mon Sep 17 00:00:00 2001 From: Ash Furrow Date: Sun, 3 Jul 2016 16:25:59 -0400 Subject: [PATCH 4/4] Removed unused depencency and file. --- Gemfile | 1 - Gemfile.lock | 5 ----- rubocop.json | 1 - 3 files changed, 7 deletions(-) delete mode 100644 rubocop.json diff --git a/Gemfile b/Gemfile index d6ecef8..91e6052 100644 --- a/Gemfile +++ b/Gemfile @@ -20,5 +20,4 @@ group :test do gem 'rspec-mocks' gem 'danger' - gem 'rspec_junit_formatter' end diff --git a/Gemfile.lock b/Gemfile.lock index 1262fb3..57c35d4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,7 +3,6 @@ GEM specs: addressable (2.4.0) ast (2.3.0) - builder (3.2.2) capybara (2.4.4) mime-types (>= 1.16) nokogiri (>= 1.3.3) @@ -101,9 +100,6 @@ GEM rspec-sinatra (0.1.2) templater (>= 1.0.0) rspec-support (3.5.0) - rspec_junit_formatter (0.2.3) - builder (< 4) - rspec-core (>= 2, < 4, != 2.12.0) rubocop (0.41.1) parser (>= 2.3.1.1, < 3.0) powerpack (~> 0.1) @@ -146,7 +142,6 @@ DEPENDENCIES rspec rspec-mocks rspec-sinatra - rspec_junit_formatter rubocop sinatra diff --git a/rubocop.json b/rubocop.json deleted file mode 100644 index 511287f..0000000 --- a/rubocop.json +++ /dev/null @@ -1 +0,0 @@ -{"metadata":{"rubocop_version":"0.41.1","ruby_engine":"ruby","ruby_version":"2.2.5","ruby_patchlevel":"319","ruby_platform":"x86_64-darwin15"},"files":[{"path":"config.ru","offenses":[]},{"path":"Gemfile","offenses":[]},{"path":"Guardfile","offenses":[]},{"path":"lib/api.rb","offenses":[]},{"path":"lib/ping_checker.rb","offenses":[{"severity":"convention","message":"Extra empty line detected at class body beginning.","cop_name":"Style/EmptyLinesAroundClassBody","corrected":false,"location":{"line":2,"column":1,"length":1}},{"severity":"convention","message":"Space inside square brackets detected.","cop_name":"Style/SpaceInsideBrackets","corrected":false,"location":{"line":4,"column":10,"length":1}}]},{"path":"lib/server.rb","offenses":[]},{"path":"lib/signature_verifier.rb","offenses":[]},{"path":"spec/api_spec.rb","offenses":[]},{"path":"spec/ping_checker_spec.rb","offenses":[]},{"path":"spec/server_spec.rb","offenses":[]},{"path":"spec/signature_verifier_spec.rb","offenses":[]},{"path":"spec/spec_helper.rb","offenses":[]}],"summary":{"offense_count":2,"target_file_count":12,"inspected_file_count":12}} \ No newline at end of file