Skip to content

Commit 0e6e4f5

Browse files
committed
feat: offer ubuntu for eligable casks
1 parent 145cd60 commit 0e6e4f5

File tree

2 files changed

+70
-6
lines changed

2 files changed

+70
-6
lines changed

Library/Homebrew/cask/cask.rb

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,47 @@ def installed?
158158
installed_caskfile&.exist? || false
159159
end
160160

161+
sig { returns(T::Boolean) }
162+
def font?
163+
artifacts.all?(Artifact::Font)
164+
end
165+
166+
sig { returns(T::Boolean) }
167+
def supports_macos?
168+
return true if font?
169+
170+
true
171+
end
172+
173+
sig { returns(T::Boolean) }
174+
def supports_linux?
175+
return true if font?
176+
177+
return false if artifacts.any? do |artifact|
178+
[
179+
::Cask::Artifact::App,
180+
::Cask::Artifact::AudioUnitPlugin,
181+
::Cask::Artifact::Colorpicker,
182+
::Cask::Artifact::Dictionary,
183+
::Cask::Artifact::InputMethod,
184+
::Cask::Artifact::Installer,
185+
::Cask::Artifact::InternetPlugin,
186+
::Cask::Artifact::KeyboardLayout,
187+
::Cask::Artifact::Mdimporter,
188+
::Cask::Artifact::Pkg,
189+
::Cask::Artifact::Prefpane,
190+
::Cask::Artifact::Qlplugin,
191+
::Cask::Artifact::ScreenSaver,
192+
::Cask::Artifact::Service,
193+
::Cask::Artifact::Suite,
194+
::Cask::Artifact::VstPlugin,
195+
::Cask::Artifact::Vst3Plugin,
196+
].include?(artifact.class)
197+
end
198+
199+
@dsl.os.present?
200+
end
201+
161202
# The caskfile is needed during installation when there are
162203
# `*flight` blocks or the cask has multiple languages
163204
def caskfile_only?

Library/Homebrew/dev-cmd/generate-cask-ci-matrix.rb

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,25 @@ class GenerateCaskCiMatrix < AbstractCommand
1313
MAX_JOBS = 256
1414

1515
# Weight for each arch must add up to 1.0.
16-
INTEL_RUNNERS = T.let({
16+
X86_MACOS_RUNNERS = T.let({
1717
{ symbol: :sequoia, name: "macos-15-intel", arch: :intel } => 1.0,
1818
}.freeze, T::Hash[T::Hash[Symbol, T.any(Symbol, String)], Float])
19-
ARM_RUNNERS = T.let({
19+
X86_LINUX_RUNNERS = T.let({
20+
{ symbol: :linux, name: "ubuntu-24.04", arch: :intel } => 1.0,
21+
}.freeze, T::Hash[T::Hash[Symbol, T.any(Symbol, String)], Float])
22+
ARM_MACOS_RUNNERS = T.let({
2023
{ symbol: :sonoma, name: "macos-14", arch: :arm } => 0.0,
2124
{ symbol: :sequoia, name: "macos-15", arch: :arm } => 0.0,
2225
{ symbol: :tahoe, name: "macos-26", arch: :arm } => 1.0,
2326
}.freeze, T::Hash[T::Hash[Symbol, T.any(Symbol, String)], Float])
24-
RUNNERS = T.let(INTEL_RUNNERS.merge(ARM_RUNNERS).freeze,
27+
ARM_LINUX_RUNNERS = T.let({
28+
{ symbol: :linux, name: "ubuntu-24.04-arm", arch: :arm } => 1.0,
29+
}.freeze, T::Hash[T::Hash[Symbol, T.any(Symbol, String)], Float])
30+
MACOS_RUNNERS = T.let(X86_MACOS_RUNNERS.merge(ARM_MACOS_RUNNERS).freeze,
31+
T::Hash[T::Hash[Symbol, T.any(Symbol, String)], Float])
32+
LINUX_RUNNERS = T.let(X86_LINUX_RUNNERS.merge(ARM_LINUX_RUNNERS).freeze,
33+
T::Hash[T::Hash[Symbol, T.any(Symbol, String)], Float])
34+
RUNNERS = T.let(MACOS_RUNNERS.merge(LINUX_RUNNERS).freeze,
2535
T::Hash[T::Hash[Symbol, T.any(Symbol, String)], Float])
2636

2737
cmd_args do
@@ -57,7 +67,8 @@ def run
5767
pr_url = args.named if args.url?
5868
syntax_only = args.syntax_only?
5969

60-
repository = ENV.fetch("GITHUB_REPOSITORY", nil)
70+
# repository = ENV.fetch("GITHUB_REPOSITORY", nil)
71+
repository = "homebrew/homebrew-cask" # For testing outside GitHub Actions
6172
raise UsageError, "The `$GITHUB_REPOSITORY` environment variable must be set." if repository.blank?
6273

6374
tap = T.let(Tap.fetch(repository), Tap)
@@ -118,7 +129,8 @@ def run
118129
sig { params(cask: Cask::Cask).returns(T::Hash[T::Hash[Symbol, T.any(Symbol, String)], Float]) }
119130
def filter_runners(cask)
120131
filtered_macos_runners = RUNNERS.select do |runner, _|
121-
cask.depends_on.macos.present? &&
132+
runner[:symbol] != :linux &&
133+
cask.depends_on.macos.present? &&
122134
cask.depends_on.macos.allows?(MacOSVersion.from_symbol(T.must(runner[:symbol]).to_sym))
123135
end
124136

@@ -128,6 +140,8 @@ def filter_runners(cask)
128140
RUNNERS.dup
129141
end
130142

143+
filtered_runners = filtered_runners.merge(LINUX_RUNNERS) if linux?(cask:)
144+
131145
archs = architectures(cask:)
132146
filtered_runners.select! do |runner, _|
133147
archs.include?(runner.fetch(:arch))
@@ -143,11 +157,18 @@ def architectures(cask:)
143157
cask.depends_on.arch.map { |arch| arch[:type] }.uniq.sort
144158
end
145159

160+
sig { params(cask: Cask::Cask).returns(T::Boolean) }
161+
def linux?(cask:)
162+
return true if cask.font?
163+
164+
cask.supports_linux?
165+
end
166+
146167
sig {
147168
params(available_runners: T::Hash[T::Hash[Symbol, T.any(Symbol, String)],
148169
Float]).returns(T::Hash[Symbol, T.any(Symbol, String)])
149170
}
150-
def random_runner(available_runners = ARM_RUNNERS)
171+
def random_runner(available_runners = ARM_MACOS_RUNNERS)
151172
T.must(available_runners.max_by { |(_, weight)| rand ** (1.0 / weight) })
152173
.first
153174
end
@@ -240,6 +261,8 @@ def generate_matrix(tap, labels: [], cask_names: [], skip_install: false, new_ca
240261
runners, multi_os = runners(cask:)
241262
runners.product(architectures(cask:)).filter_map do |runner, arch|
242263
native_runner_arch = arch == runner.fetch(:arch)
264+
# we don't need to run simulated archs on Linux
265+
next if runner.fetch(:symbol) == :linux && !native_runner_arch
243266
# If it's just a single OS test then we can just use the two real arch runners.
244267
next if !native_runner_arch && !multi_os
245268

0 commit comments

Comments
 (0)