Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dispatch-build-bottle: support self-hosted Linux and unified workflow #11600

Merged
merged 1 commit into from Jun 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions Library/Homebrew/cli/args.rbi
Expand Up @@ -96,6 +96,15 @@ module Homebrew
sig { returns(T::Boolean) }
def upload?; end

sig { returns(T::Boolean) }
def linux?; end

sig { returns(T::Boolean) }
def linux_self_hosted?; end

sig { returns(T::Boolean) }
def wheezy?; end

sig { returns(T::Boolean) }
def total?; end

Expand Down
26 changes: 15 additions & 11 deletions Library/Homebrew/dev-cmd/dispatch-build-bottle.rb
Expand Up @@ -27,8 +27,12 @@ def dispatch_build_bottle_args
description: "Upload built bottles."
switch "--linux",
description: "Dispatch bottle for Linux (using GitHub runners)."
switch "--linux-self-hosted",
description: "Dispatch bottle for Linux (using self-hosted runner)."
switch "--wheezy",
description: "Use Debian Wheezy container for building the bottle on Linux."
Comment on lines +32 to +33
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about --linux-wheezy here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or even linux-debian-wheezy?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the description enough :)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels a bit weird to me not not reference it in this flag but have it as --linux-* in others.


conflicts "--macos", "--linux"
conflicts "--macos", "--linux", "--linux-self-hosted"
named_args :formula, min: 1
end
end
Expand All @@ -45,7 +49,7 @@ def dispatch_build_bottle
# TODO: remove when core taps are merged
repo.gsub!("linux", "home") unless args.tap

if (macos = args.macos)
runner = if (macos = args.macos)
# We accept runner name syntax (11-arm64) or bottle syntax (arm64_big_sur)
os, arch = macos.yield_self do |s|
tag = Utils::Bottles::Tag.from_symbol(s.to_sym)
Expand All @@ -55,33 +59,33 @@ def dispatch_build_bottle
[MacOS::Version.new(os), arch&.to_sym]
end

macos_label = if arch.present? && arch != :x86_64
if arch.present? && arch != :x86_64
"#{os}-#{arch}"
else
os.to_s
end

dispatching_for = "macOS #{macos_label}"
elsif T.unsafe(args).linux?
workflow = args.workflow || "linux-#{workflow}"
dispatching_for = "Linux"
elsif args.linux?
"ubuntu-latest"
elsif args.linux_self_hosted?
"linux-self-hosted-1"
else
raise UsageError, "Must specify --macos or --linux option"
raise UsageError, "Must specify --macos or --linux or --linux-self-hosted option"
end

args.named.to_resolved_formulae.each do |formula|
# Required inputs
inputs = {
runner: runner,
formula: formula.name,
}

# Optional inputs
# These cannot be passed as nil to GitHub API
inputs[:macos] = macos_label if args.macos
inputs[:issue] = args.issue if args.issue
inputs[:upload] = args.upload?.to_s if args.upload?
inputs[:wheezy] = args.wheezy?.to_s if args.wheezy?

ohai "Dispatching #{tap} bottling request of formula \"#{formula.name}\" for #{dispatching_for}"
ohai "Dispatching #{tap} bottling request of formula \"#{formula.name}\" for #{runner}"
GitHub.workflow_dispatch_event(user, repo, workflow, ref, inputs)
end
end
Expand Down