Merge pull request #15356 from carlocab/macos-timeout

github_runner_matrix: improve macOS timeout handling
This commit is contained in:
Carlo Cabrera 2023-05-04 21:22:29 +08:00 committed by GitHub
commit 54adebb1de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -63,6 +63,7 @@ class GitHubRunnerMatrix
private private
SELF_HOSTED_LINUX_RUNNER = "linux-self-hosted-1" SELF_HOSTED_LINUX_RUNNER = "linux-self-hosted-1"
GITHUB_ACTIONS_LONG_TIMEOUT = 4320
sig { returns(LinuxRunnerSpec) } sig { returns(LinuxRunnerSpec) }
def linux_runner_spec def linux_runner_spec
@ -76,7 +77,7 @@ class GitHubRunnerMatrix
options: "--user=linuxbrew -e GITHUB_ACTIONS_HOMEBREW_SELF_HOSTED", options: "--user=linuxbrew -e GITHUB_ACTIONS_HOMEBREW_SELF_HOSTED",
}, },
workdir: "/github/home", workdir: "/github/home",
timeout: 4320, timeout: GITHUB_ACTIONS_LONG_TIMEOUT,
cleanup: linux_runner == SELF_HOSTED_LINUX_RUNNER, cleanup: linux_runner == SELF_HOSTED_LINUX_RUNNER,
) )
end end
@ -130,33 +131,41 @@ class GitHubRunnerMatrix
runner_timeout += 30 if macos_version <= :big_sur runner_timeout += 30 if macos_version <= :big_sur
# Use GitHub Actions macOS Runner for testing dependents if compatible with timeout. # Use GitHub Actions macOS Runner for testing dependents if compatible with timeout.
runner, cleanup = if (@dependent_matrix || use_github_runner) && runner, runner_timeout = if (@dependent_matrix || use_github_runner) &&
macos_version <= NEWEST_GITHUB_ACTIONS_MACOS_RUNNER && macos_version <= NEWEST_GITHUB_ACTIONS_MACOS_RUNNER &&
runner_timeout <= GITHUB_ACTIONS_RUNNER_TIMEOUT runner_timeout <= GITHUB_ACTIONS_RUNNER_TIMEOUT
["macos-#{version}", true] ["macos-#{version}", GITHUB_ACTIONS_RUNNER_TIMEOUT]
else else
["#{version}#{ephemeral_suffix}", false] ["#{version}#{ephemeral_suffix}", runner_timeout]
end end
spec = MacOSRunnerSpec.new( spec = MacOSRunnerSpec.new(
name: "macOS #{version}-x86_64", name: "macOS #{version}-x86_64",
runner: runner, runner: runner,
timeout: runner_timeout, timeout: runner_timeout,
cleanup: cleanup, cleanup: !runner.end_with?(ephemeral_suffix),
) )
@runners << create_runner(:macos, :x86_64, spec, macos_version) @runners << create_runner(:macos, :x86_64, spec, macos_version)
next if macos_version < :big_sur next if macos_version < :big_sur
runner = +"#{version}-arm64"
# Use bare metal runner when testing dependents on ARM64 Monterey. # Use bare metal runner when testing dependents on ARM64 Monterey.
use_ephemeral = macos_version >= (@dependent_matrix ? :ventura : :monterey) use_ephemeral = macos_version >= (@dependent_matrix ? :ventura : :monterey)
runner, cleanup = if use_ephemeral runner << ephemeral_suffix if use_ephemeral
["#{version}-arm64#{ephemeral_suffix}", false]
else
["#{version}-arm64", true]
end
spec = MacOSRunnerSpec.new(name: "macOS #{version}-arm64", runner: runner, timeout: timeout, cleanup: cleanup) runner.freeze
# The ARM runners are typically over twice as fast as the Intel runners.
runner_timeout = timeout
runner_timeout /= 2 if timeout < GITHUB_ACTIONS_LONG_TIMEOUT
spec = MacOSRunnerSpec.new(
name: "macOS #{version}-arm64",
runner: runner,
timeout: runner_timeout,
cleanup: !runner.end_with?(ephemeral_suffix),
)
@runners << create_runner(:macos, :arm64, spec, macos_version) @runners << create_runner(:macos, :arm64, spec, macos_version)
end end