github_runner_matrix: define timeout values in constants

This allows us to keep all information about timeout values here in
`brew` instead of both here and in Homebrew/core.

Will be needed after Homebrew/homebrew-core#171457.
This commit is contained in:
Carlo Cabrera 2024-05-12 04:38:16 +08:00
parent 71c4bfae79
commit a9c8556b9d
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0
3 changed files with 8 additions and 5 deletions

View File

@ -67,6 +67,7 @@ class GitHubRunnerMatrix
SELF_HOSTED_LINUX_RUNNER = "linux-self-hosted-1" SELF_HOSTED_LINUX_RUNNER = "linux-self-hosted-1"
GITHUB_ACTIONS_LONG_TIMEOUT = 4320 GITHUB_ACTIONS_LONG_TIMEOUT = 4320
GITHUB_ACTIONS_SHORT_TIMEOUT = 120
sig { returns(LinuxRunnerSpec) } sig { returns(LinuxRunnerSpec) }
def linux_runner_spec def linux_runner_spec
@ -120,9 +121,11 @@ class GitHubRunnerMatrix
end end
github_run_id = ENV.fetch("GITHUB_RUN_ID") github_run_id = ENV.fetch("GITHUB_RUN_ID")
runner_timeout = ENV.fetch("HOMEBREW_MACOS_TIMEOUT").to_i long_timeout = ENV.fetch("HOMEBREW_MACOS_LONG_TIMEOUT", "false") == "true"
use_github_runner = ENV.fetch("HOMEBREW_MACOS_BUILD_ON_GITHUB_RUNNER", "false") == "true" use_github_runner = ENV.fetch("HOMEBREW_MACOS_BUILD_ON_GITHUB_RUNNER", "false") == "true"
runner_timeout = long_timeout ? GITHUB_ACTIONS_LONG_TIMEOUT : GITHUB_ACTIONS_SHORT_TIMEOUT
# Use GitHub Actions macOS Runner for testing dependents if compatible with timeout. # Use GitHub Actions macOS Runner for testing dependents if compatible with timeout.
use_github_runner ||= @dependent_matrix use_github_runner ||= @dependent_matrix
use_github_runner &&= runner_timeout <= GITHUB_ACTIONS_RUNNER_TIMEOUT use_github_runner &&= runner_timeout <= GITHUB_ACTIONS_RUNNER_TIMEOUT

View File

@ -23,7 +23,7 @@ RSpec.describe Homebrew::DevCmd::DetermineTestRunners do
let(:runner_env) do let(:runner_env) do
{ {
"HOMEBREW_LINUX_RUNNER" => linux_runner, "HOMEBREW_LINUX_RUNNER" => linux_runner,
"HOMEBREW_MACOS_TIMEOUT" => "90", "HOMEBREW_MACOS_LONG_TIMEOUT" => "false",
"GITHUB_RUN_ID" => ephemeral_suffix.split("-").second, "GITHUB_RUN_ID" => ephemeral_suffix.split("-").second,
}.freeze }.freeze
end end

View File

@ -6,7 +6,7 @@ require "test/support/fixtures/testball"
RSpec.describe GitHubRunnerMatrix do RSpec.describe GitHubRunnerMatrix do
before do before do
allow(ENV).to receive(:fetch).with("HOMEBREW_LINUX_RUNNER").and_return("ubuntu-latest") allow(ENV).to receive(:fetch).with("HOMEBREW_LINUX_RUNNER").and_return("ubuntu-latest")
allow(ENV).to receive(:fetch).with("HOMEBREW_MACOS_TIMEOUT").and_return("90") allow(ENV).to receive(:fetch).with("HOMEBREW_MACOS_LONG_TIMEOUT", "false").and_return("false")
allow(ENV).to receive(:fetch).with("HOMEBREW_MACOS_BUILD_ON_GITHUB_RUNNER", "false").and_return("false") allow(ENV).to receive(:fetch).with("HOMEBREW_MACOS_BUILD_ON_GITHUB_RUNNER", "false").and_return("false")
allow(ENV).to receive(:fetch).with("GITHUB_RUN_ID").and_return("12345") allow(ENV).to receive(:fetch).with("GITHUB_RUN_ID").and_return("12345")
end end