-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Make Cask CI generate correctly for partial arch dependencies #21380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Partially split from: #20334 |
644dfa9 to
22ab6a6
Compare
There was a problem hiding this 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
architecturesmethod to accept anosparameter, enabling OS-specific architecture filtering based on simulated system environments - Updated
filter_runnersto 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.
| cask = Cask::CaskLoader.load(path.expand_path) | ||
|
|
||
| runners, multi_os = runners(cask:) | ||
| runners.product(architectures(cask:)).filter_map do |runner, arch| |
Copilot
AI
Jan 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The architectures method is being called on line 274 without the os parameter, which means it will default to :macos. This could cause incorrect architecture filtering when dealing with Linux runners. The method should be called per-runner with the appropriate OS based on the runner's symbol to correctly handle OS-specific architecture dependencies.
| sig { returns(T::Boolean) } | ||
| def contains_os_specific_artifacts? | ||
| return false unless @dsl.on_system_blocks_exist? | ||
|
|
||
| any_loaded = false | ||
| @contains_os_specific_artifacts ||= begin | ||
| OnSystem::VALID_OS_ARCH_TAGS.each do |bottle_tag| | ||
| Homebrew::SimulateSystem.with_tag(bottle_tag) do | ||
| refresh | ||
|
|
||
| any_loaded = true if artifacts.any? do |artifact| | ||
| (bottle_tag.linux? && ::Cask::Artifact::MACOS_ONLY_ARTIFACTS.include?(artifact.class)) || | ||
| (bottle_tag.macos? && ::Cask::Artifact::LINUX_ONLY_ARTIFACTS.include?(artifact.class)) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| any_loaded | ||
| rescue CaskInvalidError | ||
| # Invalid cask | ||
| ensure | ||
| refresh | ||
| end | ||
|
|
||
| @dsl.os.present? | ||
| @contains_os_specific_artifacts | ||
| end |
Copilot
AI
Jan 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new contains_os_specific_artifacts? method lacks test coverage. Given that Library/Homebrew/test/cask/cask_spec.rb exists with comprehensive tests for other Cask methods, this new method should have corresponding test cases to verify its behavior across different scenarios (e.g., casks with OS-specific artifacts, casks without, error cases).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it'd be good to have even just one very simple test for this. Could ask Copilot to try it for you.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
b8bbc6a to
e4c9380
Compare
MikeMcQuaid
left a comment
There was a problem hiding this 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.
| native_runner_arch = arch == runner.fetch(:arch) | ||
| # we don't need to run simulated archs on Linux | ||
| # we don't need to run simulated archs on Linux or macOS Sequoia | ||
| # because it has a GitHub hosted x86_64 runner |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # because it has a GitHub hosted x86_64 runner | |
| # because there is a GitHub hosted Linux x86_64 runner |
or something? current comment doesn't make sense
| sig { returns(T::Boolean) } | ||
| def contains_os_specific_artifacts? | ||
| return false unless @dsl.on_system_blocks_exist? | ||
|
|
||
| any_loaded = false | ||
| @contains_os_specific_artifacts ||= begin | ||
| OnSystem::VALID_OS_ARCH_TAGS.each do |bottle_tag| | ||
| Homebrew::SimulateSystem.with_tag(bottle_tag) do | ||
| refresh | ||
|
|
||
| any_loaded = true if artifacts.any? do |artifact| | ||
| (bottle_tag.linux? && ::Cask::Artifact::MACOS_ONLY_ARTIFACTS.include?(artifact.class)) || | ||
| (bottle_tag.macos? && ::Cask::Artifact::LINUX_ONLY_ARTIFACTS.include?(artifact.class)) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| any_loaded | ||
| rescue CaskInvalidError | ||
| # Invalid cask | ||
| ensure | ||
| refresh | ||
| end | ||
|
|
||
| @dsl.os.present? | ||
| @contains_os_specific_artifacts | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it'd be good to have even just one very simple test for this. Could ask Copilot to try it for you.
brew lgtm(style, typechecking and tests) with your changes locally?