improve danger message

This commit is contained in:
BBG
2018-09-10 21:16:42 +08:00
parent d4cc311486
commit b3a78c4ac6
2 changed files with 11 additions and 16 deletions

View File

@ -7,20 +7,14 @@ require 'logger'
def run_pmdtester def run_pmdtester
Dir.chdir('..') do Dir.chdir('..') do
argv = ['-r', './pmd', '-b', "#{ENV['TRAVIS_BRANCH']}", '-p', 'FETCH_HEAD', '-m', 'online', '-a'] argv = ['-r', './pmd', '-b', "#{ENV['TRAVIS_BRANCH']}", '-p', 'FETCH_HEAD', '-m', 'online', '-a']
Process.fork do begin
begin runner = PmdTester::Runner.new(argv)
runner = PmdTester::Runner.new(argv) @new_errors, @removed_errors, @new_violations, @removed_violations = runner.run
introduce_new_pmd_errors = runner.run upload_report
warn("The PR may introduce new PMD errors!") if introduce_new_pmd_errors rescue StandardError => e
rescue StandardError => e warn("Running pmdtester failed, this message is mainly used to remind the maintainers of PMD.")
warn("Running pmdtester failed, this message is mainly used to remind the maintainers of PMD.") @logger.error "Running pmdtester failed: #{e.inspect}"
@logger.error "Running pmdtester failed: #{e.inspect}" end
exit 1
end
end
Process.wait
upload_report if $?.success?
end end
end end
@ -38,7 +32,8 @@ def upload_report
@logger.info "Successfully uploaded #{tar_filename} to chunk.io" @logger.info "Successfully uploaded #{tar_filename} to chunk.io"
# set value of sticky to true and the message is kept after new commits are submited to the PR # set value of sticky to true and the message is kept after new commits are submited to the PR
message("Please check the [regression diff report](#{report_url.chomp}/diff/index.html) to make sure that everything is expected", sticky: true) message("This changeset introduce #{@new_violations} new violations and #{@new_errors} new errors,\n" +
"removes #{@removed_violations} violations and #{@removed_errors} errors. [Full report](#{report_url.chomp}/diff/index.html)", sticky: true)
else else
@logger.error "Error while uploading #{tar_filename} to chunk.io: #{report_url}" @logger.error "Error while uploading #{tar_filename} to chunk.io: #{report_url}"
warn("Uploading the diff report failed, this message is mainly used to remind the maintainers of PMD.") warn("Uploading the diff report failed, this message is mainly used to remind the maintainers of PMD.")

View File

@ -1,6 +1,6 @@
source 'https://rubygems.org/' source 'https://rubygems.org/'
gem 'pmdtester', '~> 1.0.0.pre.beta3' gem 'pmdtester', :git => 'https://github.com/pmd/pmd-regression-tester.git'
gem 'danger', '~> 5.6', '>= 5.6' gem 'danger', '~> 5.6', '>= 5.6'
# This group is only needed for rendering release notes # This group is only needed for rendering release notes