From 947a37d79497f860faa5c7f2cb76cebb272bfe3a Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Wed, 26 Apr 2023 11:51:40 +0800 Subject: [PATCH 1/2] github_runner_matrix: test dependents on GitHub runners This makes our dependent tests run on a GitHub macOS runner if compatible with the requested timeout. This will also allow builds on a GitHub runner on macOS if requested with the environment variable `HOMEBREW_MACOS_BUILD_ON_GITHUB_RUNNER`. This environment variable will need to be set in the workflow as appropriate (e.g. when requested by a label). --- Library/Homebrew/github_runner_matrix.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/github_runner_matrix.rb b/Library/Homebrew/github_runner_matrix.rb index 3cee6e7acd..f1ec17aeb7 100644 --- a/Library/Homebrew/github_runner_matrix.rb +++ b/Library/Homebrew/github_runner_matrix.rb @@ -100,6 +100,9 @@ class GitHubRunnerMatrix runner.freeze end + NEWEST_GITHUB_ACTIONS_MACOS_RUNNER = :ventura + GITHUB_ACTIONS_RUNNER_TIMEOUT = 360 + sig { void } def generate_runners! return if @runners.present? @@ -109,6 +112,8 @@ 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 + use_github_runner = ENV.fetch("HOMEBREW_MACOS_BUILD_ON_GITHUB_RUNNER", "false") == "true" + ephemeral_suffix = +"-#{github_run_id}-#{github_run_attempt}" ephemeral_suffix << "-deps" if @dependent_matrix ephemeral_suffix.freeze @@ -123,9 +128,18 @@ class GitHubRunnerMatrix runner_timeout = timeout runner_timeout += 30 if macos_version <= :big_sur + # Use GitHub Actions macOS Runner for testing dependents if compatible with timeout. + runner = if (@dependent_matrix || use_github_runner) && + macos_version <= NEWEST_GITHUB_ACTIONS_MACOS_RUNNER && + runner_timeout <= GITHUB_ACTIONS_RUNNER_TIMEOUT + "macos-#{version}" + else + "#{version}#{ephemeral_suffix}" + end + spec = MacOSRunnerSpec.new( name: "macOS #{version}-x86_64", - runner: "#{version}#{ephemeral_suffix}", + runner: runner, timeout: runner_timeout, cleanup: false, ) From 3bfe3e30371280c6a00b504f354d935f95a1b42b Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Thu, 27 Apr 2023 07:20:58 +0800 Subject: [PATCH 2/2] github_runner_matrix: fix tests --- Library/Homebrew/test/github_runner_matrix_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/Library/Homebrew/test/github_runner_matrix_spec.rb b/Library/Homebrew/test/github_runner_matrix_spec.rb index 92201d3693..48ba95d5da 100644 --- a/Library/Homebrew/test/github_runner_matrix_spec.rb +++ b/Library/Homebrew/test/github_runner_matrix_spec.rb @@ -8,6 +8,7 @@ describe GitHubRunnerMatrix 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("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_ATTEMPT").and_return("1") end