Skip to content

The agent that grows with you

ci: a shared fixture selects every lane that runs one of its consumers

Teknium2d7307931df6
diff --git a/scripts/ci/classify_changes.py b/scripts/ci/classify_changes.py
index 484c59ae4ec..60b738793db 100644
--- a/scripts/ci/classify_changes.py
+++ b/scripts/ci/classify_changes.py
@@ -67,6 +67,9 @@ must never skip one a change could break:
* ``website/docs/`` and ``website/scripts/`` are python-relevant for the same
reason: the docs tree generates ``llms.txt``, and
``tests/website/test_generate_llms_txt.py`` asserts every page reaches it.
+* A cross-language fixture (``_SHARED_FIXTURE_CONSUMERS``) selects the test
+ lanes of every consumer that reads it: the update-marker corpus runs pytest,
+ cargo, vitest and the Windows hand-off tests, not only ``python``.
"""
from __future__ import annotations
@@ -145,6 +148,27 @@ _DESKTOP_UPDATER_FILES = {
"pyproject.toml",
}
+# Cross-language fixtures: one data file that tests in several languages read as
+# their shared contract. Editing it is editing every consumer, so it selects each
+# lane that runs one (a path-prefix rule would see only ``tests/`` -> python, and
+# the cargo / vitest / PowerShell readers of the same cases would never run).
+# tests/ci/test_update_ci_routing.py finds the consumers in the tree and fails
+# until every one is listed here.
+_SHARED_FIXTURE_CONSUMERS: dict[str, tuple[str, ...]] = {
+ # A7 rule 7: the update-marker parse / judge / release corpus.
+ "tests/fixtures/update_marker_corpus.json": (
+ "tests/hermes_cli/test_update_marker_corpus.py", # Python: update_lock
+ "apps/bootstrap-installer/src-tauri/src/marker_tests.rs", # Rust: cargo test
+ "apps/desktop/electron/update-marker-corpus.test.ts", # Electron: vitest
+ "tests/scripts/desktop_update/test_desktop_update_posix_marker_corpus.py", # marker.sh
+ "tests/scripts/desktop_update/test_desktop_update_windows_marker_corpus.py", # marker.ps1
+ ),
+}
+# What a fixture inherits from its consumers: the lanes that run them as tests.
+# Not the slow suites a consumer's path also matches (an Electron test file under
+# electron/update-* starts the Desktop update E2E, which never reads the corpus).
+_FIXTURE_CONSUMER_LANES = ("python", "rust", "frontend", "desktop_updater")
+
# Rust crates — currently just the Tauri bootstrap installer (Hermes-Setup).
# These live under ``apps/``, so before this lane existed a ``.rs`` edit matched
# ``frontend`` and nothing more: the TypeScript matrix built, cargo never ran,
@@ -509,6 +533,11 @@ def classify(files: list[str], run_e2e: bool = False) -> dict[str, bool]:
"rust": any(_is_rust(f) for f in files),
**{lane: run_e2e or on for lane, on in _slow_lanes(files).items()},
}
+ consumers = [c for f in files for c in _SHARED_FIXTURE_CONSUMERS.get(f, ())]
+ if consumers:
+ inherited = classify(consumers)
+ for lane in _FIXTURE_CONSUMER_LANES:
+ ret[lane] = ret[lane] or inherited[lane]
if not files or any(f.startswith(".github/") for f in files):
ret["python"] = True
ret["python_prod"] = True
diff --git a/tests/ci/test_update_ci_routing.py b/tests/ci/test_update_ci_routing.py
index 38e61101f13..418bc2f01dc 100644
--- a/tests/ci/test_update_ci_routing.py
+++ b/tests/ci/test_update_ci_routing.py
@@ -257,6 +257,64 @@ def test_every_detect_output_a_lane_sets_is_consumed_by_some_job():
assert unread == []
+# -- shared cross-language fixtures (review D14) --------------------------------------------
+
+# The job (path from ci.yaml down) that runs each lane's consumers of a shared fixture.
+_FIXTURE_LANE_JOBS: dict[str, tuple[str, ...]] = {
+ "python": ("tests", "test"), # pytest on Linux (marker.sh corpus included)
+ "rust": ("rust-tests", "bootstrap-installer"), # cargo test of the Tauri crate
+ "frontend": ("js-tests", "check"), # apps/desktop `check` -> vitest --project electron
+}
+_CORPUS = "tests/fixtures/update_marker_corpus.json"
+_TEST_FILE = re.compile(r"(^tests/(?!ci/).*\.py$)|(_tests?\.rs$)|(\.test\.[cm]?[jt]sx?$)")
+
+
+def _fixture_lanes_reached(fixture: str) -> dict[str, bool]:
+ classified = _real_classifier([fixture])
+ run = _ci_run(classified)
+ reached = {lane: classified[lane] and _reached(run, *job) is not None
+ for lane, job in _FIXTURE_LANE_JOBS.items()}
+ reached["desktop_updater"] = classified["desktop_updater"] and _windows_desktop_updater_tests_selected(run)
+ return reached
+
+
+def test_marker_corpus_change_runs_every_language_that_reads_it():
+ """The corpus is A7 rule 7's single source of truth for four readers. Classified by
+ path alone it selected ``python`` only: cargo (marker_tests.rs), vitest
+ (update-marker-corpus.test.ts) and the PowerShell corpus test (desktop_updater on
+ the Windows lane) never ran on the PR that edited their expected answers."""
+ reached = _fixture_lanes_reached(_CORPUS)
+ assert all(reached.values()), f"{_CORPUS}: a corpus consumer's lane never runs: {reached}"
+
+
+def _tracked_mentions(name: str) -> list[str]:
+ try:
+ out = subprocess.run(["git", "-C", str(_REPO), "grep", "-l", "-F", name, "--", "."],
+ capture_output=True, text=True, timeout=60)
+ except OSError:
+ pytest.skip("git unavailable: cannot list the fixture's consumers")
+ if out.returncode not in (0, 1):
+ pytest.skip(f"not a git checkout: {out.stderr.strip()[:200]}")
+ return out.stdout.split()
+
+
+def test_every_test_that_reads_a_shared_fixture_is_routed_by_it():
+ """Derived, not remembered: every test file in the tree that names a shared fixture is
+ a listed consumer, and the fixture selects each test lane that consumer's own edit would."""
+ assert _CORPUS in cc._SHARED_FIXTURE_CONSUMERS
+ for fixture, listed in cc._SHARED_FIXTURE_CONSUMERS.items():
+ readers = {p for p in _tracked_mentions(Path(fixture).name) if _TEST_FILE.search(p)}
+ assert readers <= set(listed), f"{fixture}: unlisted consumer(s) {sorted(readers - set(listed))}"
+ if (_REPO / fixture).is_file(): # the fixture's own PRs land it with its consumers
+ missing = [c for c in listed if not (_REPO / c).is_file()]
+ assert not missing, f"{fixture}: listed consumer(s) left the tree: {missing}"
+ on = cc.classify([fixture])
+ for consumer in listed:
+ own = cc.classify([consumer])
+ lost = [lane for lane in cc._FIXTURE_CONSUMER_LANES if own[lane] and not on[lane]]
+ assert not lost, f"{fixture}: editing it skips {lost}, which run {consumer}"
+
+
# -- ownership: the update entry points' real imports ---------------------------------------
_SKIP_DIRS = {".git", ".venv", "venv", "node_modules", ".worktrees", "tests", "website", "__pycache__"}