From 79714113720385bcc486d614f2b8f19ca0d83073 Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Fri, 25 Jun 2021 19:40:43 +0200 Subject: [PATCH] dispatch-build-bottle: support self-hosted Linux and unified workflow --- Library/Homebrew/cli/args.rbi | 9 +++++++ .../Homebrew/dev-cmd/dispatch-build-bottle.rb | 26 +++++++++++-------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/Library/Homebrew/cli/args.rbi b/Library/Homebrew/cli/args.rbi index 9b4429dd77..c9a822dce7 100644 --- a/Library/Homebrew/cli/args.rbi +++ b/Library/Homebrew/cli/args.rbi @@ -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 diff --git a/Library/Homebrew/dev-cmd/dispatch-build-bottle.rb b/Library/Homebrew/dev-cmd/dispatch-build-bottle.rb index 04c51e3cc9..45680f3128 100644 --- a/Library/Homebrew/dev-cmd/dispatch-build-bottle.rb +++ b/Library/Homebrew/dev-cmd/dispatch-build-bottle.rb @@ -27,8 +27,12 @@ module Homebrew 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." - conflicts "--macos", "--linux" + conflicts "--macos", "--linux", "--linux-self-hosted" named_args :formula, min: 1 end end @@ -45,7 +49,7 @@ module Homebrew # 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) @@ -55,33 +59,33 @@ module Homebrew [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