Skip to content

Commit a473888

Browse files
authored
Merge pull request #19556 from Homebrew/deploy-arm64-on-prs
github_runner_matrix: deploy arm64 Linux runners on PRs with `:arm64_linux` bottles
2 parents 75de3aa + 84e50f5 commit a473888

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

Library/Homebrew/github_runner_matrix.rb

+22-7
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,13 @@ def active_runner_specs_hash
8383
GITHUB_ACTIONS_SHORT_TIMEOUT = 60
8484
private_constant :SELF_HOSTED_LINUX_RUNNER, :GITHUB_ACTIONS_LONG_TIMEOUT, :GITHUB_ACTIONS_SHORT_TIMEOUT
8585

86-
sig { returns(LinuxRunnerSpec) }
87-
def linux_runner_spec
88-
linux_runner = ENV.fetch("HOMEBREW_LINUX_RUNNER")
86+
sig { params(arch: Symbol).returns(LinuxRunnerSpec) }
87+
def linux_runner_spec(arch)
88+
linux_runner = case arch
89+
when :arm64 then "ubuntu-22.04-arm"
90+
when :x86_64 then ENV.fetch("HOMEBREW_LINUX_RUNNER")
91+
else raise "Unknown Linux architecture: #{arch}"
92+
end
8993

9094
LinuxRunnerSpec.new(
9195
name: "Linux",
@@ -108,14 +112,16 @@ def linux_runner_spec
108112
params(
109113
platform: Symbol,
110114
arch: Symbol,
111-
spec: RunnerSpec,
115+
spec: T.nilable(RunnerSpec),
112116
macos_version: T.nilable(MacOSVersion),
113117
).returns(GitHubRunner)
114118
}
115-
def create_runner(platform, arch, spec, macos_version = nil)
119+
def create_runner(platform, arch, spec = nil, macos_version = nil)
116120
raise "Unexpected platform: #{platform}" if VALID_PLATFORMS.exclude?(platform)
117121
raise "Unexpected arch: #{arch}" if VALID_ARCHES.exclude?(arch)
122+
raise "Missing `spec` argument" if spec.nil? && platform != :linux
118123

124+
spec ||= linux_runner_spec(arch)
119125
runner = GitHubRunner.new(platform:, arch:, spec:, macos_version:)
120126
runner.spec.testing_formulae += testable_formulae(runner)
121127
runner.active = active_runner?(runner)
@@ -141,7 +147,12 @@ def generate_runners!
141147
return if @runners.present?
142148

143149
if !@all_supported || ENV.key?("HOMEBREW_LINUX_RUNNER")
144-
@runners << create_runner(:linux, :x86_64, linux_runner_spec)
150+
@runners << create_runner(:linux, :x86_64)
151+
152+
if !@dependent_matrix &&
153+
@testing_formulae.any? { |tf| tf.formula.bottle_specification.tag?(Utils::Bottles.tag(:arm64_linux)) }
154+
@runners << create_runner(:linux, :arm64)
155+
end
145156
end
146157

147158
github_run_id = ENV.fetch("GITHUB_RUN_ID")
@@ -184,7 +195,11 @@ def generate_runners!
184195
)
185196
@runners << create_runner(:macos, :arm64, spec, macos_version)
186197

187-
next if !@all_supported && macos_version > NEWEST_HOMEBREW_CORE_INTEL_MACOS_RUNNER
198+
skip_intel_runner = !@all_supported && macos_version > NEWEST_HOMEBREW_CORE_INTEL_MACOS_RUNNER
199+
skip_intel_runner &&= @dependent_matrix || @testing_formulae.none? do |testing_formula|
200+
testing_formula.formula.bottle_specification.tag?(Utils::Bottles.tag(macos_version.to_sym))
201+
end
202+
next if skip_intel_runner
188203

189204
github_runner_available = macos_version.between?(OLDEST_GITHUB_ACTIONS_INTEL_MACOS_RUNNER,
190205
NEWEST_GITHUB_ACTIONS_INTEL_MACOS_RUNNER)

0 commit comments

Comments
 (0)