Class: Homebrew::DevCmd::GenerateCaskCiMatrix Private
- Inherits:
-
AbstractCommand
- Object
- AbstractCommand
- Homebrew::DevCmd::GenerateCaskCiMatrix
- Defined in:
- dev-cmd/generate-cask-ci-matrix.rb,
sorbet/rbi/dsl/homebrew/dev_cmd/generate_cask_ci_matrix.rbi
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
Defined Under Namespace
Classes: Args
Constant Summary collapse
- MAX_JOBS =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
256- X86_MACOS_RUNNERS =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
Weight for each arch must add up to 1.0.
T.let({ { symbol: :sequoia, name: "macos-15-intel", arch: :intel } => 1.0, }.freeze, T::Hash[T::Hash[Symbol, T.any(Symbol, String)], Float])
- X86_LINUX_RUNNERS =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
T.let({ { symbol: :linux, name: "ubuntu-22.04", arch: :intel } => 1.0, }.freeze, T::Hash[T::Hash[Symbol, T.any(Symbol, String)], Float])
- ARM_MACOS_RUNNERS =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
T.let({ { symbol: :sonoma, name: "macos-14", arch: :arm } => 0.0, { symbol: :sequoia, name: "macos-15", arch: :arm } => 0.0, { symbol: :tahoe, name: "macos-26", arch: :arm } => 1.0, }.freeze, T::Hash[T::Hash[Symbol, T.any(Symbol, String)], Float])
- ARM_LINUX_RUNNERS =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
T.let({ { symbol: :linux, name: "ubuntu-22.04-arm", arch: :arm } => 1.0, }.freeze, T::Hash[T::Hash[Symbol, T.any(Symbol, String)], Float])
- MACOS_RUNNERS =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
T.let(X86_MACOS_RUNNERS.merge(ARM_MACOS_RUNNERS).freeze, T::Hash[T::Hash[Symbol, T.any(Symbol, String)], Float])
- LINUX_RUNNERS =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
T.let(X86_LINUX_RUNNERS.merge(ARM_LINUX_RUNNERS).freeze, T::Hash[T::Hash[Symbol, T.any(Symbol, String)], Float])
- RUNNERS =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
T.let(MACOS_RUNNERS.merge(LINUX_RUNNERS).freeze, T::Hash[T::Hash[Symbol, T.any(Symbol, String)], Float])
Instance Method Summary collapse
- #args ⇒ Homebrew::DevCmd::GenerateCaskCiMatrix::Args private
- #filter_runners(cask) ⇒ Hash{Hash{Symbol => Symbol, String} => Float} private
- #run ⇒ void private
Methods inherited from AbstractCommand
command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?
Methods included from Utils::Output::Mixin
#odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_installed, #pretty_outdated, #pretty_uninstalled
Constructor Details
This class inherits a constructor from Homebrew::AbstractCommand
Instance Method Details
#args ⇒ Homebrew::DevCmd::GenerateCaskCiMatrix::Args
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
10 |
# File 'sorbet/rbi/dsl/homebrew/dev_cmd/generate_cask_ci_matrix.rbi', line 10 def args; end |
#filter_runners(cask) ⇒ Hash{Hash{Symbol => Symbol, String} => Float}
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'dev-cmd/generate-cask-ci-matrix.rb', line 129 def filter_runners(cask) filtered_macos_runners = RUNNERS.select do |runner, _| runner[:symbol] != :linux && cask.depends_on.macos.present? && cask.depends_on.macos.allows?(MacOSVersion.from_symbol(T.must(runner[:symbol]).to_sym)) end filtered_runners = if filtered_macos_runners.any? filtered_macos_runners else RUNNERS.dup end macos_archs = architectures(cask:, os: :macos) filtered_runners.select! do |runner, _| macos_archs.include?(runner.fetch(:arch)) end return filtered_runners unless cask.supports_linux? linux_archs = architectures(cask:, os: :linux) linux_runners = LINUX_RUNNERS.select do |runner, _| linux_archs.include?(runner.fetch(:arch)) end filtered_runners.merge(linux_runners) end |
#run ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'dev-cmd/generate-cask-ci-matrix.rb', line 63 def run skip_install = args.skip_install? new_cask = args.new? casks = args.named if args.casks? pr_url = args.named if args.url? syntax_only = args.syntax_only? repository = ENV.fetch("GITHUB_REPOSITORY", nil) raise UsageError, "The `$GITHUB_REPOSITORY` environment variable must be set." if repository.blank? tap = T.let(Tap.fetch(repository), Tap) unless syntax_only raise UsageError, "Either `--cask` or `--url` must be specified." if !args.casks? && !args.url? raise UsageError, "Please provide a `--cask` or `--url` argument." if casks.blank? && pr_url.blank? end raise UsageError, "Only one `--url` can be specified." if pr_url&.count&.> 1 labels = if pr_url && (first_pr_url = pr_url.first) pr = GitHub::API.open_rest(first_pr_url) pr.fetch("labels").map { |l| l.fetch("name") } else [] end runner = random_runner[:name] syntax_job = { name: "syntax", tap: tap.name, runner:, } matrix = [syntax_job] if !syntax_only && !labels&.include?("ci-syntax-only") cask_jobs = if casks&.any? generate_matrix(tap, labels:, cask_names: casks, skip_install:, new_cask:) else generate_matrix(tap, labels:, skip_install:, new_cask:) end if cask_jobs.any? # If casks were changed, skip `audit` for whole tap. syntax_job[:skip_audit] = true # The syntax job only runs `style` at this point, which should work on Linux. # Running on macOS is currently faster though, since `homebrew/cask` and # `homebrew/core` are already tapped on macOS CI machines. # syntax_job[:runner] = "ubuntu-latest" end matrix += cask_jobs end syntax_job[:name] += " (#{syntax_job[:runner]})" puts JSON.pretty_generate(matrix) github_output = ENV.fetch("GITHUB_OUTPUT", nil) return unless github_output File.open(ENV.fetch("GITHUB_OUTPUT"), "a") do |f| f.puts "matrix=#{JSON.generate(matrix)}" end end |