diff --git a/justfile b/justfile index f3a9d59a0be..4614c2e657d 100644 --- a/justfile +++ b/justfile @@ -96,15 +96,16 @@ install: # Lints, compiles, and tests only the packages the branch changed plus # everything depending on them; `check --all` is the unscoped suite. BASE # defaults to the PR base, then a main/release upstream, then origin/main. -# Rust compiles once: its test build doubles -# as the clippy gate (see `rs check-test`). +# Rust's test build doubles as the clippy gate, with a targeted default-media +# lint for cfgs hidden by the device features (see sh/rs/select.sh). # Lint, compile, and test what the branch changed since BASE, plus its dependents. check $BASE="": sh/dispatch.sh check "$BASE" # The landing worker runs this gate in one job. The test build also enforces -# default-feature clippy; the feature matrix and optimized bindings run +# clippy; a separate lint covers media tests with default features. The +# feature matrix and optimized bindings run # nightly and on release PRs. Missing tools fail under CI_STRICT. The host # land gate also sets CHECK_FAIL_FAST=1, so a failing batch stops at its first # failed module. diff --git a/quest/m0/ci/README.md b/quest/m0/ci/README.md index 061a768aab2..9611626d2ec 100644 --- a/quest/m0/ci/README.md +++ b/quest/m0/ci/README.md @@ -163,7 +163,6 @@ The historical samples locate candidates; they are not controlled benchmarks. - [Binary release publishers run on their tag](/quest/m0/ci/release-tag-publishers.md) - brew, Go and Swift releases stop running through `workflow_run` on main - [The bench comparison builds moq-gst's catalog bench on its base](/quest/m0/ci/bench-base-build.md) - A paired bench comparison that selects `rust/gst/moq-gst/catalog` against `origin/main` builds the base side and reports a comparison, instead of marking it unavailable with "base build failed" - [The workspace-hack refuses trybuild edges and spares non-media builds](/quest/m0/ci/hakari-followups.md) - `hakari.py` refuses trybuild dev-dependency edges, and non-media Linux test builds stop needing libpipewire and libclang -- [moq-audio's default-feature test build is clippy-clean and gated](/quest/m0/ci/default-feature-test-lint.md) - the dead `retains`/`fail` under default-feature `--tests` clippy is fixed, and the gate catches it next time - [A release merge opens no stale release PR](/quest/m0/ci/release-pr-after-release.md) - `just rs release` publishes before it proposes, so a merged release isn't re-proposed - [Dependabot leaves the workspace-hack to hakari](/quest/m0/ci/dependabot-workspace-hack.md) - cargo group PRs stop hand-editing `rs/workspace-hack/Cargo.toml` - [mbx's free-space GC never removes a live target](/quest/m0/ci/mbx-gc.md) - the cargo shim stops deleting targets other sessions use when the host disk runs low diff --git a/quest/m0/ci/default-feature-test-lint.md b/quest/m0/ci/default-feature-test-lint.md deleted file mode 100644 index 107eed7d21b..00000000000 --- a/quest/m0/ci/default-feature-test-lint.md +++ /dev/null @@ -1,54 +0,0 @@ -# [S] moq-audio's default-feature test build is clippy-clean and gated - -## Goal - -`cargo clippy --locked -p moq-audio --tests -- -D warnings` (default -features, test cfg) passes on main, and the PR gate fails a change that -breaks that configuration again. Done when that configuration is clippy-clean -and the gate covers it. - -## Plan - -Planned 2026-11-03 (maintainer, `/quest-plan`), from the -[moq-dev/moq#7652](https://github.com/moq-dev/moq/pull/7652) iterate, which -saw the same finding on its branch and on main. - -Verified on `origin/main` at `3c9facb322` (2026-11-03): - -```text -$ cargo clippy --locked -p moq-audio --tests -- -D warnings -error: methods `retains` and `fail` are never used - --> rs/moq-audio/src/encode/producer.rs:517:16 -error: could not compile `moq-audio` (lib test) due to 1 previous error -``` - -Both methods are `#[cfg(any(feature = "capture", test))]`, but their only -callers are in `rs/moq-audio/src/encode/capture.rs`, which compiles only -with `capture`. A test build without `capture` compiles them with no caller. - -Why the gate misses it: the land gate lints Rust only through the one -`just rs test` build that `sh/rs/select.sh test` runs, and that build turns on -`moq-audio/capture` and `moq-audio/playback` whenever moq-audio is selected. -So moq-audio's default-feature test build is never compiled in the gate. -[moq-dev/moq#7786](https://github.com/moq-dev/moq/pull/7786), queued on 2026-11-03, -adds `--benches --examples` and each target's `required-features` to the same -build. It keeps the capture picks, so it doesn't catch this either. - -- Fix the cfgs: gate `retains` and `fail` on `feature = "capture"` alone, or - give them a caller outside `capture`. Audit the other - `cfg(any(feature = "...", test))` items the gate's feature picks hide, in - moq-audio and moq-video. -- Cover it in the gate without a second full compile, since the gate already - has only one Rust build (see `rs/justfile`'s `test` recipe comments). One - way is a lint, for example in `just rs lint`, that refuses - `cfg(any(feature = "X", test))` on an item whose callers are all behind - `X`, if that can be checked cheaply. Otherwise, measure the cost of - linting moq-audio's and moq-video's default-feature `--tests` build when - they are selected, and bring the numbers to the maintainer if it is not - small. - -Public API: none. Wire: none. - -## Related - -- [Gate each diff in under five minutes](/quest/m0/ci/five-minutes.md) - the gate's time budget any extra build must fit diff --git a/rs/justfile b/rs/justfile index a91f3240ca1..7cd0fbba4a4 100644 --- a/rs/justfile +++ b/rs/justfile @@ -158,6 +158,10 @@ macos-test: capture *args: bash sh/local.sh cargo clippy --locked -p moq-video -p moq-audio --all-targets --features moq-video/capture,moq-audio/capture,moq-audio/playback "$@" -- -D warnings +# Lint media tests without the device features the gate's test build enables. +media-defaults: + bash sh/local.sh cargo clippy --locked -p moq-audio -p moq-video --tests -- -D warnings + # The capture and playback tests drive synthetic devices, so they need no hardware. # Test the capture and playback features, which the default test pass skips. diff --git a/rs/moq-audio/src/encode/producer.rs b/rs/moq-audio/src/encode/producer.rs index f90b65f3388..5456d2ebcd2 100644 --- a/rs/moq-audio/src/encode/producer.rs +++ b/rs/moq-audio/src/encode/producer.rs @@ -513,7 +513,7 @@ impl Producer { } /// Whether unencoded history is still retained. - #[cfg(any(feature = "capture", test))] + #[cfg(feature = "capture")] pub(crate) fn retains(&self) -> bool { !self.backlog.is_empty() } @@ -611,7 +611,7 @@ impl Producer { /// [`finish`](Self::finish) the track with `err`, for a source that failed: subscribers keep /// every packet published, then get `err` instead of the end of stream. - #[cfg(any(feature = "capture", test))] + #[cfg(feature = "capture")] pub(crate) fn fail(&mut self, err: moq_net::Error) -> Result<(), Error> { self.end(Some(err)) } diff --git a/sh/dispatch.sh b/sh/dispatch.sh index 60494879ad8..c68c4bb0c40 100755 --- a/sh/dispatch.sh +++ b/sh/dispatch.sh @@ -330,8 +330,8 @@ step() { check:js) just js check-changed "$js_list" ;; check:workers) just js workers ;; check:moq_sh) just infra moq-sh test ;; - # The check keeps docs; the test phase enforces default-feature clippy - # without a second compile. + # The check keeps docs and the isolated default-media lint; the test + # phase enforces the other clippy checks in its existing build. check:rs) just rs lint-changed "$rs_list" ;; check:bench) python3 bench/compare.test.py diff --git a/sh/rs/select.sh b/sh/rs/select.sh index 94b6f26aa41..287b1a8644f 100755 --- a/sh/rs/select.sh +++ b/sh/rs/select.sh @@ -161,6 +161,12 @@ case "$action" in # Nightly runs the Send-depth proof (`just rs send-depth`) on its # pinned toolchain. just rs "$action" "${flags[@]}" + # The test build enables device features, which can hide unused items + # in the default-feature test cfg. Keep this compile isolated from the + # selected dependents, whose features would unify capture back in. + if [[ "$action" == lint ]] && wants '(moq-video|moq-audio)'; then + just rs media-defaults + fi # Device code behind the off-by-default `capture` feature. check-test # lints it through the test build, as for the default features. if [[ "$action" != lint ]] && wants '(moq-video|moq-audio)'; then diff --git a/sh/rs/select.test.py b/sh/rs/select.test.py index b0a3bf0311d..3bd914e0e81 100644 --- a/sh/rs/select.test.py +++ b/sh/rs/select.test.py @@ -124,15 +124,28 @@ def test_gate_runs_no_feature_matrix(self): self.assertEqual(self.selected(f"sh/rs/{owner}-features.sh"), []) def test_gate_leaves_send_depth_to_nightly(self): - # Nightly runs `rs send-depth` on the pinned toolchain; the gate's lint - # is the one cargo pass. + # Nightly runs `rs send-depth` on the pinned toolchain. for path in ("rs/moq-net/src/lib.rs", "rs/kio/src/lib.rs", "Cargo.lock"): with self.subTest(path=path): calls = self.selected(path) - self.assertEqual(len(calls), 1, calls) + self.assertEqual(len(calls), 2, calls) self.assertTrue(calls[0].startswith("rs lint "), calls) + self.assertEqual(calls[1], "rs media-defaults", calls) self.assertEqual(self.selected("sh/rs/send-depth.sh"), []) + def test_media_defaults_are_isolated_from_device_features(self): + for path in ("rs/moq-audio/src/lib.rs", "rs/moq-video/src/lib.rs", "Cargo.lock"): + for github_actions in (False, True): + with self.subTest(path=path, github_actions=github_actions): + calls = self.selected(path, github_actions=github_actions) + self.assertEqual(calls[-1], "rs media-defaults", calls) + self.assertEqual(calls.count("rs media-defaults"), 1, calls) + # A crate with no media dependents needs no extra compile. + for action in ("lint", "test"): + self.assertNotIn("rs media-defaults", self.selected("rs/moq-auth/src/lib.rs", action=action)) + # The device-feature test build stays a single build. + self.assertNotIn("rs media-defaults", self.selected("rs/moq-audio/src/lib.rs", action="test")) + def test_device_features_join_the_one_test_build(self): for path, features in ( ("rs/moq-audio/src/lib.rs", DEVICE_FEATURES),