Skip to content

ci: gate macOS runners on draft + path relevance - #1594

Merged
Nashon-Steffen merged 3 commits into
mainfrom
Nashon-Steffen/gha-cost-path-gates
Sep 15, 2026
Merged

Nashon-Steffen merged 3 commits into
mainfrom
Nashon-Steffen/gha-cost-path-gates

Conversation

@Nashon-Steffen

Copy link
Copy Markdown
Contributor

What

Gate the three macos-14 jobs in ci.yml — which cost ~10× a Linux runner minute — behind draft-PR and path-relevance flags, so they no longer run on every non-docs push/PR regardless of what changed.

Extends the repository's existing trusted-classifier idiom (docs-only-changes.sh + the changes job) rather than adding on:-level paths: filters (those would break required status checks).

Why

ci.yml previously gated the macOS jobs only on docs_only != 'true', so any non-docs change ran all three on Apple-silicon runners — including draft PRs and changes that could not possibly affect them (e.g. a TypeScript-SDK-only or website-only change still ran the native Go darwin smokes). macOS is the single most expensive per-minute runner class in this repo.

Changes

New scripts

  • .github/scripts/macos-relevant-changes.sh — fail-closed classifier mirroring docs-only-changes.sh. Prints true (RUN) unless it can prove every changed path is irrelevant. Two categories:
    • go — irrelevant: docs, user-docs/, website/, sdk/typescript/ (used by smoke-darwin-arm64, managed-temp-macos).
    • sdk — irrelevant: docs, user-docs/, website/ only (the SDK spawns mecated, so Go changes are relevant too; used by sdk-macos-spawn).
  • .github/scripts/macos-relevant-changes_test.sh — offline unit tests (fail-closed, rename-boundary, and shell-injection-safety cases).
  • .github/scripts/macos-relevant-workflow_test.sh — asserts the wiring stays correct (fail-closed defaults, base-ref extraction ordering, draft gate on all three jobs, exactly-3-macos-jobs tripwire).

ci.yml

  • changes job emits new macos_go / macos_sdk outputs, computed from the base ref's classifier — same anti-tamper property as docs_only (a PR cannot edit the classifier to skip a job it should run until it merges; fail-closed to RUN on any failure or missing script).
  • smoke-darwin-arm64 + managed-temp-macos gate on macos_go; sdk-macos-spawn gates on macos_sdk. All three additionally skip on draft PRs. The existing docs_only != 'true' guard is retained as the outer safety.
  • Both new tests wired into the existing "Validate race workflow contracts" step.

docs_only semantics are untouched (it feeds many other jobs).

Expected savings

  • Draft PRs: all three macOS jobs skip entirely.
  • Ready PRs / pushes: SDK-frontend-only, site-only, or docs changes skip both Go smokes; docs/site-only changes also skip the SDK spawn. Go changes still run everything relevant (deep Go dep graphs stay fail-closed).

Safety

This extends an if: pattern these jobs already rely on (they skip on docs-only PRs today), so branch protection already tolerates them skipping — no required-check/aggregator changes needed.

Verification

  • bash .github/scripts/macos-relevant-changes_test.sh — all checks pass
  • bash .github/scripts/macos-relevant-workflow_test.sh — all checks pass
  • bash .github/scripts/docs-only-changes_test.sh / docs-only-workflow_test.sh — still pass (unchanged semantics)
  • ci.yml parses as valid YAML

Nashon-Steffen and others added 3 commits September 15, 2026 10:24
The three macos-14 jobs cost ~10x a Linux runner minute and previously ran
on every non-docs push/PR. Gate them behind a draft-PR check and per-category
path-relevance flags computed by a fail-closed, base-ref classifier (the same
anti-tamper discipline as docs-only-changes.sh):

- smoke-darwin-arm64 + managed-temp-macos gate on macos_go
  (irrelevant: docs, user-docs/, website/, sdk/typescript/)
- sdk-macos-spawn gates on macos_sdk
  (irrelevant: docs, user-docs/, website/ — Go changes are relevant since
  the SDK spawns mecated)

All three also skip on draft PRs. The existing docs_only guard is retained.
Adds unit + workflow-wiring tests, wired into the race-contracts step.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Measuring the darwin+freebsd build/test closure of what the three macos-14
jobs actually build and test shows ~25 root-module packages sit outside it —
a Go change confined to them cannot alter the darwin build or darwin tests,
so running the (10x-cost) macOS jobs for them catches nothing.

Extend the macos-relevant-changes.sh "irrelevant" allowlist with the terminal
leaf directories that no macOS-job binary or test imports: cmd/mecademo,
cmd/mecak8s, cmd/mecatequi, examples/, perf/, e2e/, deploy/, docs/lint/. This
is a SOUND narrowing with zero coverage loss (skipped builds would be
byte-identical), unlike gating on darwin build tags.

Guard against fail-open drift with macos-closure-guard.sh: it recomputes the
closure via `go list -deps` and fails CI if any allowlisted directory ever
enters it, and cross-checks that the guard and classifier name the same dirs.
Wired into the build job (needs resolved modules); the offline classifier and
wiring tests cover the rest.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
actionlint's embedded shellcheck flags SC2129 now that the classify step
writes three outputs; the added macos_go/macos_sdk echoes turned the single
docs_only redirect into three. Group them into one `{ ...; } >> "$GITHUB_OUTPUT"`
(the house fix, per release.yml), and update the wiring test's literal
assertions to the grouped form.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@Nashon-Steffen
Nashon-Steffen merged commit 808c6ce into main Sep 15, 2026
62 of 64 checks passed
@Nashon-Steffen
Nashon-Steffen deleted the Nashon-Steffen/gha-cost-path-gates branch September 15, 2026 18:16
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Sep 21, 2026
2 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.

1 participant