From 08097fb6287e0753c88de2fdbc60a2d7976d78a7 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Tue, 23 Jan 2024 19:34:25 +0100 Subject: [PATCH] Fixes #37092 - Use minitest_reporters_github in GHA This is a specialized reporter to provide GitHub annotations on failure. These annotations can be seen in the changes files tab. --- bundler.d/test.rb | 1 + test/test_report_helper.rb | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/bundler.d/test.rb b/bundler.d/test.rb index 41c07678472..cc0e935014b 100644 --- a/bundler.d/test.rb +++ b/bundler.d/test.rb @@ -4,6 +4,7 @@ gem 'minitest-reporters', '~> 1.4', :require => false gem 'minitest-retry', '~> 0.0', :require => false gem 'minitest-spec-rails', '~> 7.1' + gem 'minitest_reporters_github', '~> 1.0', :require => false gem 'capybara', '~> 3.33', :require => false gem 'show_me_the_cookies', '~> 6.0', :require => false gem 'database_cleaner', '~> 1.3', :require => false diff --git a/test/test_report_helper.rb b/test/test_report_helper.rb index 8e9fe55c435..92ae972e577 100644 --- a/test/test_report_helper.rb +++ b/test/test_report_helper.rb @@ -1,7 +1,16 @@ require 'minitest/reporters' -junit_reporter = Minitest::Reporters::JUnitReporter.new('jenkins/reports/unit/') -meantime_reporter = Minitest::Reporters::MeanTimeReporter.new(previous_runs_filename: Rails.root.join('tmp', 'foreman_minitest_reporters_previous_run'), - report_filename: Rails.root.join('tmp', 'foreman_minitest_reporters_report')) +if ENV['GITHUB_ACTIONS'] == 'true' + require 'minitest_reporters_github' + reporters = [MinitestReportersGithub.new] +else + reporters = [ + Minitest::Reporters::JUnitReporter.new('jenkins/reports/unit/'), + Minitest::Reporters::MeanTimeReporter.new( + previous_runs_filename: Rails.root.join('tmp', 'foreman_minitest_reporters_previous_run'), + report_filename: Rails.root.join('tmp', 'foreman_minitest_reporters_report') + ), + ] +end -Minitest::Reporters.use! [junit_reporter, meantime_reporter] +Minitest::Reporters.use! reporters