diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 1e9495f7044..e66080f43de 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -466,30 +466,35 @@ jobs: persist-credentials: false - uses: ./.github/actions/nix - name: Rust cache + id: setup uses: ./.github/actions/rust-cache with: access-key-id: ${{ secrets.MBX_R2_ACCESS_KEY_ID }} secret-access-key: ${{ secrets.MBX_R2_SECRET_ACCESS_KEY }} + # Independent checks keep running after a failure; the job still finishes red. - name: WebSocket fallback startup benchmark run: nix develop --command just js qmux-bench - name: Browser publisher fairness benchmark + if: ${{ !cancelled() && steps.setup.outcome == 'success' }} run: nix develop --command just js serve-bench shell: bash -leo pipefail {0} - name: Raw audio encoding benchmark + if: ${{ !cancelled() && steps.setup.outcome == 'success' }} run: nix develop --command just js raw-audio-bench shell: bash -leo pipefail {0} - name: Audio ring benchmark + if: ${{ !cancelled() && steps.setup.outcome == 'success' }} run: nix develop --command just js ring-bench shell: bash -leo pipefail {0} - name: Native headless playback - if: ${{ !cancelled() }} + if: ${{ !cancelled() && steps.setup.outcome == 'success' }} run: nix develop --command just test native-play shell: bash -leo pipefail {0} env: HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs - name: Audio quality - if: ${{ !cancelled() }} + if: ${{ !cancelled() && steps.setup.outcome == 'success' }} run: nix develop --command just test audio-quality --runtimes chromium --enforce --capture shell: bash -leo pipefail {0} env: @@ -508,7 +513,7 @@ jobs: # stall voids about one AAC row in seven, which would fail most nights until # it is fixed. Kept beside the browser run so its ceilings can be re-measured. - name: Native audio quality - if: ${{ !cancelled() }} + if: ${{ !cancelled() && steps.setup.outcome == 'success' }} run: nix develop --command just test audio-quality --runtimes native shell: bash -leo pipefail {0} env: @@ -517,7 +522,7 @@ jobs: # The run directory is the diagnosis: each process's log, the shaper's # counters, the raw samples, and every row's summary. - name: Keep the run - if: ${{ !cancelled() }} + if: ${{ !cancelled() && steps.setup.outcome == 'success' }} uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7 with: name: audio-quality-run diff --git a/.github/workflows/platform.yml b/.github/workflows/platform.yml index a178c017e75..f72fcb6dd0a 100644 --- a/.github/workflows/platform.yml +++ b/.github/workflows/platform.yml @@ -106,14 +106,16 @@ jobs: - name: Setup complete id: setup run: echo "Platform tools ready" - - name: Rust compile and tests + - name: Rust compile if: ${{ !cancelled() && steps.setup.outcome == 'success' && (needs.scope.outputs.rs == 'true') }} shell: bash env: CI_BASE: ${{ github.event_name != 'pull_request' && '--all' || '' }} - run: | - just rs windows "$CI_BASE" - just rs windows-test + run: just rs windows "$CI_BASE" + - name: Rust tests + if: ${{ !cancelled() && steps.setup.outcome == 'success' && (needs.scope.outputs.rs == 'true') }} + shell: bash + run: just rs windows-test - name: C if: ${{ !cancelled() && steps.setup.outcome == 'success' && (needs.scope.outputs.c == 'true') }} shell: bash @@ -159,13 +161,14 @@ jobs: - name: Setup complete id: setup run: echo "Platform tools ready" - - name: Rust compile and tests + - name: Rust compile if: ${{ !cancelled() && steps.setup.outcome == 'success' && (needs.scope.outputs.rs == 'true') }} env: CI_BASE: ${{ github.event_name != 'pull_request' && '--all' || '' }} - run: | - just rs macos "$CI_BASE" - just rs macos-test + run: just rs macos "$CI_BASE" + - name: Rust tests + if: ${{ !cancelled() && steps.setup.outcome == 'success' && (needs.scope.outputs.rs == 'true') }} + run: just rs macos-test - name: Swift simulator check if: ${{ !cancelled() && steps.setup.outcome == 'success' && (needs.scope.outputs.swift == 'true') }} run: just swift simulator diff --git a/quest/m0/nightly/README.md b/quest/m0/nightly/README.md index b896ebeb1de..fb51ffd967b 100644 --- a/quest/m0/nightly/README.md +++ b/quest/m0/nightly/README.md @@ -22,10 +22,8 @@ children for the causes nothing owned. This README's own work, after the children: -- Nightly's multi-step jobs (Features first) keep going past a failed step - and fail at the end, so one break never hides the steps after it. -- Confirm a scheduled run passes. Failures already owned elsewhere stay - there: the audio near-zero p95 row belongs to +- Confirm a scheduled run on `main` passes; never dispatch Nightly. Failures + already owned elsewhere stay there: the audio near-zero p95 row belongs to [audio jitter target](/quest/m1/audio-jitter-target/README.md), the macOS `receive_credit` timeout has no owner since its quest was deleted in [moq-dev/moq#6732](https://github.com/moq-dev/moq/pull/6732), so plan one under diff --git a/rs/justfile b/rs/justfile index 57ee63a5771..6b3f5b8e152 100644 --- a/rs/justfile +++ b/rs/justfile @@ -101,9 +101,13 @@ windows $BASE="": # Test the platform-sensitive crates on Windows, independent of the diff. windows-test: - just rs test --manifest-path rs/moq-auth/Cargo.toml - just rs test -p kio -p hang -p moq-tokio -p moq-sock -p moq-relay - just rs test -p moq-video --no-default-features --features render -E 'test(/^render::export::/)' + #!/usr/bin/env bash + set -euo pipefail + source sh/checks.sh + run just rs test --manifest-path rs/moq-auth/Cargo.toml + run just rs test -p kio -p hang -p moq-tokio -p moq-sock -p moq-relay + run just rs test -p moq-video --no-default-features --features render -E 'test(/^render::export::/)' + finish # Run io_uring tests when the branch affects the relay or its dependencies. [positional-arguments] @@ -144,14 +148,18 @@ macos $BASE="": # Test the platform-sensitive crates on macOS, independent of the diff. macos-test: - just rs test --manifest-path rs/moq-auth/Cargo.toml - just rs test -p kio -p hang -p moq-tokio -p moq-sock - just rs test -p moq-sock --features fast-apple-datapath - just rs test -p moq-video --no-default-features -E 'test(encode::backend::videotoolbox::tests)' - just rs test -p moq-video --no-default-features --features render -E 'test(/^render::export::/)' + #!/usr/bin/env bash + set -euo pipefail + source sh/checks.sh + run just rs test --manifest-path rs/moq-auth/Cargo.toml + run just rs test -p kio -p hang -p moq-tokio -p moq-sock + run just rs test -p moq-sock --features fast-apple-datapath + run just rs test -p moq-video --no-default-features -E 'test(encode::backend::videotoolbox::tests)' + run just rs test -p moq-video --no-default-features --features render -E 'test(/^render::export::/)' # The runner's paravirtual Metal device proves the IOSurface import, ignored elsewhere. - just rs test -p moq-video --no-default-features --features render --lib --run-ignored only \ + run just rs test -p moq-video --no-default-features --features render --lib --run-ignored only \ -E 'test(/^render::renderer::tests::(the_metal_import_matches_the_cpu_path|imports_survive_decoder_pool_recycling)$/)' + finish # Compile and lint the capture and playback features, which the default check skips. [positional-arguments] @@ -237,26 +245,30 @@ c-tests: # Compile the full feature matrix, including isolated combinations and their tests. features: - just rs net-features --all - just rs coroutines - just rs quic-features --all - just rs crypto-key - just rs tokio-features --all - just rs media-features --all - bash sh/local.sh cargo check --locked --workspace {{ no_fuzz }} --all-targets --no-default-features - bash sh/local.sh cargo check --locked -p moq-relay --no-default-features - just rs relay-minimal - bash sh/local.sh cargo check --locked -p moq-cli --no-default-features - just rs test -p moq-cli --no-default-features --features capture,websocket -E 'test(capture_window)' - just rs test -p moq-cli --no-default-features --features capture,pipewire,websocket -E 'test(capture_window)' - bash sh/local.sh cargo check --locked -p moq-bench --no-default-features - bash sh/local.sh cargo check --locked -p moq-boy --no-default-features + #!/usr/bin/env bash + set -euo pipefail + source sh/checks.sh + run just rs net-features --all + run just rs coroutines + run just rs quic-features --all + run just rs crypto-key + run just rs tokio-features --all + run just rs media-features --all + run bash sh/local.sh cargo check --locked --workspace {{ no_fuzz }} --all-targets --no-default-features + run bash sh/local.sh cargo check --locked -p moq-relay --no-default-features + run just rs relay-minimal + run bash sh/local.sh cargo check --locked -p moq-cli --no-default-features + run just rs test -p moq-cli --no-default-features --features capture,websocket -E 'test(capture_window)' + run just rs test -p moq-cli --no-default-features --features capture,pipewire,websocket -E 'test(capture_window)' + run bash sh/local.sh cargo check --locked -p moq-bench --no-default-features + run bash sh/local.sh cargo check --locked -p moq-boy --no-default-features # Alone, since the workspace's `kio/sim` dev-dependencies would unify `kio/async` back in. - bash sh/local.sh cargo check --locked --manifest-path rs/moq-auth/Cargo.toml --lib --all-features - bash sh/local.sh cargo check --locked -p moq-hls -p moq-rtmp -p moq-rtc --no-default-features --all-targets - bash sh/local.sh cargo clippy --locked --workspace {{ no_fuzz }} --all-targets --all-features -- -D warnings - RUSTDOCFLAGS="-D warnings" bash sh/local.sh cargo doc --locked --workspace {{ no_fuzz }} --all-features --no-deps - bash sh/rs/nextest.sh cargo nextest run --locked --workspace {{ no_fuzz }} --all-targets --all-features + run bash sh/local.sh cargo check --locked --manifest-path rs/moq-auth/Cargo.toml --lib --all-features + run bash sh/local.sh cargo check --locked -p moq-hls -p moq-rtmp -p moq-rtc --no-default-features --all-targets + run bash sh/local.sh cargo clippy --locked --workspace {{ no_fuzz }} --all-targets --all-features -- -D warnings + run env RUSTDOCFLAGS="-D warnings" bash sh/local.sh cargo doc --locked --workspace {{ no_fuzz }} --all-features --no-deps + run bash sh/rs/nextest.sh cargo nextest run --locked --workspace {{ no_fuzz }} --all-targets --all-features + finish # Compile and test the explicit-time model without async helpers or sessions. [positional-arguments] @@ -265,37 +277,46 @@ net-features *args: # Prove the poll-only library builds compile no coroutines and document cleanly. coroutines: - bash sh/rs/coroutines.sh kio -- --no-default-features --features macros,runtime,manual,serde - RUSTDOCFLAGS="-D warnings" bash sh/local.sh cargo doc --locked -p kio --no-deps --no-default-features --features macros,runtime,manual,serde - bash sh/rs/coroutines.sh moq-net -- --no-default-features - bash sh/rs/coroutines.sh moq-json -- --no-default-features - RUSTDOCFLAGS="-D warnings" bash sh/local.sh cargo doc --locked -p moq-json --no-deps --no-default-features - bash sh/rs/coroutines.sh hang -- --no-default-features - RUSTDOCFLAGS="-D warnings" bash sh/local.sh cargo doc --locked -p hang --no-deps --no-default-features - bash sh/rs/coroutines.sh moq-mux -- --no-default-features - RUSTDOCFLAGS="-D warnings" bash sh/local.sh cargo doc --locked -p moq-mux --no-deps --no-default-features - bash sh/rs/coroutines.sh moq-hls -- --no-default-features - RUSTDOCFLAGS="-D warnings" bash sh/local.sh cargo doc --locked -p moq-hls --no-deps --no-default-features - bash sh/rs/coroutines.sh moq-room -- --no-default-features - RUSTDOCFLAGS="-D warnings" bash sh/local.sh cargo doc --locked -p moq-room --no-deps --no-default-features - bash sh/rs/coroutines.sh moq-stats -- --no-default-features - RUSTDOCFLAGS="-D warnings" bash sh/local.sh cargo doc --locked -p moq-stats --no-deps --no-default-features - bash sh/rs/coroutines.sh moq-crypto -- --no-default-features --features sign,e2ee,provider,serde - RUSTDOCFLAGS="-D warnings" bash sh/local.sh cargo doc --locked -p moq-crypto --no-deps --no-default-features --features sign,e2ee,provider,serde - bash sh/rs/coroutines.sh rs/moq-auth/Cargo.toml -- --no-default-features + #!/usr/bin/env bash + set -euo pipefail + source sh/checks.sh + run bash sh/rs/coroutines.sh kio -- --no-default-features --features macros,runtime,manual,serde + run env RUSTDOCFLAGS="-D warnings" bash sh/local.sh cargo doc --locked -p kio --no-deps --no-default-features --features macros,runtime,manual,serde + run bash sh/rs/coroutines.sh moq-net -- --no-default-features + run bash sh/rs/coroutines.sh moq-json -- --no-default-features + run env RUSTDOCFLAGS="-D warnings" bash sh/local.sh cargo doc --locked -p moq-json --no-deps --no-default-features + run bash sh/rs/coroutines.sh hang -- --no-default-features + run env RUSTDOCFLAGS="-D warnings" bash sh/local.sh cargo doc --locked -p hang --no-deps --no-default-features + run bash sh/rs/coroutines.sh moq-mux -- --no-default-features + run env RUSTDOCFLAGS="-D warnings" bash sh/local.sh cargo doc --locked -p moq-mux --no-deps --no-default-features + run bash sh/rs/coroutines.sh moq-hls -- --no-default-features + run env RUSTDOCFLAGS="-D warnings" bash sh/local.sh cargo doc --locked -p moq-hls --no-deps --no-default-features + run bash sh/rs/coroutines.sh moq-room -- --no-default-features + run env RUSTDOCFLAGS="-D warnings" bash sh/local.sh cargo doc --locked -p moq-room --no-deps --no-default-features + run bash sh/rs/coroutines.sh moq-stats -- --no-default-features + run env RUSTDOCFLAGS="-D warnings" bash sh/local.sh cargo doc --locked -p moq-stats --no-deps --no-default-features + run bash sh/rs/coroutines.sh moq-crypto -- --no-default-features --features sign,e2ee,provider,serde + run env RUSTDOCFLAGS="-D warnings" bash sh/local.sh cargo doc --locked -p moq-crypto --no-deps --no-default-features --features sign,e2ee,provider,serde + run bash sh/rs/coroutines.sh rs/moq-auth/Cargo.toml -- --no-default-features + finish # Prove moq-crypto's key-only build, which moq-auth depends on, leaves out the transport and aws-lc-rs, then lint and test it alone; a workspace build unifies the default features back in. crypto-key: #!/usr/bin/env bash set -euo pipefail - graph=$(cargo tree --locked -p moq-crypto --no-default-features --features serde -e normal --prefix none) - if grep -E '^(aws-lc-rs|moq-net) ' <<<"$graph"; then - echo "moq-crypto without sign or e2ee must not depend on moq-net or aws-lc-rs" >&2 - exit 1 - fi - bash sh/local.sh cargo clippy --locked -p moq-crypto --no-default-features --all-targets -- -D warnings - bash sh/local.sh cargo clippy --locked -p moq-crypto --no-default-features --features serde --all-targets -- -D warnings - bash sh/rs/nextest.sh cargo nextest run --locked -p moq-crypto --no-default-features --features serde + source sh/checks.sh + key_only_dependencies() { + graph=$(cargo tree --locked -p moq-crypto --no-default-features --features serde -e normal --prefix none) || return + if grep -E '^(aws-lc-rs|moq-net) ' <<<"$graph"; then + echo "moq-crypto without sign or e2ee must not depend on moq-net or aws-lc-rs" >&2 + return 1 + fi + } + run key_only_dependencies + run bash sh/local.sh cargo clippy --locked -p moq-crypto --no-default-features --all-targets -- -D warnings + run bash sh/local.sh cargo clippy --locked -p moq-crypto --no-default-features --features serde --all-targets -- -D warnings + run bash sh/rs/nextest.sh cargo nextest run --locked -p moq-crypto --no-default-features --features serde + finish # Prove moq-quic leaves kio's dev-only clock runtime to its consumers, and lints without its default features; a workspace build unifies both back in. [positional-arguments] @@ -309,12 +330,17 @@ quic-features *args: echo 'usage: just rs quic-features [--all]' >&2 exit 2 fi - graph=$(cargo tree --locked -p moq-quic -e normal --prefix none) - if grep -E '^tokio ' <<<"$graph"; then - echo "moq-quic must not depend on a native runtime" >&2 - exit 1 - fi - bash sh/local.sh cargo clippy --locked -p moq-quic "${targets[@]}" --no-default-features -- -D warnings + source sh/checks.sh + dependencies() { + graph=$(cargo tree --locked -p moq-quic -e normal --prefix none) || return + if grep -E '^tokio ' <<<"$graph"; then + echo "moq-quic must not depend on a native runtime" >&2 + return 1 + fi + } + run dependencies + run bash sh/local.sh cargo clippy --locked -p moq-quic "${targets[@]}" --no-default-features -- -D warnings + finish # Compile media boundaries (--all isolates every mode) and prove expensive # native/render dependencies are absent when their features are excluded. diff --git a/sh/checks.sh b/sh/checks.sh new file mode 100644 index 00000000000..265e3605404 --- /dev/null +++ b/sh/checks.sh @@ -0,0 +1,15 @@ +# shellcheck shell=bash +# Source this in a suite, run independent commands with run, then call finish. +# Functions passed to run must return errors explicitly: Bash suppresses their +# errexit inside an if condition. External commands keep their own error handling. +failed=() +run() { + echo "checks: $*" + if ! "$@"; then failed+=("$*"); fi +} +finish() { + if ((${#failed[@]})); then + printf 'checks: failed: %s\n' "${failed[@]}" >&2 + return 1 + fi +} diff --git a/sh/gh/nightly.sh b/sh/gh/nightly.sh index 2017e3f034e..5a4fe03313c 100755 --- a/sh/gh/nightly.sh +++ b/sh/gh/nightly.sh @@ -54,11 +54,8 @@ if [[ -n $report ]]; then mkdir -p "$out/raw" fi -failed=() -run() { - echo "nightly: $*" - if ! "$@"; then failed+=("$*"); fi -} +# shellcheck source=sh/checks.sh +source "$(dirname "${BASH_SOURCE[0]}")/../checks.sh" criterion() { local label=$1 @@ -202,10 +199,7 @@ case "$1" in ;; esac -if ((${#failed[@]})); then - printf 'nightly: failed: %s\n' "${failed[@]}" >&2 - exit 1 -fi +finish if [[ -n $report ]]; then just gh benchmark-report "$report" "$out" "$out/report.json" diff --git a/sh/gh/nightly.test.py b/sh/gh/nightly.test.py index 09d596baf3e..8ea23e81a51 100644 --- a/sh/gh/nightly.test.py +++ b/sh/gh/nightly.test.py @@ -7,6 +7,7 @@ import shutil import subprocess import tempfile +import textwrap import unittest from pathlib import Path @@ -15,6 +16,122 @@ ROOT = Path(__file__).resolve().parents[2] +class FeaturesTest(unittest.TestCase): + def run_features(self, failures=(), nested=False, leaks=(), recipe="features"): + runner = shutil.which("just") + (ROOT / ".tmp").mkdir(exist_ok=True) + with tempfile.TemporaryDirectory(dir=ROOT / ".tmp") as directory: + scratch = Path(directory) + calls = scratch / "calls" + for command in ("just", "cargo"): + stub = scratch / command + stub.write_text( + textwrap.dedent("""\ + #!/usr/bin/env python3 + import json, os, subprocess, sys + from pathlib import Path + args = sys.argv[1:] + call = [os.path.basename(sys.argv[0]), *[ + 'mir=' if arg.startswith('mir=') else arg for arg in args + ]] + with open(os.environ['FEATURE_CALLS'], 'a') as output: + output.write(json.dumps(call) + '\\n') + if call in json.loads(os.environ['FEATURE_FAILURES']): + sys.exit(1) + if call[0] == 'just': + if os.environ['FEATURE_NESTED'] == '1' and args[1] in ( + 'net-features', 'quic-features', 'crypto-key', 'tokio-features', 'media-features', + 'coroutines', + ): + sys.exit(subprocess.call([os.environ['FEATURE_REAL_JUST'], *args])) + sys.exit(0) + if args[0] == 'tree': + for crate in json.loads(os.environ['FEATURE_LEAKS']): + print(crate + ' v1.0.0') + features = args[args.index('--features') + 1].split(',') if '--features' in args else [] + for feature, crates in { + 'openh264': ['openh264', 'openh264-sys2'], 'nvidia': ['moq-nvenc'], + 'render': ['wgpu'], 'vpx': ['libvpx-native-sys'], 'capture': ['cpal'], + }.items(): + if feature in features: + for crate in crates: + print(crate + ' v1.0.0') + elif args[0] == 'rustc': + for arg in args: + if arg.startswith('mir='): + Path(arg[4:]).write_text('') + """) + ) + stub.chmod(0o755) + result = subprocess.run( + [runner, "rs", recipe], + cwd=ROOT, + env=dict( + os.environ, + PATH=f"{scratch}:{os.environ['PATH']}", + FEATURE_CALLS=str(calls), + FEATURE_FAILURES=json.dumps(failures), + FEATURE_REAL_JUST=runner, + FEATURE_NESTED=str(int(nested)), + FEATURE_LEAKS=json.dumps(leaks), + LOCAL_SUPERVISED="1", + GITHUB_ACTIONS="false", + BASH_ENV="/dev/null", + ), + capture_output=True, + text=True, + ) + return result, [json.loads(line) for line in calls.read_text().splitlines()] + + def test_independent_checks_run_after_multiple_failures(self): + passed, expected = self.run_features() + self.assertEqual(passed.returncode, 0, passed.stderr) + # Early, middle, and final failures must all survive subsequent successes. + for failures in ([expected[0], expected[len(expected) // 2]], [expected[-1]]): + with self.subTest(failures=failures): + failed, calls = self.run_features(failures) + self.assertNotEqual(failed.returncode, 0) + self.assertEqual(calls, expected) + summary = [line for line in failed.stderr.splitlines() if line.startswith("checks: failed: ")] + self.assertEqual(len(summary), len(failures)) + for failure in failures: + self.assertTrue(any(" ".join(failure) in line for line in summary)) + + def test_platform_tests_run_after_a_failure(self): + for recipe in ("macos-test", "windows-test"): + with self.subTest(recipe=recipe): + passed, expected = self.run_features(recipe=recipe) + self.assertEqual(passed.returncode, 0, passed.stderr) + failed, calls = self.run_features([expected[0]], recipe=recipe) + self.assertNotEqual(failed.returncode, 0) + self.assertEqual(calls, expected) + self.assertIn("checks: failed: " + " ".join(expected[0]), failed.stderr) + + def test_nested_feature_checks_continue_after_compile_failures(self): + passed, expected = self.run_features(nested=True) + self.assertEqual(passed.returncode, 0, passed.stderr) + failures = [] + for package in ("kio", "moq-net", "moq-quic", "moq-crypto", "moq-tokio", "moq-video"): + failures.append( + next(call for call in expected if call[0] == "cargo" and call[1] != "tree" and package in call) + ) + failed, calls = self.run_features(failures, nested=True) + self.assertNotEqual(failed.returncode, 0) + self.assertEqual(calls, expected) + summary = "\n".join(line for line in failed.stderr.splitlines() if line.startswith("checks: failed: ")) + for package in ("kio", "moq-net", "moq-quic", "moq-crypto", "moq-tokio", "moq-video"): + self.assertIn(package, summary) + self.assertIn("checks: just rs coroutines", failed.stdout) + + def test_dependency_contract_failures_do_not_hide_checks(self): + passed, expected = self.run_features(nested=True) + self.assertEqual(passed.returncode, 0, passed.stderr) + failed, calls = self.run_features(nested=True, leaks=("cpal",)) + self.assertNotEqual(failed.returncode, 0) + self.assertEqual(calls, expected) + self.assertIn("moq-video minimal unexpectedly contains cpal", failed.stderr) + + class NightlyTest(unittest.TestCase): def run_group(self, group, fail="", cwd=ROOT, **environment): with tempfile.TemporaryDirectory() as directory: diff --git a/sh/rs/media-features.sh b/sh/rs/media-features.sh index 6f27ab49c6c..7877588e999 100755 --- a/sh/rs/media-features.sh +++ b/sh/rs/media-features.sh @@ -13,12 +13,14 @@ elif [[ $# != 0 ]]; then exit 2 fi +# shellcheck source=sh/checks.sh +source "$(dirname "${BASH_SOURCE[0]}")/../checks.sh" + targets=(--tests) if ((all)); then targets=(--all-targets); fi check() { - echo "media features: cargo check $*" - cargo check --locked "${targets[@]}" "$@" + run cargo check --locked "${targets[@]}" "$@" } # Resolved for Linux, the platform every asserted dependency targets: moq-nvenc @@ -32,7 +34,7 @@ require_crate() { local graph=$1 crate=$2 label=$3 if ! grep -Eq "^${crate} v" <<<"$graph"; then echo "media features: $label must contain $crate" >&2 - exit 1 + failed+=("$label must contain $crate") fi } @@ -40,7 +42,7 @@ forbid_crate() { local graph=$1 crate=$2 label=$3 if grep -Eq "^${crate} v" <<<"$graph"; then echo "media features: $label unexpectedly contains $crate" >&2 - exit 1 + failed+=("$label unexpectedly contains $crate") fi } @@ -52,7 +54,7 @@ minimal=$(tree -p moq-video --no-default-features) for crate in openh264 openh264-sys2 wgpu cpal; do forbid_crate "$minimal" "$crate" "moq-video minimal" done -cargo nextest run --locked -p moq-video --no-default-features +run cargo nextest run --locked -p moq-video --no-default-features if ((all)); then check -p moq-video --no-default-features --features openh264; fi software=$(tree -p moq-video --no-default-features --features openh264) @@ -76,7 +78,7 @@ require_crate "$vpx" libvpx-native-sys "moq-video VP8/VP9" for crate in openh264 openh264-sys2 wgpu; do forbid_crate "$vpx" "$crate" "moq-video VP8/VP9" done -cargo nextest run --locked -p moq-video --no-default-features --features vpx -E 'test(/::vpx::/)' +run cargo nextest run --locked -p moq-video --no-default-features --features vpx -E 'test(/::vpx::/)' if ((all)); then check -p moq-video --no-default-features --features render; fi render=$(tree -p moq-video --no-default-features --features render) @@ -111,4 +113,5 @@ if ((all)); then check -p moq-audio --no-default-features --features capture,pip audio_capture=$(tree -p moq-audio --no-default-features --features capture,pipewire) require_crate "$audio_capture" cpal "moq-audio PipeWire capture" +finish echo "media features: dependency contracts ok" diff --git a/sh/rs/net-features.sh b/sh/rs/net-features.sh index a7aca80cead..cf0f7bc5737 100644 --- a/sh/rs/net-features.sh +++ b/sh/rs/net-features.sh @@ -28,6 +28,10 @@ if grep -qE 'moq-net feature "(async|default|fuzz)"' <<<"$features"; then exit 1 fi -cargo clippy --locked -p moq-net --no-default-features --lib -- -D warnings -RUSTDOCFLAGS="-D warnings" cargo doc --locked -p moq-net --no-default-features --no-deps -bash sh/rs/nextest.sh cargo nextest run --locked -p moq-net --no-default-features --tests +# shellcheck source=sh/checks.sh +source "$(dirname "${BASH_SOURCE[0]}")/../checks.sh" + +run cargo clippy --locked -p moq-net --no-default-features --lib -- -D warnings +run env RUSTDOCFLAGS="-D warnings" cargo doc --locked -p moq-net --no-default-features --no-deps +run bash sh/rs/nextest.sh cargo nextest run --locked -p moq-net --no-default-features --tests +finish diff --git a/sh/rs/tokio-features.sh b/sh/rs/tokio-features.sh index 871779252fa..c4328fb151a 100755 --- a/sh/rs/tokio-features.sh +++ b/sh/rs/tokio-features.sh @@ -18,30 +18,36 @@ elif [[ $# != 0 ]]; then fi cd "$(git rev-parse --show-toplevel)" +# shellcheck source=sh/checks.sh +source "$(dirname "${BASH_SOURCE[0]}")/../checks.sh" -cargo clippy --locked -p moq-tokio --no-default-features -- -D warnings -cargo clippy --locked -p moq-tokio --all-features -- -D warnings +run cargo clippy --locked -p moq-tokio --no-default-features -- -D warnings +run cargo clippy --locked -p moq-tokio --all-features -- -D warnings # The QUIC driver is public API for applications without a MoQ session, so its # build must not reach moq-net, the MoQ backend's dependencies, or another QUIC stack. driver=(--no-default-features --features "driver") targets=(--tests) if ((all)); then targets=(--all-targets); fi -cargo clippy --locked -p moq-tokio "${targets[@]}" "${driver[@]}" -- -D warnings -graph=$(cargo tree --locked -p moq-tokio -e normal --prefix none "${driver[@]}") -if leaked=$(grep -E '^(moq-net|reqwest|notify|quinn[a-z-]*|noq[a-z-]*|web-transport[a-z-]*) ' <<<"$graph"); then - echo "rs: moq-tokio's driver build must not depend on:" >&2 - sort -u <<<"$leaked" >&2 - exit 1 -fi +run cargo clippy --locked -p moq-tokio "${targets[@]}" "${driver[@]}" -- -D warnings +driver_dependencies() { + graph=$(cargo tree --locked -p moq-tokio -e normal --prefix none "${driver[@]}") || return + if leaked=$(grep -E '^(moq-net|reqwest|notify|quinn[a-z-]*|noq[a-z-]*|web-transport[a-z-]*) ' <<<"$graph"); then + echo "rs: moq-tokio's driver build must not depend on:" >&2 + sort -u <<<"$leaked" >&2 + return 1 + fi +} +run driver_dependencies # Every isolated permutation, which `just rs features` asks for. if ((all)); then for feature in net quic tcp uds websocket webrtc; do - cargo clippy --locked -p moq-tokio --no-default-features --features "$feature" -- -D warnings + run cargo clippy --locked -p moq-tokio --no-default-features --features "$feature" -- -D warnings done fi # Crypto support alone must not make a transport-less server load a QUIC identity. -bash sh/rs/nextest.sh cargo nextest run --locked -p moq-tokio --lib \ +run bash sh/rs/nextest.sh cargo nextest run --locked -p moq-tokio --lib \ --no-default-features --features tcp \ -E 'test(no_quic_backend_needs_no_served_identity)' +finish