From dd1e5b723da21e36a3aa6c60d3d3ef0c33fca27d Mon Sep 17 00:00:00 2001 From: Brooklyn Nicholson Date: Thu, 20 Aug 2026 11:46:30 -0500 Subject: [PATCH] fix(ci): declare the rust lane on the detect job, and test that wiring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .github/workflows/ci.yaml | 1 + tests/ci/test_classify_changes.py | 50 +++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 71756b3acb..e2660cc4a6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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 }} diff --git a/tests/ci/test_classify_changes.py b/tests/ci/test_classify_changes.py index 29095ffff0..4902cbafc2 100644 --- a/tests/ci/test_classify_changes.py +++ b/tests/ci/test_classify_changes.py @@ -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",