diff --git a/quest/m0/ci/README.md b/quest/m0/ci/README.md index c1666404b6d..b7fd13f40ca 100644 --- a/quest/m0/ci/README.md +++ b/quest/m0/ci/README.md @@ -139,4 +139,3 @@ The historical samples locate candidates; they are not controlled benchmarks. - [Padding runs](/quest/m0/ci/quic-padding.md) - moq-quic parses a PADDING run as one frame, keeping the padding stats' meaning - [tracing-test filter](/quest/m0/ci/tracing-filter.md) - moq-tokio's tests stop forcing every crate to format at TRACE - [Stats oversize](/quest/m0/ci/stats-oversize.md) - moq-stats refuses an oversized plain snapshot before parsing it back -- [Out-of-crate targets](/quest/m0/ci/out-of-crate-targets.md) - branch checks format and lint a crate whose target file lives outside it, such as the Rust interop clients diff --git a/quest/m0/ci/out-of-crate-targets.md b/quest/m0/ci/out-of-crate-targets.md deleted file mode 100644 index 7948dd9e586..00000000000 --- a/quest/m0/ci/out-of-crate-targets.md +++ /dev/null @@ -1,26 +0,0 @@ -# [S] Branch checks cover out-of-crate targets - -## Goal - -When a branch changes only a file that a Cargo target points at from outside -its crate, such as the Rust interop clients under -`test/interop/clients/rust/`, `just check` and `just fix` format and lint that -crate. - -## Plan - -Found by [moq-dev/moq#7015](https://github.com/moq-dev/moq/pull/7015). -`rs/moq-cli/Cargo.toml` builds those clients as examples through `path = -"../../test/interop/clients/rust/*.rs"`, but `sh/rs/select.sh` seeds crates -only from paths under `rs/` and `demo/` (and the `rs` scope in -`sh/dispatch.sh` matches the same way), so those files reach neither rustfmt -nor clippy. Seed from each target's `src_path` in the `cargo metadata` the -selector already reads instead of adding a moq-cli special case, and cover it -in the selector's tests. - -Decided 2026-10-28 (maintainer): the draft-18 FETCH cancel spelling the same -PR noted (a reset from Rust, a FIN from JS) is not a quest, since both sides -accept either as a draft-18 cancel (`fin_cancels` in -`rs/moq-net/src/ietf/request_stream.rs`). - -Public API: none. diff --git a/sh/dispatch.sh b/sh/dispatch.sh index b3f9f1c2dec..37b1dff5443 100755 --- a/sh/dispatch.sh +++ b/sh/dispatch.sh @@ -64,7 +64,9 @@ declare -A scope=( [workers]='^(infra/|demo/pub/|sh/js/workers\.sh$)' [moq_sh]='^infra/moq-sh/' # sh/rs/select.sh widens to the whole workspace for inputs every crate shares. - [rs]='^(\.cargo/|sh/local\.(sh|ts)$|rs/|demo/carla/bridge/|sh/rs/|Cargo\.(toml|lock)$|rust-toolchain\.toml$|\.config/nextest\.toml$)' + # moq-cli builds the Rust interop clients as examples from outside its + # crate; sh/rs/select.test.py fails when a target's directory is missing. + [rs]='^(\.cargo/|sh/local\.(sh|ts)$|rs/|demo/carla/bridge/|test/interop/clients/rust/|sh/rs/|Cargo\.(toml|lock)$|rust-toolchain\.toml$|\.config/nextest\.toml$)' [bench]='^bench/' # The CARLA demo's simulator worker and launchers. Its player is a JS # package and its GPU bridge a Rust crate, so those modules cover them. diff --git a/sh/rs/select.sh b/sh/rs/select.sh index ff26d988040..1cd75fe3abf 100755 --- a/sh/rs/select.sh +++ b/sh/rs/select.sh @@ -25,8 +25,6 @@ select_packages() { return fi - grep -qE '^(rs|demo)/' "$list" || return 0 - # `--no-deps` keeps this to workspace members and off the network. local metadata metadata=$(cargo metadata --format-version 1 --no-deps) @@ -53,11 +51,26 @@ select_packages() { # depend on and the test build never compiles, so it selects that crate alone # (for its lint) rather than every dependent's tests. benches=$(sed -n 's|^rs/\([^/]*\)/benches/.*|\1|p' "$list") + # A target can also sit outside its crate, as moq-cli's interop examples + # under test/interop/clients/rust/ do, so a change in the directory of a + # target's root file, which holds that file's modules, seeds its crate. + # Cargo leaves the manifest's `..` in `src_path`, so they are resolved here. + # sh/dispatch.sh's `rs` scope must match those directories too; the + # selector's tests check that. seeds=$({ sed -n '\|^rs/[^/]*/benches/|d; s|^rs/\([^/]*\)/.*|\1|p' "$list" - jq -r --rawfile list "$list" '($list | split("\n")) as $paths | .packages[] - | (.manifest_path | split("/")) as $p | select($p[-4] == "demo") - | select(any($paths[]; startswith("demo/\($p[-3])/\($p[-2])/"))) | .name' <<<"$metadata" + jq -r --rawfile list "$list" ' + def resolve: gsub("\\\\"; "/") | reduce split("/")[] as $s ([]; + if $s == ".." then .[:-1] elif $s == "." then . else . + [$s] end) | join("/"); + ($list | split("\n") | map(select(. != ""))) as $paths + | ((.workspace_root | resolve) + "/") as $root + | .packages[] + | (.manifest_path | split("/")) as $p + | ($p[:-1] | join("/") + "/") as $crate + | select(($p[-4] == "demo" and any($paths[]; startswith("demo/\($p[-3])/\($p[-2])/"))) + or any(.targets[].src_path | resolve | select(startswith($crate) | not) + | ltrimstr($root) | sub("[^/]*$"; ""); . as $dir | any($paths[]; startswith($dir)))) + | .name' <<<"$metadata" } | sort -u) edges=$(jq -r '.packages[] | .name as $name | .dependencies[] | "\($name) \(.name)"' <<<"$metadata") diff --git a/sh/rs/select.test.py b/sh/rs/select.test.py index 8817af5ec16..d7e50d35255 100644 --- a/sh/rs/select.test.py +++ b/sh/rs/select.test.py @@ -3,6 +3,7 @@ import json import os from pathlib import Path +import re import subprocess import tempfile import unittest @@ -113,6 +114,33 @@ def test_demo_crate_follows_its_dependencies(self): self.assertTrue(any("/demo/carla/bridge#moq-carla-bridge" in call for call in calls), calls) self.assertEqual(self.selected("demo/carla/web/src/main.ts"), []) + def test_out_of_crate_target_selects_its_crate(self): + # moq-cli builds the Rust interop clients as examples from outside its crate. + for path in ("test/interop/clients/rust/tail.rs", "test/interop/clients/rust/added.rs"): + for action in ("lint", "fix"): + with self.subTest(path=path, action=action): + calls = self.selected(path, action=action) + self.assertTrue(any(call.startswith(f"rs {action} ") and "/rs/moq-cli#" in call + for call in calls), calls) + self.assertEqual(self.selected("test/interop/compat/container.rs"), []) + + def test_dispatch_scope_covers_out_of_crate_targets(self): + scope = re.search(r"^\s*\[rs\]='([^']*)'", (ROOT / "sh/dispatch.sh").read_text(), re.M).group(1) + metadata = json.loads(subprocess.check_output( + ["cargo", "metadata", "--format-version", "1", "--no-deps"], cwd=ROOT, text=True)) + root = Path(metadata["workspace_root"]) + directories = set() + for package in metadata["packages"]: + crate = Path(package["manifest_path"]).parent + for target in package["targets"]: + source = Path(os.path.normpath(target["src_path"])) + if not source.is_relative_to(crate): + directories.add(source.parent.relative_to(root).as_posix()) + self.assertIn("test/interop/clients/rust", directories) + for directory in sorted(directories): + with self.subTest(directory=directory): + self.assertRegex(f"{directory}/added.rs", scope) + def test_a_bench_selects_only_its_crate(self): bench = "rs/moq-stats/benches/producer_tick.rs" for action in ("lint", "test"):