Skip to content

Make Cask CI generate correctly for partial arch dependencies#21380

Merged
SMillerDev merged 6 commits intomainfrom
feat/cask/arch_ci
Feb 7, 2026
Merged

Make Cask CI generate correctly for partial arch dependencies#21380
SMillerDev merged 6 commits intomainfrom
feat/cask/arch_ci

Conversation

@SMillerDev
Copy link
Copy Markdown
Member

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

Copilot AI review requested due to automatic review settings January 9, 2026 21:40
@SMillerDev
Copy link
Copy Markdown
Member Author

Partially split from: #20334

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request enhances Cask CI matrix generation to correctly handle partial architecture dependencies, particularly when casks have OS-specific architecture requirements (e.g., requiring x86_64 on macOS but arm64 on Linux). The changes introduce per-OS architecture filtering to ensure CI runners are properly selected based on platform-specific constraints.

Key Changes

  • Modified the architectures method to accept an os parameter, enabling OS-specific architecture filtering based on simulated system environments
  • Updated filter_runners to separately filter macOS and Linux runners based on their respective architecture requirements
  • Added contains_os_specific_artifacts? method to detect casks with platform-specific artifacts that affect OS compatibility
  • Introduced comprehensive test coverage for various combinations of OS and architecture dependencies

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
Library/Homebrew/dev-cmd/generate-cask-ci-matrix.rb Enhanced architecture filtering to support OS-specific dependencies; modified filter_runners and architectures methods to handle per-OS architecture constraints
Library/Homebrew/cask/cask.rb Added contains_os_specific_artifacts? method to improve Linux support detection by checking for OS-specific artifact constraints
Library/Homebrew/cask/artifact.rb Added LINUX_ONLY_ARTIFACTS constant (empty placeholder for future Linux-specific artifacts)
Library/Homebrew/test/dev-cmd/generate-cask-ci-matrix_spec.rb Added comprehensive test cases covering various scenarios including mixed OS/arch dependencies, OS-specific dependencies, and system-wide constraints

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Library/Homebrew/test/dev-cmd/generate-cask-ci-matrix_spec.rb Outdated
Comment thread Library/Homebrew/dev-cmd/generate-cask-ci-matrix.rb Outdated
Comment thread Library/Homebrew/dev-cmd/generate-cask-ci-matrix.rb Outdated
Comment thread Library/Homebrew/cask/cask.rb Outdated
Comment thread Library/Homebrew/dev-cmd/generate-cask-ci-matrix.rb Outdated
Comment thread Library/Homebrew/cask/cask.rb
Copy link
Copy Markdown
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Thanks! A few small comments.

Comment thread Library/Homebrew/dev-cmd/generate-cask-ci-matrix.rb Outdated
Comment thread Library/Homebrew/cask/cask.rb
Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 20, 2026

@SMillerDev I've opened a new pull request, #21432, to work on those changes. Once the pull request is ready, I'll request review from you.

@SMillerDev SMillerDev force-pushed the feat/cask/arch_ci branch 4 times, most recently from de5afca to 1750f36 Compare January 30, 2026 13:44
@SMillerDev
Copy link
Copy Markdown
Member Author

No idea why this issue happens here and not on my local install:

Error: Homebrew::DevCmd::GenerateCaskCiMatrix::filter_runners when cask does not have on_system blocks/calls or `depends_on arch` returns an array including everything

Failure/Error:
  expect(generate_matrix.send(:filter_runners, c_app_only_macos))
    .to eq({
      { arch: :arm, name: "macos-14", symbol: :sonoma }          => 0.0,
      { arch: :arm, name: "macos-15", symbol: :sequoia }         => 0.0,
      { arch: :arm, name: "macos-26", symbol: :tahoe }           => 1.0,
      { arch: :arm, name: "ubuntu-22.04-arm", symbol: :linux }   => 1.0,
      { arch: :intel, name: "macos-15-intel", symbol: :sequoia } => 1.0,
      { arch: :intel, name: "ubuntu-22.04", symbol: :linux }     => 1.0,
    })

@bevanjkay
Copy link
Copy Markdown
Member

I can reproduce it using brew tests --only dev-cmd/generate-cask-ci-matrix:161 --generic.

Did a bit of discovery with help from Claude. It looks like when the supports_linux? value on cask is set, the value gets reset during the process, because the SimulateSystem value when running the test with --generic is nil.

The fix below seems to get this working for me, but there may be a better approach. It stores the value before calling contains_os_specific_artifacts? which is the root cause of the reset because it calls refresh.

diff --git a/Library/Homebrew/cask/cask.rb b/Library/Homebrew/cask/cask.rb
index 55de9a0613..f2fe086ddd 100644
--- a/Library/Homebrew/cask/cask.rb
+++ b/Library/Homebrew/cask/cask.rb
@@ -167,9 +167,14 @@ module Cask
     sig { returns(T::Boolean) }
     def supports_linux?
       return true if font?
+
+      # Cache the os value before contains_os_specific_artifacts? refreshes the cask
+      # (the refresh clears @dsl.os in generic/non-OS-specific contexts)
+      os_value = @dsl.os
+
       return false if contains_os_specific_artifacts?
 
-      @dsl.os.present?
+      os_value.present?
     end
 
     sig { returns(T::Boolean) }

Copy link
Copy Markdown
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

thanks, looks fine bar weird tests.

Comment thread Library/Homebrew/test/dev-cmd/generate-cask-ci-matrix_spec.rb Outdated
@SMillerDev SMillerDev force-pushed the feat/cask/arch_ci branch 2 times, most recently from 2556ef8 to e3e8f5a Compare February 2, 2026 22:19
SMillerDev and others added 6 commits February 7, 2026 19:19
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Cache the OS value before checking for OS-specific artifacts.

Co-Authored-By: Bevan Kay <email@bevankay.me>
@SMillerDev SMillerDev enabled auto-merge February 7, 2026 18:21
@SMillerDev SMillerDev added this pull request to the merge queue Feb 7, 2026
Merged via the queue into main with commit 589bfc7 Feb 7, 2026
42 checks passed
@SMillerDev SMillerDev deleted the feat/cask/arch_ci branch February 7, 2026 18:56
@bevanjkay bevanjkay mentioned this pull request Feb 10, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants