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)) } sig { returns(T.nilable(String)) }
def tap; end def tap; end
sig { returns(T.nilable(String)) } sig { returns(T.nilable(T::Array[String])) }
def macos; end def macos; end
sig { returns(T.nilable(T::Array[String])) } sig { returns(T.nilable(T::Array[String])) }

View File

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