fix(ci): declare the rust lane on the detect job, and test that wiring

The lane shipped dead. `classify_changes.py` emitted `rust`, the composite
action re-exported it, and ci.yaml's `rust-tests` job gated on
`needs.detect.outputs.rust` — but the `detect` job never declared that
output, so the expression was the empty string and the job reported
"skipping" on the very PR that added it. GitHub does not error on a
reference to an output a job never declared, so nothing went red.

Adds the missing line plus the invariant that catches the whole class:
every `needs.detect.outputs.X` referenced by a job's `if` must be
declared by `detect`. Verified it fails with the line removed.

The related check — every lane reaching the composite action — is
separate on purpose: nix.yml and docker.yml own their triggers and
re-export different subsets, so `docker` and `nix` are legitimately not
ci.yaml detect outputs.
This commit is contained in:
Brooklyn Nicholson
2026-08-20 11:46:30 -05:00
parent 5caea5e501
commit dd1e5b723d
2 changed files with 51 additions and 0 deletions
+1
View File
@@ -49,6 +49,7 @@ jobs:
uv_lock: ${{ steps.classify.outputs.uv_lock }}
npm_lock: ${{ steps.classify.outputs.npm_lock }}
installer: ${{ steps.classify.outputs.installer }}
rust: ${{ steps.classify.outputs.rust }}
docker_meta: ${{ steps.classify.outputs.docker_meta }}
mcp_catalog: ${{ steps.classify.outputs.mcp_catalog }}
ci_review: ${{ steps.classify.outputs.ci_review }}
+50
View File
@@ -8,6 +8,7 @@ change could have broken.
from __future__ import annotations
import importlib.util
import re
from pathlib import Path
import pytest
@@ -240,6 +241,55 @@ def test_classify(files, expected):
assert classify(files) == expected
_REPO = Path(__file__).resolve().parents[2]
def _yaml(rel: str) -> dict:
yaml = pytest.importorskip("yaml")
return yaml.safe_load((_REPO / rel).read_text(encoding="utf-8"))
def test_every_lane_reaches_the_composite_action():
"""The action is the one surface every consumer reads, so it must carry all
of them — ci.yaml, nix.yml and docker.yml each re-export a different subset.
"""
lanes = set(classify(["run_agent.py"]))
action_outputs = set(_yaml(".github/actions/detect-changes/action.yml")["outputs"])
assert lanes - action_outputs == set(), "lane(s) missing from the composite action's outputs"
def test_ci_jobs_only_gate_on_detect_outputs_that_detect_actually_declares():
"""An ``if`` that reads an undeclared output resolves to the empty string.
The lane then reports "skipping" on every PR, forever, and nothing goes red
— there is no error for referencing an output a job never declared. That is
exactly how the ``rust`` lane shipped dead: the classifier emitted it and
the composite action re-exported it, but ci.yaml's ``detect`` job did not,
so ``needs.detect.outputs.rust`` was never anything but "".
"""
ci = _yaml(".github/workflows/ci.yaml")
declared = set(ci["jobs"]["detect"]["outputs"])
referenced: set[str] = set()
for job in ci["jobs"].values():
for expr in _iter_if_expressions(job):
referenced.update(re.findall(r"needs\.detect\.outputs\.(\w+)", expr))
assert referenced, "found no detect-gated jobs — the walk is broken, not the wiring"
assert referenced - declared == set(), "job(s) gate on an output detect never declares"
def _iter_if_expressions(job: object):
"""Yield every ``if:`` string in a job, including inside its steps."""
if not isinstance(job, dict):
return
if isinstance(cond := job.get("if"), str):
yield cond
for step in job.get("steps", []) or []:
if isinstance(step, dict) and isinstance(cond := step.get("if"), str):
yield cond
def test_ci_review_files_returns_only_sensitive_paths_sorted_and_unique():
assert ci_review_files([
"apps/desktop/src/app.tsx",