diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..5154b3f --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.6 diff --git a/Dangerfile b/Dangerfile new file mode 100644 index 0000000..af24e3e --- /dev/null +++ b/Dangerfile @@ -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: (?(?:\/.+)+\.kt): \((?\d+), (?\d+)\): (?.*)/ +error_pattern = /e: (?(?:\/.+)+\.kt): \((?\d+), (?\d+)\): (?.*)/ + +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 diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..2b62d4d --- /dev/null +++ b/Gemfile @@ -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' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..2bede9e --- /dev/null +++ b/Gemfile.lock @@ -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