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
24 changes: 24 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ members = [
"rs/moq-mux",
"rs/moq-native",
"rs/moq-net",
"rs/moq-net/fuzz",
Comment thread
kixelated marked this conversation as resolved.
Resolved
"rs/moq-nvenc",
"rs/moq-relay",
"rs/moq-rtc",
Expand Down
4 changes: 2 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ check $BASE="":
check-all *args:
just _tools ALL
just js check
just rs check --workspace {{ args }}
just rs check --workspace --exclude moq-net-fuzz {{ args }}
cargo run --quiet --locked --package quest -- check
# Not covered by the line above: moq-wasm only exists on the wasm32 target.
just rs wasm
Expand Down Expand Up @@ -776,7 +776,7 @@ fix $BASE="":
# Auto-fix every JavaScript workspace and every default Rust member.
fix-all:
just js fix
just rs fix --workspace
just rs fix --workspace --exclude moq-net-fuzz
just py fix
just dart fix
just obs fix
Expand Down
64 changes: 37 additions & 27 deletions rs/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ set working-directory := '..'
_rust_cargo := env_var_or_default("RUST_CARGO", "cargo")
cargo_compile := if _rust_cargo == "" { "cargo" } else { _rust_cargo }

# `moq-net-fuzz` is a workspace member only so it shares the root lockfile; libFuzzer
# needs a nightly toolchain and sanitizer flags, so `just rs fuzz` is the one recipe
# that may compile it. Every `--workspace` below therefore carries this, and a new
# one that forgets it pays a vendored C++ libFuzzer build for nothing. The root
# justfile's `check-all` and `fix-all` spell it out, since a module cannot read this.
no_fuzz := "--exclude moq-net-fuzz"

default:
just check

Expand All @@ -50,25 +57,10 @@ check *args:
{{ cargo_compile }} clippy --locked --all-targets {{ args }} -- -D warnings
cargo fmt --all --check
just rs _doc-names
just rs _fuzz-lock
RUSTDOCFLAGS="-D warnings" {{ cargo_compile }} doc --locked --no-deps {{ args }}
cargo shear
cargo sort --workspace --check --no-format

# The fuzz harness is its own workspace, because libFuzzer needs nightly and
# sanitizer flags. Nothing in `check` or `test` builds it, so its lockfile drifts
# from the path dependencies it shares with the main workspace and nobody finds out
# until a `just rs fuzz` silently re-resolves it. Re-resolving against the committed
# lock is metadata only, so it costs no compilation and can sit in the PR gate.
_fuzz-lock:
#!/usr/bin/env bash
set -euo pipefail

if ! cargo metadata --locked --format-version 1 --manifest-path rs/moq-net/fuzz/Cargo.toml > /dev/null; then
echo "rs: run: cargo update --manifest-path rs/moq-net/fuzz/Cargo.toml --workspace" >&2
exit 1
fi

# Two targets whose names differ only by `-` vs `_` render to the same
# `target/doc/<name>`, and a `cargo doc` that selects both races to clean it: the
# collision warning escalates to `error: failed to remove directory` depending on
Expand Down Expand Up @@ -181,8 +173,19 @@ _select $FILES:
# `--no-deps` keeps this to workspace members and off the network.
metadata=$(cargo metadata --format-version 1 --no-deps)

# Every crate directory is named after the crate it holds, which is what
# makes a changed path a seed below. Verify it rather than trust it: under-
# A seed is the first path segment under `rs/`, so only a crate whose manifest
# sits directly at `rs/<dir>/Cargo.toml` can ever be one. Drop the rest here:
# `moq-net-fuzz` lives at `rs/moq-net/fuzz`, so its seed is already `moq-net`,
# and leaving it in the graph would select it as a dependent of the crate it
# fuzzes and compile libFuzzer on every moq-net diff.
#
# `manifest_path` is a native path, so normalize the separator before splitting
# on it. Windows would otherwise match no segment, drop every package, and
# select nothing at all, where the assertion below fails safe to ALL.
metadata=$(jq '.packages |= map((.manifest_path |= gsub("\\\\"; "/")) | select(.manifest_path | split("/")[-3] == "rs"))' <<< "$metadata")

# Every remaining crate directory is named after the crate it holds, which is
# what makes a changed path a seed below. Verify it rather than trust it: under-
# selecting silently checks nothing, so fall back to checking everything.
if jq -e '.packages[] | select((.manifest_path | split("/")[-2]) != .name)' <<< "$metadata" > /dev/null; then
echo "rs: a crate directory no longer matches its crate name; selecting everything." >&2
Expand Down Expand Up @@ -249,8 +252,8 @@ _select $FILES:
# spelling keeps those call sites working whatever spec form `_select` uses; the
# previous alternation matched `--package <name>` literally and silently stopped
# firing the moment the spec form changed. Ids are `path+file://<dir>#<version>`
# and `_select` has already verified every crate directory matches its crate
# name, so the last path segment is the name.
# and `_select` only emits crates whose directory it has verified matches
# their crate name, so the last path segment is the name.

# True when a selection includes a crate the wasm32 pass covers. One predicate
# rather than the same alternation in each gate, so the test below exercises what
Expand Down Expand Up @@ -307,6 +310,13 @@ _select-test:
[[ -z "$(just rs _select "rs/scripts/package-binary.sh")" ]] \
|| fail "a non-crate seed must select nothing"

# A crate nested inside another crate's directory is covered by its parent's
# seed. Selecting it directly would compile libFuzzer on every moq-net diff,
# and its directory name is not its crate name, so it would also mis-report.
fuzz=$(just rs _names "$(just rs _select "rs/moq-net/fuzz/fuzz_targets/lite.rs")")
grep -qw moq-net <<< "$fuzz" || fail "a fuzz diff must select moq-net: $fuzz"
! grep -qw fuzz <<< "$fuzz" || fail "a fuzz diff must not select the harness: $fuzz"

echo "rs: selection ok"

# Published crates need the current workspace version as the lower bound for
Expand Down Expand Up @@ -350,7 +360,7 @@ check-changed $FILES:
packages=$(just rs _select "$FILES")
case "$packages" in
"") echo "rs: no crates affected; skipping." ;;
ALL) just rs check --workspace ;;
ALL) just rs check --workspace {{ no_fuzz }} ;;
*) echo "rs: checking $(just rs _names "$packages")"; just rs check $packages ;;
esac

