From 9bcd162f9d922185cca7e8d197ce5f32013580cf Mon Sep 17 00:00:00 2001 From: Alan Chester Date: Thu, 2 Apr 2026 23:36:09 -0400 Subject: [PATCH] ci: skip macOS jobs on CI-only PRs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a detect-changes job that checks whether any files outside .github/ were modified. formula-audit and integration (both macOS runners at 10× cost) now depend on it and are skipped entirely when a PR only touches workflow files — not just early-exited, but never scheduled. Non-PR events (push to main/develop, tags, workflow_call) always run. Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/validate.yml | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 1f8437c..f409923 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -11,6 +11,33 @@ permissions: contents: read jobs: + # ── Job 0: Detect changed files (PR only) ───────────────────────────────── + # Formula Audit and Integration Test run on macOS runners (10× cost). + # Skip them entirely when a PR only touches CI/workflow files. + detect-changes: + name: Detect Changed Files + runs-on: ubuntu-latest + outputs: + source_changed: ${{ steps.filter.outputs.source }} + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + with: + fetch-depth: 0 + + - name: Check for source file changes + id: filter + run: | + # On non-PR events (push to main/develop, workflow_call, tags) always run. + if [[ "${{ github.event_name }}" != "pull_request" ]]; then + echo "source=true" >> "$GITHUB_OUTPUT" + exit 0 + fi + # On PRs: skip macOS jobs if every changed file is under .github/ + git diff --name-only "origin/${{ github.base_ref }}...HEAD" \ + | grep -qvE '^\.github/' \ + && echo "source=true" >> "$GITHUB_OUTPUT" \ + || echo "source=false" >> "$GITHUB_OUTPUT" + # ── Job 1: Lint (fast, runs on Linux) ────────────────────────────────────── lint: name: Lint @@ -132,6 +159,8 @@ jobs: formula-audit: name: Formula Audit runs-on: macos-latest + needs: [lint, detect-changes] + if: needs.detect-changes.outputs.source_changed == 'true' steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 @@ -147,7 +176,8 @@ jobs: integration: name: Integration Test runs-on: macos-latest - needs: [lint, formula-audit] + needs: [lint, formula-audit, detect-changes] + if: needs.detect-changes.outputs.source_changed == 'true' steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6