@@ -7,7 +7,6 @@ module ExcludeMessage
77end
88
99require "minitest/excludes"
10- require "minitest/github_action_reporter"
1110
1211# This gives great visibility on schema dump related tests, but
1312# some rails specific messages are then ignored.
@@ -152,21 +151,34 @@ def with_postgresql_datetime_type(type)
152151
153152ActiveRecord ::TestCase . prepend ( SetDatetimeInCockroachDBAdapter )
154153
155- module Minitest
156- module GithubActionReporterExt
157- def gh_link ( loc )
158- return super unless loc . include? ( "/gems/" )
154+ if ENV [ "GITHUB_ACTIONS" ] || true
155+ require "minitest/github_action_reporter"
159156
160- path , _ , line = loc [ %r(/(?:test|spec|lib)/.*) ] [ 1 ..] . rpartition ( ":" )
157+ module Minitest
158+ module GithubActionReporterExt
159+ def gh_link ( loc )
160+ return super unless loc . include? ( "/gems/" )
161161
162- rails_version = "v#{ ActiveRecord ::VERSION ::STRING } "
163- "#{ ENV [ "GITHUB_SERVER_URL" ] } /rails/rails/blob/#{ rails_version } /activerecord/#{ path } #L#{ line } "
164- rescue
165- warn "Failed to generate link for #{ loc } "
166- super
162+ path , _ , line = loc [ %r(/(?:test|spec|lib)/.*) ] [ 1 ..] . rpartition ( ":" )
163+
164+ rails_version = "v#{ ActiveRecord ::VERSION ::STRING } "
165+ "#{ ENV [ "GITHUB_SERVER_URL" ] } /rails/rails/blob/#{ rails_version } /activerecord/#{ path } #L#{ line } "
166+ rescue
167+ warn "Failed to generate link for #{ loc } "
168+ super
169+ end
167170 end
171+ GithubActionReporter . prepend ( GithubActionReporterExt )
172+ end
173+
174+ # Using '--fail-fast' may cause the github_action_reporter to not
175+ # catch the error or failure in time. We make sure it appears first.
176+ Minitest . load_plugins
177+ github_action_index = Minitest . extensions . index ( "github_action_reporter" )
178+ if github_action_index &.positive?
179+ Minitest . extensions [ 0 ] , Minitest . extensions [ github_action_index ] =
180+ Minitest . extensions [ github_action_index ] , Minitest . extensions [ 0 ]
168181 end
169- GithubActionReporter . prepend ( GithubActionReporterExt )
170182end
171183
172184if ENV [ 'TRACE_LIB' ]
0 commit comments