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/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. diff --git a/Dangerfile b/Dangerfile new file mode 100644 index 0000000..c264ab7 --- /dev/null +++ b/Dangerfile @@ -0,0 +1,45 @@ +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 + +# 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 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..a450b5b --- /dev/null +++ b/circle.yml @@ -0,0 +1,4 @@ +test: + override: + - bundle exec rspec + - bundle exec danger