Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide less intrusive bot message #22

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

Empty file modified Gemfile
100755 → 100644
Empty file.
134 changes: 73 additions & 61 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -133,4 +145,4 @@ DEPENDENCIES
yard (~> 0.9.11)

BUNDLED WITH
1.15.4
1.17.2
Empty file modified Guardfile
100755 → 100644
Empty file.
Empty file modified LICENSE.txt
100755 → 100644
Empty file.
Empty file modified README.md
100755 → 100644
Empty file.
Empty file modified Rakefile
100755 → 100644
Empty file.
Empty file modified danger-code_style_validation.gemspec
100755 → 100644
Empty file.
Empty file modified lib/code_style_validation/gem_version.rb
100755 → 100644
Empty file.
24 changes: 23 additions & 1 deletion lib/code_style_validation/plugin.rb
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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?
Expand All @@ -76,6 +84,20 @@ def check(config = {})

private

def get_markdown(file_name, patch, language)
md = %(
<details>
<summary><strong>Patch for</strong> <code>#{file_name}</code><strong>...</strong></summary>

```#{language}
#{patch}
```
</details>\n
)

md
end

def get_changes(diff_str, file_extensions, ignore_file_patterns)
changes = {}
line_cursor = 0
Expand Down
Empty file modified lib/danger_code_style_validation.rb
100755 → 100644
Empty file.
Empty file modified lib/danger_plugin.rb
100755 → 100644
Empty file.
Empty file modified spec/code_style_validation_spec.rb
100755 → 100644
Empty file.
Empty file modified spec/spec_helper.rb
100755 → 100644
Empty file.