@@ -60,6 +60,7 @@ def initialize(testing_formulae, deleted_formulae, all_supported:, dependent_mat
60
60
@dependent_matrix = T . let ( dependent_matrix , T ::Boolean )
61
61
@compatible_testing_formulae = T . let ( { } , T ::Hash [ GitHubRunner , T ::Array [ TestRunnerFormula ] ] )
62
62
@formulae_with_untested_dependents = T . let ( { } , T ::Hash [ GitHubRunner , T ::Array [ TestRunnerFormula ] ] )
63
+ @deploy_new_x86_64_runner = T . let ( all_supported , T ::Boolean )
63
64
64
65
@runners = T . let ( [ ] , T ::Array [ GitHubRunner ] )
65
66
generate_runners!
@@ -122,13 +123,30 @@ def create_runner(platform, arch, spec, macos_version = nil)
122
123
123
124
NEWEST_HOMEBREW_CORE_MACOS_RUNNER = :sequoia
124
125
OLDEST_HOMEBREW_CORE_MACOS_RUNNER = :ventura
125
- NEWEST_HOMEBREW_CORE_INTEL_MACOS_RUNNER = :sonoma
126
+ NEWEST_DEFAULT_HOMEBREW_CORE_INTEL_MACOS_RUNNER = :sonoma
126
127
127
128
sig { params ( macos_version : MacOSVersion ) . returns ( T ::Boolean ) }
128
129
def runner_enabled? ( macos_version )
129
130
macos_version <= NEWEST_HOMEBREW_CORE_MACOS_RUNNER && macos_version >= OLDEST_HOMEBREW_CORE_MACOS_RUNNER
130
131
end
131
132
133
+ NEW_INTEL_MACOS_MUST_BUILD_FORMULAE = %w[ pkg-config pkgconf ] . freeze
134
+
135
+ sig { returns ( T ::Boolean ) }
136
+ def deploy_new_x86_64_runner?
137
+ return true if @testing_formulae . any? { |f | NEW_INTEL_MACOS_MUST_BUILD_FORMULAE . include? ( f . name ) }
138
+ return true if @testing_formulae . any? { |f | f . formula . class . pour_bottle_only_if == :clt_installed }
139
+
140
+ Formula . all . any? do |formula |
141
+ next false if formula . class . pour_bottle_only_if != :clt_installed
142
+
143
+ non_test_dependencies = Dependency . expand ( formula , cache_key : "determine-test-runners" ) do |_ , dependency |
144
+ Dependency . prune if dependency . test?
145
+ end
146
+ non_test_dependencies . any? { |dep | @testing_formulae . map ( &:name ) . include? ( dep . name ) }
147
+ end
148
+ end
149
+
132
150
NEWEST_GITHUB_ACTIONS_INTEL_MACOS_RUNNER = :ventura
133
151
OLDEST_GITHUB_ACTIONS_INTEL_MACOS_RUNNER = :monterey
134
152
NEWEST_GITHUB_ACTIONS_ARM_MACOS_RUNNER = :sonoma
@@ -181,7 +199,13 @@ def generate_runners!
181
199
)
182
200
@runners << create_runner ( :macos , :arm64 , spec , macos_version )
183
201
184
- next if !@all_supported && macos_version > NEWEST_HOMEBREW_CORE_INTEL_MACOS_RUNNER
202
+ # `#deploy_new_x86_64_runner?` is expensive, so:
203
+ # - avoid calling it if we don't have to
204
+ # - cache the result to a variable to avoid calling it multiple times
205
+ if macos_version > NEWEST_DEFAULT_HOMEBREW_CORE_INTEL_MACOS_RUNNER &&
206
+ !( @deploy_new_x86_64_runner ||= deploy_new_x86_64_runner? )
207
+ next
208
+ end
185
209
186
210
github_runner_available = macos_version <= NEWEST_GITHUB_ACTIONS_INTEL_MACOS_RUNNER &&
187
211
macos_version >= OLDEST_GITHUB_ACTIONS_INTEL_MACOS_RUNNER
0 commit comments