Skip to content

Commit dd885b9

Browse files
committed
fix(ci): rails reporter priority
When using `--fail-fast` option the rails reporter could raise before other reporters records the failure. Hence we place rails last. Signed-off-by: Ulysse Buonomo <[email protected]>
1 parent e27240e commit dd885b9

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"]
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)
168172
end
169-
GithubActionReporter.prepend(GithubActionReporterExt)
173+
end
174+
175+
# Using '--fail-fast' may cause the rails plugin to raise Interrupt when recording
176+
# a test. This would prevent other plugins from recording it. Hence we make sure
177+
# that rails plugin is loaded last.
178+
Minitest.load_plugins
179+
if Minitest.extensions.include?("rails")
180+
Minitest.extensions.delete("rails")
181+
Minitest.extensions << "rails"
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)