ci: extract reusable guard workflow

Merged
TE
2mo ago
+707-502

Summary

Extract the already-parallel Linux guard jobs from .github/workflows/ci.yml into the reusable .github/workflows/ci-guards.yml workflow.

This is the topology half of RFC #13095 slice 1. The guard latency behavior change already landed separately in #13097; this PR keeps those job bodies, checkout depths, runner labels, permissions, commands, and route meanings unchanged.

  • keep static-preflight in the caller so web/macOS start behavior stays unchanged in this extraction
  • replace the four guard jobs in ci.yml with one local reusable-workflow call
  • keep the four existing route outputs as strings and reject missing/invalid values
  • aggregate guard results inside the reusable workflow and propagate failure/cancellation through linux-preflight
  • preserve docs/guard-only routing by teaching the CI area detector to scan both ci.yml and ci-guards.yml
  • update the existing guard, permission, Ghostty, and app-host workflow-parsing regression tests for the new ownership boundary

Fail-closed behavior

The caller skips the reusable guard workflow only when all four guard routes are exactly false. Any unknown or missing route causes the reusable call to run. Its guard-status gate rejects invalid route values and rejects a skipped/failed/cancelled guard whose route is true.

linux-preflight independently validates the four route values and requires the reusable guards result to succeed whenever any guard route is true. It accepts a skipped reusable call only when every guard route is explicitly false.

Review boundary

This PR is an extraction, not another optimization pass. It deliberately leaves these in ci.yml for later slices:

  • static-preflight
  • GhosttyKit release check
  • web/typecheck/react/db/agent-session jobs
  • macOS compile/test/package/release jobs
  • existing CI area inference and rollup layout beyond the compatibility change needed for moved guard-test references

No persistent-Mac routing, R2 artifact work, or app-host flake repair is included.

Guard performance evidence

The accepted #13097 optimization provides the before/after measurement for this slice:

MetricBeforeAfter #13097
Guard wall-clock critical path385.5 s124.3 s
Linux guard runner-minutes6.43 min7.49 min

Before: https://github.com/manaflow-ai/cmux/actions/runs/35477597285/job/105989493676

After: https://github.com/manaflow-ai/cmux/actions/runs/35478932148

The remaining parallel guard groups in that run were:

  • history: 124.2 s
  • main guard suite: 116.8 s
  • CLI/profiling guards: 109.9 s
  • source lints: 98.4 s

So #13097 cut the measured guard wall-clock by about 68% while adding about 1.06 Linux runner-minutes from parallel setup/checkout overhead. The critical path is roughly 2m04s; the history lane is the longest remaining group.

This extraction is intended to preserve that profile.

Validation

Regression coverage in this branch exercises:

  • reusable guard route wiring
  • all-false guard skipping
  • selected guard failure/skipped/cancelled propagation
  • malformed/missing route rejection
  • single full-history checkout ownership
  • guard-only test routing after the file move
  • local reusable-workflow permission ceilings
  • existing app-host and Ghostty workflow-body guards after ownership moves

Hosted CI is the validation path for this repo-side workflow change.

Migration sequence

  1. This PR: reusable guard workflow extraction
  2. reusable web workflow extraction
  3. reusable macOS workflow extraction
  4. replace workflow-text/job-diff inference with the RFC area table, preserving unknown-path macOS fallback
  5. remove obsolete preflight/rollup complexity while retaining one authoritative ci-status
  6. complete routing/result/merge-group regression matrix and refresh performance evidence

Refs #13095.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Extracts the four Linux guard jobs from ci.yml into the reusable ci-guards.yml workflow, replacing them with a single guards call. Job bodies, checkout depths, runner labels, permissions, commands, and route meanings are unchanged.

Fail-closed behavior

  • The caller skips the reusable workflow only when all four guard routes are exactly false; missing or invalid routes force it to run.
  • guard-status inside the reusable workflow rejects invalid route values and any skipped/failed/cancelled guard whose route is true.
  • linux-preflight independently validates the four routes and requires the guards call to succeed whenever any route is true.
  • The CI area detector now scans both workflow files so guard-only test routing keeps working, and edits to ci-guards.yml force all areas like edits to ci.yml do.

static-preflight stays in the caller; web and macOS jobs are deliberately left in ci.yml for later slices. The guard, permission, Ghostty, app-host, TestFlight, and Swift warning budget regression tests follow their jobs into the reusable workflow.

Summary by CodeRabbit

  • CI Improvements

    • Consolidated Linux validation checks into a reusable workflow.
    • Added centralized routing and status validation for guard checks.
    • Improved workflow handling when individual validation routes are skipped or fail.
    • Updated change detection and validation coverage to include the reusable guard workflow.
  • Tests

    • Updated CI, distribution, version-sync, permissions, and routing checks for the new workflow structure.
    • Added coverage for guard routing, aggregate results, and invalid route states.