Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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).
#
Expand Down
41 changes: 35 additions & 6 deletions sh/dispatch-query.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,33 +173,62 @@ 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)
self.assertEqual(sum(call.startswith("rs test-changed ") for call in calls), 1)
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
Expand Down
4 changes: 3 additions & 1 deletion sh/dispatch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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$)'
Expand Down
Loading