Skip to content

ci: gate job families on go/sdk/site path relevance - #1644

Merged
jhrozek merged 3 commits into
mainfrom
Nashon-Steffen/reduce-ci-runner-costs
Sep 17, 2026
Merged

jhrozek merged 3 commits into
mainfrom
Nashon-Steffen/reduce-ci-runner-costs

Conversation

@Nashon-Steffen

Copy link
Copy Markdown
Contributor

What & why

ci.yml gated jobs on a single dimension — docs_only (plus the two macOS
flags). Everything non-docs was one blob, leaving two classes of runner waste:

  • Every Go-only PR ran the pure-TypeScript SDK unit job (sdk) and the
    Docusaurus site build — neither of which a Go change can affect.
  • Every website/**- or sdk/typescript/**-only PR ran the entire Go
    matrix. (website/** isn't in the docs_only allowlist, so a website-only PR
    ran the full Go + SDK suite.)

This extends the changes classifier with three fail-closed relevance flags and
gates each job family on the right one, reusing the exact security-hardened
pattern behind the existing macOS gating.

The flags (.github/scripts/relevant-changes.sh <go|sdk|site>)

Fail-closed → RUN on anything unproven; computed from the classifier as it
exists on the base ref
, so a PR cannot edit it to skip a job it should run.

  • go — Go build/test matrix. Irrelevant only if every path is docs,
    website/, or sdk/typescript/. (Unlike the macOS go category, cmd/,
    examples/, perf/, e2e/, contracts/ etc. are in the Linux test closure
    and stay relevant.)
  • sdk — the pure-TS sdk unit job (runs against committed
    sdk/typescript/src/gen); relevant to sdk/typescript/ or contracts/.
  • site — the Docusaurus user-docs build; relevant to website/,
    user-docs/, or sdk/typescript/ (the SDK reference pages it checks).

Job → flag mapping

  • Go matrix (build, test-race×3 + draft, analysis, fuzz-smoke,
    engine-standalone, provider-standalone, api-compat, vuln) → go_relevant.
  • sdk (pure-TS Node matrix) → sdk_relevant alone.
  • sdk-integration / sdk-deno / sdk-browser / slack-bot-example (all
    build/spawn mecated) → go_relevant || sdk_relevant.
  • user-docs (Docusaurus) → site_relevant (no docs_only guard — a
    user-docs/ content change is docs-only yet must still rebuild the site).
  • Unchanged by design: docs (matlatl — generates the config reference from
    Go, must run on Go changes) and domain-model (its correct gate is
    docs/architecture/**, out of scope).

Required-check safety

test and lint are the required checks; they if: always() and assert
upstream .results keyed on docs_only. Both gain a go_relevant branch
mirroring their docs_only branch, so a non-Go PR reports the legitimate skips
(race shards / analysis) as success rather than blocking. Job-level if:
skips (not workflow-level paths:) keep every required check reporting on every
push/PR.

Tests

  • relevant-changes_test.sh — classifier unit test (per-category relevant /
    irrelevant / mixed / malformed / empty / rename / shell-injection-safety).
  • relevant-changes-workflow_test.sh — ci.yml wiring contract: fail-closed
    defaults, trusted base-ref extraction ordered after commit validation, the
    PR-checkout classifier is never executed, each job's if: carries the right
    flag, and both aggregators read go_relevant.

Registered next to the macos-relevant-* pair in ci.yml and in the
test:docs-only-classifier Taskfile target.

Verification

  • task test:docs-only-classifier — new classifier + wiring tests green.
  • Existing contract tests still green: race-aggregate-workflow_test.sh,
    docs-only-*, macos-relevant-* (proves the aggregator edits preserved every
    asserted line).
  • task lint:actions (actionlint + template guards) clean.
  • shellcheck: no warning/error findings on the new scripts.

🤖 Generated with Claude Code

Nashon-Steffen and others added 2 commits September 16, 2026 11:43
Extend the `changes` classifier with three fail-closed, trusted-base-ref
relevance flags so a change that provably cannot affect a job family skips
that family's runners:

- go_relevant  — the Go build/test matrix (build, test-race, analysis/lint,
  vuln, fuzz-smoke, engine/provider-standalone, api-compat).
- sdk_relevant — the pure-TypeScript SDK unit job (runs against committed
  sdk/typescript/src/gen; the mecated-spawning SDK jobs stay on go || sdk).
- site_relevant — the Docusaurus site build (user-docs).

The flags reuse the macOS gating pattern: computed from the classifier as it
exists on the base ref (a PR cannot edit it to skip a job it should run), and
each family is gated via a job-level `if:` (never a workflow-level path filter,
so the required checks still report on every push/PR). The required-check
aggregators (test, lint) gain a go_relevant branch mirroring their docs_only
branch, so a non-Go PR reports the legitimate skips as success instead of
blocking.

Net effect: a Go-only PR no longer runs the pure-TS SDK unit job or the
Docusaurus build; a website- or sdk/typescript-only PR no longer runs the Go
matrix.

Adds relevant-changes.sh plus its classifier and workflow-wiring contract tests,
registered alongside the macos-relevant-* pair in ci.yml and Taskfile.yml.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Address PR review findings on the go/sdk/site path-relevance gating:

- F1: the sdk/site categories used positive allowlists that treated CI-control
  files (.github/*, Taskfile.yml) as irrelevant, so a change to a job's own
  definition or the task recipe it runs would SKIP that very job. Add those
  files to the sdk and site relevant sets (fail-closed -> RUN), correct the
  header comment that overstated the allowlist's safety, and add classifier
  test coverage.
- F2: the workflow-wiring test asserted the GO_RELEVANT early-exit with a
  whole-file grep, which matched BOTH the test and lint aggregators, so it did
  not actually pin the test aggregator's branch (a regression there would block
  non-Go PRs undetected). Scope each assertion to its own job body via a new
  job_block helper; verified load-bearing by deletion.
- F3: add a drift guard pinning the count of go_relevant if: gates (15 = 11
  go-family/race/draft + 4 go||sdk), so adding or removing a Go-gated job forces
  a conscious update to the test's job lists.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

@jhrozek jhrozek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Panel review follow-up on the go/sdk/site CI cost-gating change. Two findings remain open after the latest commit (80f1f6d), which already fixed the sdk/site classifier allowlist gap and the aggregator test scoping. Posting both as inline comments.

Comment thread .github/workflows/ci.yml Resolved
Comment thread .github/workflows/ci.yml Resolved
…tests

Address PR #1644 review (jhrozek):

- [Blocker] user-docs is a required check but was gated directly on
  site_relevant. A job skipped via if: reports as success for branch
  protection, so a site-category misclassification (or a future allowlist
  narrowing that misses a content source) could let the gate go green having
  never built the site or checked links. Add a `user-docs-gate` always() job
  mirroring lint/test: require user-docs skipped when site_relevant != true,
  else require success. Branch protection should require "User docs (gate)"
  instead of "User docs (Docusaurus build)".

- [Important] the path-classifier self-tests ran inside test-race-root-a,
  itself gated on go_relevant, so a `go` misclassification would skip the very
  tests that catch it (the aggregators then report success on the gap). Move
  the docs-only / macos / relevant classifier tests into the always-run
  `changes` job, right after the flags are computed.

Both fixes are pinned in relevant-changes-workflow_test.sh and verified
load-bearing by mutate-and-restore.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

@jhrozek jhrozek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Both findings from the prior review confirmed fixed in 51441b3: user-docs-gate aggregator added, classifier self-tests moved into the always-run changes job. Approving.

@jhrozek
jhrozek merged commit 25c0ab8 into main Sep 17, 2026
37 checks passed
@jhrozek
jhrozek deleted the Nashon-Steffen/reduce-ci-runner-costs branch September 17, 2026 19:10
@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.

2 participants