Skip to content

Commit 3f4425c

Browse files
committed
generate-cask-ci-matrix: respect on_linux architecture constraints
1 parent 1ee9e05 commit 3f4425c

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,12 @@ def architectures(cask:, os: :macos, arch: :arm)
175175
cask.refresh
176176

177177
if cask.depends_on.arch.blank?
178-
architectures = if cask.artifacts.any?(Cask::Artifact::AppImage)
179-
[:intel]
178+
# If the Cask does not define a general architecture requirement,
179+
# check if there is one specific to Linux.
180+
architectures = if (linux_archs = Homebrew::SimulateSystem.with(os: :linux) do
181+
Cask::CaskLoader.load(cask.sourcefile_path).depends_on.arch
182+
end)
183+
linux_archs.map { |a| a[:type] }.uniq.sort
180184
else
181185
RUNNERS.keys.map { |r| r.fetch(:arch).to_sym }.uniq.sort
182186
end

Library/Homebrew/test/dev-cmd/generate-cask-ci-matrix_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99

1010
describe "#architectures" do
1111
let(:cmd) { described_class.new }
12-
let(:appimage_cask) { Cask::CaskLoader.load(TEST_FIXTURE_DIR/"cask/Casks/with-appimage.rb") }
12+
let(:linux_arch_cask) { Cask::CaskLoader.load(TEST_FIXTURE_DIR/"cask/Casks/on-linux-arch.rb") }
1313
let(:standard_cask) { Cask::CaskLoader.load(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
1414

15-
it "returns only [:intel] for Casks with an AppImage" do
16-
expect(cmd.architectures(cask: appimage_cask)).to eq([:intel])
15+
it "returns only [:intel] for Casks with an on_linux arch dependency" do
16+
expect(cmd.architectures(cask: linux_arch_cask)).to eq([:intel])
1717
end
1818

1919
it "returns all runners for standard Casks" do
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
cask "on-linux-arch" do
2+
version "1.0.0"
3+
sha256 :no_check
4+
5+
url "https://brew.sh/"
6+
name "On Linux Arch"
7+
desc "Cask with on_linux architecture dependency"
8+
homepage "https://brew.sh/"
9+
10+
on_linux do
11+
depends_on arch: :intel
12+
end
13+
14+
app "On Linux Arch.app"
15+
end

0 commit comments

Comments
 (0)