Skip to content

Commit

Permalink
Add danger
Browse files Browse the repository at this point in the history
  • Loading branch information
uzzu committed Apr 17, 2020
1 parent 23f753c commit fcac8c7
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 0 deletions.
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.6
82 changes: 82 additions & 0 deletions Dangerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#
# GitHub Comment
#
github.dismiss_out_of_range_messages({
error: false,
warning: true,
message: true,
markdown: true
})

#
# File watching
#

[
".idea/codeStyleSettings.xml",
].each do |file|
warn("Are you sure want to modify #{file} ?") if git.modified_files.include?(file)
end

#
# Compiler warnings, errors
#

warning_pattern = /w: (?<path>(?:\/.+)+\.kt): \((?<line>\d+), (?<column>\d+)\): (?<description>.*)/
error_pattern = /e: (?<path>(?:\/.+)+\.kt): \((?<line>\d+), (?<column>\d+)\): (?<description>.*)/

target_files = (git.modified_files - git.deleted_files) + git.added_files
kotlin_compile_files = Dir.glob("**/build/kotlin/compile*Kotlin*.stdout")
unless kotlin_compile_files.empty?
compile_messages = File.read(kotlin_compile_files.first).strip
.split("\n")
.each { |s|
if match = s.match(warning_pattern)
file = Pathname(match[:path]).relative_path_from(Pathname(Dir.pwd)).to_s
if git.diff_for_file(file)
warn("#{match[:description]}", file: file, line: match[:line].to_i)
else
warn("#{file}: (#{match[:line]}, #{match[:column]}): #{match[:description]}")
end
end
if match = s.match(error_pattern)
file = Pathname(match[:path]).relative_path_from(Pathname(Dir.pwd)).to_s
if git.diff_for_file(file)
fail("#{match[:description]}", file: file, line: match[:line].to_i)
else
fail("#{file}: (#{match[:line]}, #{match[:column]}): #{match[:description]}")
end
end
}
end

#
# ktlint
#
checkstyle_format.base_path = Dir.pwd
Dir.glob('**/build/reports/ktlint/ktlint*Check.xml') do |file|
checkstyle_format.report file
end

#
# JUnit test results
#

tests = []
failures = []
errors = []
skipped = []

Dir.glob("**/build/test-results/**/TEST-*.xml") do |file|
junit.parse file
tests.concat(junit.tests)
failures.concat(junit.failures)
errors.concat(junit.errors)
skipped.concat(junit.skipped)
end
junit.tests = tests
junit.failures = failures
junit.errors = errors
junit.skipped = skipped

junit.report
8 changes: 8 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

gem 'danger'
gem 'danger-junit'
gem 'danger-checkstyle_format'
70 changes: 70 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
claide (1.0.3)
claide-plugins (0.9.2)
cork
nap
open4 (~> 1.3)
colored2 (3.1.2)
cork (0.3.0)
colored2 (~> 3.1)
danger (7.0.0)
claide (~> 1.0)
claide-plugins (>= 0.9.2)
colored2 (~> 3.1)
cork (~> 0.1)
faraday (>= 0.9.0, < 2.0)
faraday-http-cache (~> 2.0)
git (~> 1.6)
kramdown (~> 2.0)
kramdown-parser-gfm (~> 1.0)
no_proxy_fix
octokit (~> 4.7)
terminal-table (~> 1)
danger-checkstyle_format (0.1.1)
danger-plugin-api (~> 1.0)
ox (~> 2.0)
danger-junit (1.0.0)
danger (> 2.0)
ox (~> 2.0)
danger-plugin-api (1.0.0)
danger (> 2.0)
faraday (1.0.1)
multipart-post (>= 1.2, < 3)
faraday-http-cache (2.2.0)
faraday (>= 0.8)
git (1.6.0)
rchardet (~> 1.8)
kramdown (2.1.0)
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
multipart-post (2.1.1)
nap (1.1.0)
no_proxy_fix (0.1.2)
octokit (4.18.0)
faraday (>= 0.9)
sawyer (~> 0.8.0, >= 0.5.3)
open4 (1.3.4)
ox (2.13.2)
public_suffix (4.0.4)
rchardet (1.8.0)
sawyer (0.8.2)
addressable (>= 2.3.5)
faraday (> 0.8, < 2.0)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
unicode-display_width (1.7.0)

PLATFORMS
ruby

DEPENDENCIES
danger
danger-checkstyle_format
danger-junit

BUNDLED WITH
2.1.4

0 comments on commit fcac8c7

Please sign in to comment.