From a9c8556b9daf3bf56e305255dd9ccba86ee934cd Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Sun, 12 May 2024 04:38:16 +0800 Subject: [PATCH] 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. --- Library/Homebrew/github_runner_matrix.rb | 5 ++++- .../Homebrew/test/dev-cmd/determine-test-runners_spec.rb | 6 +++--- Library/Homebrew/test/github_runner_matrix_spec.rb | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/github_runner_matrix.rb b/Library/Homebrew/github_runner_matrix.rb index ed82b51719..cf1715f2d7 100644 --- a/Library/Homebrew/github_runner_matrix.rb +++ b/Library/Homebrew/github_runner_matrix.rb @@ -67,6 +67,7 @@ class GitHubRunnerMatrix SELF_HOSTED_LINUX_RUNNER = "linux-self-hosted-1" GITHUB_ACTIONS_LONG_TIMEOUT = 4320 + GITHUB_ACTIONS_SHORT_TIMEOUT = 120 sig { returns(LinuxRunnerSpec) } def linux_runner_spec @@ -120,9 +121,11 @@ class GitHubRunnerMatrix end 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" + 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_runner ||= @dependent_matrix use_github_runner &&= runner_timeout <= GITHUB_ACTIONS_RUNNER_TIMEOUT diff --git a/Library/Homebrew/test/dev-cmd/determine-test-runners_spec.rb b/Library/Homebrew/test/dev-cmd/determine-test-runners_spec.rb index 75125ecfb2..32cd05b0c1 100644 --- a/Library/Homebrew/test/dev-cmd/determine-test-runners_spec.rb +++ b/Library/Homebrew/test/dev-cmd/determine-test-runners_spec.rb @@ -22,9 +22,9 @@ RSpec.describe Homebrew::DevCmd::DetermineTestRunners do let(:ephemeral_suffix) { "-12345" } let(:runner_env) do { - "HOMEBREW_LINUX_RUNNER" => linux_runner, - "HOMEBREW_MACOS_TIMEOUT" => "90", - "GITHUB_RUN_ID" => ephemeral_suffix.split("-").second, + "HOMEBREW_LINUX_RUNNER" => linux_runner, + "HOMEBREW_MACOS_LONG_TIMEOUT" => "false", + "GITHUB_RUN_ID" => ephemeral_suffix.split("-").second, }.freeze end let(:all_runners) do diff --git a/Library/Homebrew/test/github_runner_matrix_spec.rb b/Library/Homebrew/test/github_runner_matrix_spec.rb index 01bed6f608..99f457e01e 100644 --- a/Library/Homebrew/test/github_runner_matrix_spec.rb +++ b/Library/Homebrew/test/github_runner_matrix_spec.rb @@ -6,7 +6,7 @@ require "test/support/fixtures/testball" RSpec.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_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("GITHUB_RUN_ID").and_return("12345") end