Expand All @@ -373,7 +383,7 @@ fix-changed $FILES:
packages=$(just rs _select "$FILES")
case "$packages" in
"") echo "rs: no crates affected; skipping." ;;
ALL) just rs fix --workspace ;;
ALL) just rs fix --workspace {{ no_fuzz }} ;;
*) echo "rs: fixing $(just rs _names "$packages")"; just rs fix $packages ;;
esac

Expand Down Expand Up @@ -404,7 +414,7 @@ fix-changed $FILES:

# Compile the whole workspace on a Windows host. Must run ON Windows.
windows *args:
{{ cargo_compile }} check --locked --workspace --exclude moq-gst --all-targets --features "moq-cli/play moq-cli/capture" {{ args }}
{{ cargo_compile }} check --locked --workspace --exclude moq-gst {{ no_fuzz }} --all-targets --features "moq-cli/play moq-cli/capture" {{ args }}

# Runs the `#[cfg(target_os = "macos")]` code past the compiler: moq-video's
# VideoToolbox encode/decode and its ScreenCaptureKit / AVFoundation capture,
Expand Down Expand Up @@ -503,10 +513,10 @@ audit:

# Compile the workspace at the feature extremes.
features:
{{ cargo_compile }} check --locked --workspace --all-targets --no-default-features
{{ cargo_compile }} clippy --locked --workspace --all-targets --all-features -- -D warnings
RUSTDOCFLAGS="-D warnings" {{ cargo_compile }} doc --locked --workspace --all-features --no-deps
{{ cargo_compile }} nextest run --locked --workspace --all-targets --all-features
{{ cargo_compile }} check --locked --workspace {{ no_fuzz }} --all-targets --no-default-features
{{ cargo_compile }} clippy --locked --workspace {{ no_fuzz }} --all-targets --all-features -- -D warnings
RUSTDOCFLAGS="-D warnings" {{ cargo_compile }} doc --locked --workspace {{ no_fuzz }} --all-features --no-deps
{{ cargo_compile }} nextest run --locked --workspace {{ no_fuzz }} --all-targets --all-features

# nextest, not `cargo test`, so a wedged test is killed instead of pinning a core
# until someone notices (`.config/nextest.toml` sets the timeout). The trade is
Expand Down Expand Up @@ -556,7 +566,7 @@ test-changed $FILES:
packages=$(just rs _select "$FILES")
case "$packages" in
"") echo "rs: no crates affected; skipping tests." ;;
ALL) just rs test --workspace ;;
ALL) just rs test --workspace {{ no_fuzz }} ;;
*) echo "rs: testing $(just rs _names "$packages")"; just rs test --no-tests=pass $packages ;;
esac

Expand Down
Loading
Loading