Skip to content

Skip platform-specific builds based on formula dependencies#2008

Merged
chenrui333 merged 3 commits into
mainfrom
copilot/update-workflow-linux-only-prs
Oct 9, 2025
Merged

Skip platform-specific builds based on formula dependencies#2008
chenrui333 merged 3 commits into
mainfrom
copilot/update-workflow-linux-only-prs

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 9, 2025

Problem

When a PR contains formulas with platform-specific dependencies (e.g., depends_on :linux), the CI workflow was unnecessarily running builds on all platforms. As shown in the issue screenshot, a PR with the "linux-only" label still triggered all 4 macOS runners (macos-14, macos-15, macos-15-intel, macos-26) even though they would never succeed for a Linux-only formula.

This wastes CI resources, increases queue times, and delays feedback for contributors.

Solution

This PR implements intelligent platform filtering in the CI workflow, matching the behavior of homebrew/homebrew-core:

  • Linux-only PRs (formulas with depends_on :linux): Skip all macOS runners, only run Linux builds
  • macOS-only PRs (formulas with depends_on :macos): Skip all Linux runners, only run macOS builds
  • Multi-platform PRs: Run all platforms as before

Implementation

1. Label Detection (environment.js)

Extended the environment configuration script to detect linux-only and macos-only labels (which are automatically applied by the triage.yml workflow) and set corresponding output flags.

2. Conditional Runner Execution (tests.yml)

  • Added skip_on_linux_only and skip_on_macos_only flags to each matrix runner
  • Introduced a skip-check step that evaluates whether a runner should execute based on:
    • Event type (only applies to pull requests)
    • Label presence (linux-only or macos-only)
    • Runner platform (macOS vs Linux)
  • Made all build steps conditional on the skip flag

Benefits

  • Resource Optimization: Up to 66% reduction in CI runs for linux-only PRs
  • Cost Savings: Significantly fewer GitHub Actions minutes, especially for expensive macOS runners (10x cost of Linux)
  • Faster Feedback: Quicker turnaround for contributors on platform-specific PRs
  • Consistency: Aligns with Homebrew core tap practices

Example

For a PR adding a Linux-only formula:

Before:

  • 4 macOS runners queued → will fail ❌
  • 2 Linux runners queued → will succeed ✅
  • Total: 6 runners, 4 unnecessary

After:

  • 4 macOS runners skipped ⏭️
  • 2 Linux runners queued → will succeed ✅
  • Total: 2 runners, 0 unnecessary

Safety

  • Non-PR events (push to main) always run all platforms
  • Missing labels default to running all platforms
  • No impact on existing multi-platform formulas
  • All changes validated with YAML and JavaScript syntax checks

Fixes #[issue_number]

Original prompt

This section details on the original issue you should resolve

<issue_title>[bug] like homebrew core tap, the linux-only prs should not trigger macos builds</issue_title>
<issue_description>Image

<agent_instructions>need to update the workflow to not create macos builds run for linux-only builds</agent_instructions>

Comments on the Issue (you are @copilot in this section)

Fixes #2007


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] Fix workflow to skip macOS builds for Linux-only PRs Skip platform-specific builds based on formula dependencies Oct 9, 2025
Copilot AI requested a review from chenrui333 October 9, 2025 12:28
@chenrui333 chenrui333 marked this pull request as ready for review October 9, 2025 13:07
@chenrui333 chenrui333 added the CI-syntax-only Change only affects brew syntax, not the install. Only run syntax CI. label Oct 9, 2025
@chenrui333 chenrui333 merged commit b40e133 into main Oct 9, 2025
11 of 15 checks passed
@chenrui333 chenrui333 deleted the copilot/update-workflow-linux-only-prs branch October 9, 2025 13:11
@chenrui333 chenrui333 mentioned this pull request Oct 9, 2025
chenrui333 added a commit that referenced this pull request Oct 9, 2025
chenrui333 added a commit that referenced this pull request Oct 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI-syntax-only Change only affects brew syntax, not the install. Only run syntax CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] like homebrew core tap, the linux-only prs should not trigger macos builds

2 participants