From e382251edd1ec5f032f74c013c622eb1b3838a75 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Thu, 22 Oct 2026 16:05:05 -0700 Subject: [PATCH] ci: scope flake checks to Nix and packaging inputs Skip Nix evaluation and runner VM checks for Rust source-only edits. Keep Cargo metadata and packaging assets covered, and include runner helper scripts and toolchain changes in the Nix gate. Co-Authored-By: GPT-6 --- flake.nix | 4 ++-- sh/dispatch-query.test.py | 41 +++++++++++++++++++++++++++++++++------ sh/dispatch.sh | 4 +++- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/flake.nix b/flake.nix index 58c5a22c38e..4d6d27e5ff8 100644 --- a/flake.nix +++ b/flake.nix @@ -667,8 +667,8 @@ # test` (see rs/justfile), reaching mbx through the Cargo shim the dev # shell puts on PATH. Neither path goes through crane. # `nix flake check` is kept -- it still validates flake eval + builds the - # dev shell -- but no longer compiles the workspace, so it's cheap - # enough that `just check` runs it on any Nix/Rust input change. Release + # runner tests. The dispatcher runs it for Nix and packaging inputs; + # Rust source changes use the Cargo gate above. Release # artifacts still build via crane `buildPackage` (see `packages` above / # release-*.yml). # diff --git a/sh/dispatch-query.test.py b/sh/dispatch-query.test.py index 212eb471d57..1bc6c7da99e 100644 --- a/sh/dispatch-query.test.py +++ b/sh/dispatch-query.test.py @@ -173,26 +173,36 @@ def test_platform_is_only_a_query(self): self.assertEqual(result.returncode, 2) self.assertEqual(result.stdout, "") - def test_ci_runs_one_lint_preamble_and_one_test_pass(self): + def run_ci(self, base="origin/main"): for tool in ("bun", "python3", "cargo", "wasm-bindgen", "jq", "shellcheck", - "shfmt", "taplo", "nixfmt", "actionlint", "quest", "nix"): + "shfmt", "taplo", "nixfmt", "actionlint", "quest", "nix", + "c++", "clang-format", "cmake", "dart", "dash", "gersemi", "go", + "gradle", "java", "kramdown-rfc", "pkg-config", "uniffi-bindgen-cpp", + "uniffi-bindgen-go", "uniffi_bindgen_dart", "uv", "xml2rfc"): path = self.bin / tool path.write_text("#!/bin/sh\nexit 0\n") path.chmod(0o755) just = self.bin / "just" just.write_text('#!/usr/bin/env bash\nprintf "%s\\n" "$*" >>"$CALLS"\n') just.chmod(0o755) + nix = self.bin / "nix" + nix.write_text('#!/usr/bin/env bash\nprintf "nix %s\\n" "$*" >>"$CALLS"\n') + nix.chmod(0o755) self.env.update(MOQ_DEV_SHELL="1", CALLS=str(self.root / "calls")) - self.change("rs/moq-clock/src/lib.rs") - self.env["PATH"] += f":{os.environ['PATH']}" + (self.root / "calls").unlink(missing_ok=True) + self.env["PATH"] = f"{self.bin}:{os.environ['PATH']}" for script in ("markdown.sh", "shell.sh"): path = self.repo / "sh" / script path.write_text("#!/bin/sh\nexit 0\n") path.chmod(0o755) - result = subprocess.run(["bash", "sh/dispatch.sh", "ci", "origin/main"], + result = subprocess.run(["bash", "sh/dispatch.sh", "ci", base], cwd=self.repo, env=self.env, text=True, capture_output=True) self.assertEqual(result.returncode, 0, result.stderr) - calls = (self.root / "calls").read_text().splitlines() + return (self.root / "calls").read_text().splitlines() + + def test_ci_runs_one_lint_preamble_and_one_test_pass(self): + self.change("rs/moq-clock/src/lib.rs") + calls = self.run_ci() self.assertTrue(any(call.startswith("rs lint-changed ") for call in calls), calls) self.assertFalse(any(call.startswith("rs check-changed ") for call in calls), calls) self.assertEqual(sum(call.startswith("rs lint-changed ") for call in calls), 1) @@ -200,6 +210,25 @@ def test_ci_runs_one_lint_preamble_and_one_test_pass(self): self.assertLess(next(i for i, call in enumerate(calls) if call.startswith("rs lint-changed ")), next(i for i, call in enumerate(calls) if call.startswith("rs test-changed "))) + def test_flake_checks_follow_nix_inputs_instead_of_rust_source(self): + for path, expected in (("rs/moq-net/src/lib.rs", False), + ("rs/moq-net/Cargo.toml", True), + ("rs/moq-c/native-libs/linux.txt", True), + ("rs/moq-video/src/frame/nv12_resize.ptx", True), + ("Cargo.toml", True), ("Cargo.lock", True), + ("rust-toolchain.toml", True), + ("flake.nix", True), ("flake.lock", True), + ("nix/runner/hog.py", True), + ("nix/runner/migrate.sh", True), + ("infra/example.nix", True), + ("quest/m1/example.md", False)): + with self.subTest(path=path): + self.change(path) + calls = self.run_ci() + (self.repo / path).unlink() + self.assertEqual("nix flake check" in calls, expected) + self.assertIn("nix flake check", self.run_ci("--all")) + def benchmark(): # Sweep path count and both job selections. No timing threshold: hosted setup diff --git a/sh/dispatch.sh b/sh/dispatch.sh index af88ecf0359..45395e399ca 100755 --- a/sh/dispatch.sh +++ b/sh/dispatch.sh @@ -90,7 +90,9 @@ declare -A scope=( # `obs check` compares the OBS pinned in buildspec.json, flake.nix, and # nixpkgs, and the last moves on a flake.lock bump alone. [obs]='^(cpp/obs/|sh/obs/|flake\.(nix|lock)$)' - [flake]='(^rs/|^Cargo\.(toml|lock)$|^flake\.lock$|\.nix$)' + # Rust source is compiled below. Nix reads Cargo metadata, packaging inputs, + # and its own modules and test helpers; those still gate the full flake. + [flake]='(^rs/.*\.(toml|txt|ptx|in)$|^Cargo\.(toml|lock)$|^rust-toolchain\.toml$|^flake\.lock$|^nix/|\.nix$)' # ts.yml's crate filters against the closure test/ts/run.sh builds, which # moves only with a manifest, the lockfile, or the harness's packages. [ts_paths]='^(rs/.*Cargo\.toml$|Cargo\.(toml|lock)$|test/ts/run\.sh$|\.github/workflows/release-gate\.yml$|sh/gh/ts-paths\.py$)'