Merge pull request #15309 from carlocab/longer-big-sur-timeout
github_runner_matrix: set `timeout` on macOS
This commit is contained in:
commit
e69e8e04c1
@ -13,7 +13,7 @@ class GitHubRunnerMatrix
|
||||
RunnerSpec = T.type_alias { T.any(LinuxRunnerSpec, MacOSRunnerSpec) }
|
||||
private_constant :RunnerSpec
|
||||
|
||||
MacOSRunnerSpecHash = T.type_alias { { name: String, runner: String, cleanup: T::Boolean } }
|
||||
MacOSRunnerSpecHash = T.type_alias { { name: String, runner: String, timeout: Integer, cleanup: T::Boolean } }
|
||||
private_constant :MacOSRunnerSpecHash
|
||||
|
||||
LinuxRunnerSpecHash = T.type_alias do
|
||||
@ -108,6 +108,7 @@ class GitHubRunnerMatrix
|
||||
|
||||
github_run_id = ENV.fetch("GITHUB_RUN_ID")
|
||||
github_run_attempt = ENV.fetch("GITHUB_RUN_ATTEMPT")
|
||||
timeout = ENV.fetch("HOMEBREW_MACOS_TIMEOUT").to_i
|
||||
ephemeral_suffix = +"-#{github_run_id}-#{github_run_attempt}"
|
||||
ephemeral_suffix << "-deps" if @dependent_matrix
|
||||
ephemeral_suffix.freeze
|
||||
@ -116,9 +117,16 @@ class GitHubRunnerMatrix
|
||||
macos_version = OS::Mac::Version.new(version)
|
||||
next if macos_version.unsupported_release?
|
||||
|
||||
# Intel Big Sur is a bit slower than the other runners,
|
||||
# so give it a little bit more time. The comparison below
|
||||
# should be `==`, but it returns typecheck errors.
|
||||
runner_timeout = timeout
|
||||
runner_timeout += 30 if macos_version <= :big_sur
|
||||
|
||||
spec = MacOSRunnerSpec.new(
|
||||
name: "macOS #{version}-x86_64",
|
||||
runner: "#{version}#{ephemeral_suffix}",
|
||||
timeout: runner_timeout,
|
||||
cleanup: false,
|
||||
)
|
||||
@runners << create_runner(:macos, :x86_64, spec, macos_version)
|
||||
@ -126,15 +134,14 @@ class GitHubRunnerMatrix
|
||||
next unless macos_version >= :big_sur
|
||||
|
||||
# Use bare metal runner when testing dependents on ARM64 Monterey.
|
||||
use_ephemeral = (macos_version >= :ventura && @dependent_matrix) ||
|
||||
(macos_version >= :monterey && !@dependent_matrix)
|
||||
use_ephemeral = macos_version >= (@dependent_matrix ? :ventura : :monterey)
|
||||
runner, cleanup = if use_ephemeral
|
||||
["#{version}-arm64#{ephemeral_suffix}", false]
|
||||
else
|
||||
["#{version}-arm64", true]
|
||||
end
|
||||
|
||||
spec = MacOSRunnerSpec.new(name: "macOS #{version}-arm64", runner: runner, cleanup: cleanup)
|
||||
spec = MacOSRunnerSpec.new(name: "macOS #{version}-arm64", runner: runner, timeout: timeout, cleanup: cleanup)
|
||||
@runners << create_runner(:macos, :arm64, spec, macos_version)
|
||||
end
|
||||
|
||||
@ -154,9 +161,12 @@ class GitHubRunnerMatrix
|
||||
arch = runner.arch
|
||||
macos_version = runner.macos_version
|
||||
|
||||
compatible_formulae.select! { |formula| formula.public_send(:"#{platform}_compatible?") }
|
||||
compatible_formulae.select! { |formula| formula.public_send(:"#{arch}_compatible?") }
|
||||
compatible_formulae.select! { |formula| formula.compatible_with?(macos_version) } if macos_version
|
||||
compatible_formulae.select! do |formula|
|
||||
next false if macos_version && !formula.compatible_with?(macos_version)
|
||||
|
||||
formula.public_send(:"#{platform}_compatible?") &&
|
||||
formula.public_send(:"#{arch}_compatible?")
|
||||
end
|
||||
|
||||
compatible_formulae.present?
|
||||
end
|
||||
@ -178,9 +188,12 @@ class GitHubRunnerMatrix
|
||||
compatible_dependents = formula.dependents(platform: platform, arch: arch, macos_version: macos_version&.to_sym)
|
||||
.dup
|
||||
|
||||
compatible_dependents.select! { |dependent_f| dependent_f.public_send(:"#{platform}_compatible?") }
|
||||
compatible_dependents.select! { |dependent_f| dependent_f.public_send(:"#{arch}_compatible?") }
|
||||
compatible_dependents.select! { |dependent_f| dependent_f.compatible_with?(macos_version) } if macos_version
|
||||
compatible_dependents.select! do |dependent_f|
|
||||
next false if macos_version && !dependent_f.compatible_with?(macos_version)
|
||||
|
||||
dependent_f.public_send(:"#{platform}_compatible?") &&
|
||||
dependent_f.public_send(:"#{arch}_compatible?")
|
||||
end
|
||||
|
||||
# These arrays will generally have been generated by different Formulary caches,
|
||||
# so we can only compare them by name and not directly.
|
||||
|
||||
@ -4,13 +4,15 @@
|
||||
class MacOSRunnerSpec < T::Struct
|
||||
const :name, String
|
||||
const :runner, String
|
||||
const :timeout, Integer
|
||||
const :cleanup, T::Boolean
|
||||
|
||||
sig { returns({ name: String, runner: String, cleanup: T::Boolean }) }
|
||||
sig { returns({ name: String, runner: String, timeout: Integer, cleanup: T::Boolean }) }
|
||||
def to_h
|
||||
{
|
||||
name: name,
|
||||
runner: runner,
|
||||
timeout: timeout,
|
||||
cleanup: cleanup,
|
||||
}
|
||||
end
|
||||
|
||||
@ -16,6 +16,7 @@ describe "brew determine-test-runners" do
|
||||
{
|
||||
"HOMEBREW_LINUX_RUNNER" => linux_runner,
|
||||
"HOMEBREW_LINUX_CLEANUP" => "false",
|
||||
"HOMEBREW_MACOS_TIMEOUT" => "90",
|
||||
"GITHUB_RUN_ID" => ephemeral_suffix.split("-").second,
|
||||
"GITHUB_RUN_ATTEMPT" => ephemeral_suffix.split("-").third,
|
||||
}.freeze
|
||||
|
||||
@ -7,6 +7,7 @@ describe GitHubRunnerMatrix do
|
||||
before do
|
||||
allow(ENV).to receive(:fetch).with("HOMEBREW_LINUX_RUNNER").and_return("ubuntu-latest")
|
||||
allow(ENV).to receive(:fetch).with("HOMEBREW_LINUX_CLEANUP").and_return("false")
|
||||
allow(ENV).to receive(:fetch).with("HOMEBREW_MACOS_TIMEOUT").and_return("90")
|
||||
allow(ENV).to receive(:fetch).with("GITHUB_RUN_ID").and_return("12345")
|
||||
allow(ENV).to receive(:fetch).with("GITHUB_RUN_ATTEMPT").and_return("1")
|
||||
end
|
||||
|
||||
@ -4,7 +4,7 @@ require "github_runner"
|
||||
|
||||
describe GitHubRunner do
|
||||
let(:runner) do
|
||||
spec = MacOSRunnerSpec.new(name: "macOS 11-arm64", runner: "11-arm64", cleanup: true)
|
||||
spec = MacOSRunnerSpec.new(name: "macOS 11-arm64", runner: "11-arm64", timeout: 90, cleanup: true)
|
||||
version = OS::Mac::Version.new("11")
|
||||
described_class.new(platform: :macos, arch: :arm64, spec: spec, macos_version: version)
|
||||
end
|
||||
|
||||
@ -3,10 +3,10 @@
|
||||
require "macos_runner_spec"
|
||||
|
||||
describe MacOSRunnerSpec do
|
||||
let(:spec) { described_class.new(name: "macOS 11-arm64", runner: "11-arm64", cleanup: true) }
|
||||
let(:spec) { described_class.new(name: "macOS 11-arm64", runner: "11-arm64", timeout: 90, cleanup: true) }
|
||||
|
||||
it "has immutable attributes" do
|
||||
[:name, :runner, :cleanup].each do |attribute|
|
||||
[:name, :runner, :timeout, :cleanup].each do |attribute|
|
||||
expect(spec.respond_to?("#{attribute}=")).to be(false)
|
||||
end
|
||||
end
|
||||
|
||||
@ -89,7 +89,7 @@ class TestRunnerFormula
|
||||
def dependents(platform:, arch:, macos_version:)
|
||||
cache_key = :"#{platform}_#{arch}_#{macos_version}"
|
||||
|
||||
@dependent_hash.fetch(cache_key) do
|
||||
@dependent_hash[cache_key] ||= begin
|
||||
all = eval_all || Homebrew::EnvConfig.eval_all?
|
||||
formula_selector, eval_all_env = if all
|
||||
[:all, "1"]
|
||||
@ -110,5 +110,7 @@ class TestRunnerFormula
|
||||
Homebrew::SimulateSystem.clear
|
||||
end
|
||||
end
|
||||
|
||||
@dependent_hash.fetch(cache_key)
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user