dev-cmd/dispatch-build-bottle: allow an array of macOS runners

This commit is contained in:
Bo Anderson 2021-10-24 05:13:11 +01:00
parent 890190c0f3
commit c6dbff43bd
No known key found for this signature in database
GPG Key ID: 3DB94E204E137D65
2 changed files with 22 additions and 20 deletions

View File

@ -168,7 +168,7 @@ module Homebrew
sig { returns(T.nilable(String)) }
def tap; end
sig { returns(T.nilable(String)) }
sig { returns(T.nilable(T::Array[String])) }
def macos; end
sig { returns(T.nilable(T::Array[String])) }

View File

@ -21,8 +21,8 @@ module Homebrew
description: "Build timeout (in minutes, default: 60)."
flag "--issue=",
description: "If specified, post a comment to this issue number if the job fails."
flag "--macos=",
description: "Version of macOS the bottle should be built for."
comma_array "--macos=",
description: "Version(s) of macOS the bottle should be built for."
flag "--workflow=",
description: "Dispatch specified workflow (default: `dispatch-build-bottle.yml`)."
switch "--upload",
@ -51,9 +51,10 @@ module Homebrew
# TODO: remove when core taps are merged
repo.gsub!("linux", "home") unless args.tap
runner = if (macos = args.macos)
runners = if (macos = args.macos&.compact_blank) && macos.present?
macos.map do |element|
# We accept runner name syntax (11-arm64) or bottle syntax (arm64_big_sur)
os, arch = macos.yield_self do |s|
os, arch = element.yield_self do |s|
tag = Utils::Bottles::Tag.from_symbol(s.to_sym)
[tag.to_macos_version, tag.arch]
rescue ArgumentError, MacOSVersionError
@ -66,10 +67,11 @@ module Homebrew
else
os.to_s
end
end
elsif args.linux?
"ubuntu-latest"
["ubuntu-latest"]
elsif args.linux_self_hosted?
"linux-self-hosted-1"
["linux-self-hosted-1"]
else
raise UsageError, "Must specify --macos or --linux or --linux-self-hosted option"
end
@ -77,7 +79,7 @@ module Homebrew
args.named.to_resolved_formulae.each do |formula|
# Required inputs
inputs = {
runner: runner,
runner: runners.join(","),
formula: formula.name,
}
@ -88,7 +90,7 @@ module Homebrew
inputs[:upload] = args.upload?.to_s if args.upload?
inputs[:wheezy] = args.linux_wheezy?.to_s if args.linux_wheezy?
ohai "Dispatching #{tap} bottling request of formula \"#{formula.name}\" for #{runner}"
ohai "Dispatching #{tap} bottling request of formula \"#{formula.name}\" for #{runners.join(", ")}"
GitHub.workflow_dispatch_event(user, repo, workflow, ref, inputs)
end
end