diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..0391a18 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,41 @@ +name: Test code_style_validation plugin to Danger + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + test: + + + strategy: + fail-fast: false + matrix: + os: [ubuntu, macos] + ruby-version: [2.5, 2.6, 2.7, head] + + runs-on: ${{ matrix.os }}-latest + + steps: + - uses: actions/checkout@v2 + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + + - name: Install clang-format + if: contains(matrix.os, 'ubuntu') + run: | + sudo apt-get install -y clang-format + + - name: Install clang-format + if: contains(matrix.os, 'macos') + run: | + brew install clang-format + + - name: Run tests + run: | + bundle exec rake spec diff --git a/.travis.yml b/.travis.yml deleted file mode 100755 index f2365f1..0000000 --- a/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -os: - - linux - - osx -dist: trusty - -language: ruby -cache: bundler - -rvm: - - 2.3.1 - - 2.4.0 - -branches: - only: - - master - -addons: - apt: - packages: [ - clang-format-3.8 - ] - -before_install: - - if [ "${TRAVIS_OS_NAME}" = "osx" ]; then brew update; fi - - if [ "${TRAVIS_OS_NAME}" = "osx" ]; then brew install clang-format@3.8; fi - - if [ "${TRAVIS_OS_NAME}" = "osx" ]; then export PATH=`brew --prefix clang-format@3.8`/bin:$PATH; fi - -script: - - bundle exec rake spec diff --git a/Gemfile b/Gemfile old mode 100755 new mode 100644 diff --git a/Gemfile.lock b/Gemfile.lock index 54b26a5..72c8cf4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,44 +7,47 @@ PATH GEM remote: https://rubygems.org/ specs: - addressable (2.5.2) - public_suffix (>= 2.0.2, < 4.0) - ast (2.3.0) - claide (1.0.2) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) + ast (2.4.1) + claide (1.0.3) claide-plugins (0.9.2) cork nap open4 (~> 1.3) - coderay (1.1.1) + coderay (1.1.3) colored2 (3.1.2) cork (0.3.0) colored2 (~> 3.1) - danger (5.5.2) + danger (8.2.1) claide (~> 1.0) claide-plugins (>= 0.9.2) colored2 (~> 3.1) cork (~> 0.1) - faraday (~> 0.9) - faraday-http-cache (~> 1.0) - git (~> 1) - kramdown (~> 1.5) + faraday (>= 0.9.0, < 2.0) + faraday-http-cache (~> 2.0) + git (~> 1.7) + kramdown (~> 2.3) + kramdown-parser-gfm (~> 1.0) no_proxy_fix octokit (~> 4.7) terminal-table (~> 1) danger-plugin-api (1.0.0) danger (> 2.0) - diff-lcs (1.2.5) - faraday (0.13.1) + diff-lcs (1.4.4) + faraday (1.1.0) multipart-post (>= 1.2, < 3) - faraday-http-cache (1.3.1) - faraday (~> 0.8) - ffi (1.9.14) + ruby2_keywords + faraday-http-cache (2.2.0) + faraday (>= 0.8) + ffi (1.13.1) formatador (0.2.5) - git (1.3.0) - guard (2.14.0) + git (1.7.0) + rchardet (~> 1.8) + guard (2.16.2) formatador (>= 0.2.4) listen (>= 2.7, < 4.0) - lumberjack (~> 1.0) + lumberjack (>= 1.0.12, < 2.0) nenv (~> 0.1) notiffany (~> 0.0) pry (>= 0.9.12) @@ -55,67 +58,76 @@ GEM guard (~> 2.1) guard-compat (~> 1.1) rspec (>= 2.99.0, < 4.0) - kramdown (1.15.0) + kramdown (2.3.0) + rexml + kramdown-parser-gfm (1.1.0) + kramdown (~> 2.0) listen (3.0.7) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9.7) - lumberjack (1.0.10) - method_source (0.8.2) - multipart-post (2.0.0) + lumberjack (1.2.8) + method_source (1.0.0) + multipart-post (2.1.1) nap (1.1.0) nenv (0.3.0) - no_proxy_fix (0.1.1) - notiffany (0.1.1) + no_proxy_fix (0.1.2) + notiffany (0.1.3) nenv (~> 0.1) shellany (~> 0.0) - octokit (4.7.0) + octokit (4.19.0) + faraday (>= 0.9) sawyer (~> 0.8.0, >= 0.5.3) open4 (1.3.4) - parallel (1.12.1) - parser (2.4.0.2) - ast (~> 2.3) - powerpack (0.1.1) - pry (0.10.4) - coderay (~> 1.1.0) - method_source (~> 0.8.1) - slop (~> 3.4) - public_suffix (3.0.0) + parallel (1.20.0) + parser (2.7.2.0) + ast (~> 2.4.1) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) + public_suffix (4.0.6) rainbow (3.0.0) rake (10.5.0) - rb-fsevent (0.9.8) - rb-inotify (0.9.7) - ffi (>= 0.5.0) - rspec (3.5.0) - rspec-core (~> 3.5.0) - rspec-expectations (~> 3.5.0) - rspec-mocks (~> 3.5.0) - rspec-core (3.5.4) - rspec-support (~> 3.5.0) - rspec-expectations (3.5.0) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) + ffi (~> 1.0) + rchardet (1.8.0) + regexp_parser (1.8.2) + rexml (3.2.4) + rspec (3.10.0) + rspec-core (~> 3.10.0) + rspec-expectations (~> 3.10.0) + rspec-mocks (~> 3.10.0) + rspec-core (3.10.0) + rspec-support (~> 3.10.0) + rspec-expectations (3.10.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.5.0) - rspec-mocks (3.5.0) + rspec-support (~> 3.10.0) + rspec-mocks (3.10.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.5.0) - rspec-support (3.5.0) - rubocop (0.52.1) + rspec-support (~> 3.10.0) + rspec-support (3.10.0) + rubocop (0.93.1) parallel (~> 1.10) - parser (>= 2.4.0.2, < 3.0) - powerpack (~> 0.1) + parser (>= 2.7.1.5) rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8) + rexml + rubocop-ast (>= 0.6.0) ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.0, >= 1.0.1) - ruby-progressbar (1.9.0) - sawyer (0.8.1) - addressable (>= 2.3.5, < 2.6) - faraday (~> 0.8, < 1.0) + unicode-display_width (>= 1.4.0, < 2.0) + rubocop-ast (1.1.1) + parser (>= 2.7.1.5) + ruby-progressbar (1.10.1) + ruby2_keywords (0.0.2) + sawyer (0.8.2) + addressable (>= 2.3.5) + faraday (> 0.8, < 2.0) shellany (0.0.1) - slop (3.6.0) terminal-table (1.8.0) unicode-display_width (~> 1.1, >= 1.1.1) - thor (0.19.4) - unicode-display_width (1.1.3) - yard (0.9.12) + thor (1.0.1) + unicode-display_width (1.7.0) + yard (0.9.25) PLATFORMS ruby @@ -133,4 +145,4 @@ DEPENDENCIES yard (~> 0.9.11) BUNDLED WITH - 1.15.4 + 1.17.2 diff --git a/Guardfile b/Guardfile old mode 100755 new mode 100644 diff --git a/LICENSE.txt b/LICENSE.txt old mode 100755 new mode 100644 diff --git a/README.md b/README.md old mode 100755 new mode 100644 diff --git a/Rakefile b/Rakefile old mode 100755 new mode 100644 diff --git a/danger-code_style_validation.gemspec b/danger-code_style_validation.gemspec old mode 100755 new mode 100644 diff --git a/lib/code_style_validation/gem_version.rb b/lib/code_style_validation/gem_version.rb old mode 100755 new mode 100644 diff --git a/lib/code_style_validation/plugin.rb b/lib/code_style_validation/plugin.rb old mode 100755 new mode 100644 index aac7283..d9d0d2d --- a/lib/code_style_validation/plugin.rb +++ b/lib/code_style_validation/plugin.rb @@ -52,6 +52,12 @@ def check(config = {}) raise 'Unknown SCM Provider' end + language = 'objective-c' + if file_extensions.include? '.cpp' then + language = 'c++' + elsif file_extensions.include? '.py' then + language = 'python' + end changes = get_changes(diff, file_extensions, ignore_file_patterns) offending_files, patches = resolve_changes(validator, changes) @@ -64,7 +70,9 @@ def check(config = {}) message += 'Execute one of the following actions and commit again:' + "\n" message += '1. Run `%s` on the offending files' % validator + "\n" message += '2. Apply the suggested patches with `git apply patch`.' + "\n\n" - message += patches.join("\n") + offending_file.zip(patches).each do |file_name, patch| + message += get_markdown(file_name, patch, language) + end end return if message.empty? @@ -76,6 +84,20 @@ def check(config = {}) private + def get_markdown(file_name, patch, language) + md = %( +
+ Patch for #{file_name}... + + ```#{language} + #{patch} + ``` +
\n + ) + + md + end + def get_changes(diff_str, file_extensions, ignore_file_patterns) changes = {} line_cursor = 0 diff --git a/lib/danger_code_style_validation.rb b/lib/danger_code_style_validation.rb old mode 100755 new mode 100644 diff --git a/lib/danger_plugin.rb b/lib/danger_plugin.rb old mode 100755 new mode 100644 diff --git a/spec/code_style_validation_spec.rb b/spec/code_style_validation_spec.rb old mode 100755 new mode 100644 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb old mode 100755 new mode 100644