Skip to content

Commit 4c6c3f9

Browse files
committed
fix(ci): Github Action reporter priority
When using `--fail-fast` option the rails reporter could raise before the Github Action reporter records the failure. Hence we invert them. Signed-off-by: Ulysse Buonomo <[email protected]>
1 parent 341c20f commit 4c6c3f9

File tree

3 files changed

+25
-14
lines changed

3 files changed

+25
-14
lines changed

test/cases/helper_cockroachdb.rb

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ module ExcludeMessage
77
end
88

99
require "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

153152
ActiveRecord::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)
170182
end
171183

172184
if ENV['TRACE_LIB']

test/support/copy_cat.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def warn(message, category: nil, **kwargs)
2020

2121
# Copy methods from The original rails class to our adapter.
2222
# While copying, we can rewrite the source code of the method using
23-
# ast. Use `debug: true` to lead you true that process.
23+
# ast. Use `debug: true` to lead you through that process.
2424
def copy_methods(new_klass, old_klass, *methods, debug: false, &block)
2525
methods.each do |met|
2626
file, _ = old_klass.instance_method(met).source_location

test/support/exclude_from_transactional_tests.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ def self.prepended(base)
1818
end
1919

2020
def before_setup
21-
# binding.irb if self.class.non_transactional_list.include?(@NAME.to_s)
2221
@old_use_transactional_tests = self.use_transactional_tests
2322
if @old_use_transactional_tests # stay false if false
2423
self.use_transactional_tests = !self.class.non_transactional_list.include?(@NAME.to_s)

0 commit comments

Comments
 (0)