Skip to content

ci: Lint and test the Cargo feature sets that --workspace does not build - #2059

Merged
zackees merged 2 commits into
obs-rust:masterfrom
vpacher:ci/2056-feature-matrix
Oct 24, 2026
Merged

zackees merged 2 commits into
obs-rust:masterfrom
vpacher:ci/2056-feature-matrix

Conversation

@vpacher

@vpacher vpacher commented Oct 24, 2026

Copy link
Copy Markdown
Member

Refs #2056 (proposal 1, the feature matrix; proposal 2, [workspace.dependencies], is the next PR)

What and why

The --workspace clippy and test runs unify Cargo features. They build libobs-rust and obs-util only with gio on, and the opt-in features only off. CMake ships both gio states (libobs/cmake/os-linux.cmake, os-freebsd.cmake: NO_DEFAULT_FEATURES, then gio if Gio is found). So the #[cfg(not(feature = "gio"))] code in rust/obs-util/src/ffi/platform_nix_inhibit.rs was not compiled, linted or tested by any lane.

This PR adds the feature sets to the existing local-gate lanes. It adds no job and changes no workflow: the Fast Gate already runs ci/local_gate.py --lane lint and --lane rust-test.

  • FEATURE_SETS in ci/local_gate.py: the lint lane runs one clippy --all-targets -D warnings for each entry.
    • -p libobs-rust --no-default-features: libobs without GIO, as CMake builds it.
    • -p obs-util: obs-util's own test and bench targets with gio off.
    • -p obs-studio-rust --features libobs-integration: the native libobs contracts. Before, only a few macOS/Windows tests built this feature (Tier 2, Qt SDK step).
  • FEATURE_TEST_SETS: the rust-test lane runs the obs-util tests with gio off.
  • check_feature_sets() in the lint lane: it fails when a workspace feature is not built both on and off by some clippy run (the --workspace run or a FEATURE_SETS entry). It reads the workspace manifests with tomllib and follows the dependency tables (features, default-features, optional, dev and build dependencies) and the feature syntax (dep:x, x/y, x?/y). A new Cargo feature therefore needs an entry, or an exemption with a reason.
  • Exempt: obs-studio-rust/bundled-native and obs-sys/bundled. obs-sys/build.rs needs OBS_BUILD_RUST_ARCHIVE, a release libobs-rust staticlib, so they cannot build in the lint lane. Tier 2 checks them after its native build (validate.sh, validate.ps1).
  • ci/test_local_gate_probe.py: the scratch crate of the probe has no obs-util, so the probe skips the FEATURE_TEST_SETS runs, as it skips the windows-gnu step.
  • docs/rust-port/testing-policy.md describes the rule.

Without the FEATURE_SETS entries, the check reports the six gaps from #2056 on master 6891f69:

libobs-rust/gio: no clippy run builds it off
obs-build/libobs-integration: no clippy run builds it on
obs-studio-rust/bundled-native: no clippy run builds it on
obs-studio-rust/libobs-integration: no clippy run builds it on
obs-sys/bundled: no clippy run builds it on
obs-util/gio: no clippy run builds it off

No Rust code changes: the gio-off code and libobs-integration are clean today.

Cost (Debian 13 container, 6 cores, after a warm --workspace clippy, with the feature-set crates cleaned first): the three clippy runs take 3.0 s, 4.9 s and 2.0 s. The obs-util test build with gio off takes 7.7 s, and the 839 tests run in about 6 s. A CI runner with fewer cores takes longer.

RED → GREEN

  • RED commit: af16779 adds ci/test_feature_sets.py (14 tests) against stubs in ci/local_gate.py: 3 failures, 11 errors. ci/test_local_gate.py (18) passes.
  • GREEN: c0cf923. ci/test_feature_sets.py 14/14, ci/test_local_gate.py 18/18, ci/test_local_gate_probe.py OK (the soldr probe ran). Linux (Debian 13, kernel 6.x, soldr 0.9.38, Rust 1.98.1):
    • OBS_GATE_SKIP_SELF_TEST=1 uv run ci/local_gate.py --lane lint (as the Fast Gate runs it): ok, 42 s. + Cargo feature sets: 3 runs, every feature built on and off, all three clippy runs clean.
    • The FEATURE_TEST_SETS run (nextest + doctests): 839/839, doctests 2/2.
    • All ci/ self-tests: 1189 run. 3 errors in test_hybrid_packaging.py, because this host has no zstd; master 6891f69 gives the same 3 errors on this host.
    • Before the change, with SOLDR_RUSTC_WRAPPER=none: cargo tree -e features -i obs-util for -p obs-util and for -p libobs-rust --no-default-features shows no gio.
  • Real app: N/A (CI only).

Checklist

  • Base is master
  • I claimed the issue, or no one else has an open PR for it
  • RED, then GREEN commits
  • User-visible change: not applicable, no user-visible change
  • (Optional) Local gate passed and the pushed head is stamped; otherwise PR CI runs the full suite
  • Warning or flag changes: not applicable (no -W or ratchet change)
  • Intentional differences from C: not applicable (no port)

🤖 Generated with Claude Code

vpacher and others added 2 commits October 24, 2026 07:34
The --workspace clippy and test runs unify Cargo features, so they build
libobs-rust and obs-util only with gio on, and obs-build, obs-studio-rust
and obs-sys only with their opt-in features off. CMake ships both gio
states (os-linux.cmake and os-freebsd.cmake: NO_DEFAULT_FEATURES, then gio
if Gio is found), and the opt-in features are built only for a few tests
on macOS and Windows.

ci/test_feature_sets.py requires:
- feature_coverage(): every feature of a workspace crate is built on in
  one run and off in another (the --workspace run or a FEATURE_SETS
  entry), or has an exemption with a reason. A run counts as "off" only
  where it builds the crate. Dependency tables (features,
  default-features, optional, dev and build dependencies) and the
  feature syntax (dep:x, x/y, x?/y) decide what a run enables.
- the real workspace passes that check, and FEATURE_SETS has the gio-off
  run of libobs-rust; FEATURE_TEST_SETS tests obs-util with gio off.
- the lint lane calls check_feature_sets() and runs one clippy per
  FEATURE_SETS entry; the rust-test lane runs one cargo test per
  FEATURE_TEST_SETS entry.

ci/local_gate.py has stubs only, so all 14 tests fail (3 failures,
11 errors). ci/test_local_gate.py is unchanged and passes.

Refs obs-rust#2056

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The lint lane now runs one clippy for each entry of FEATURE_SETS in
ci/local_gate.py, and the rust-test lane one cargo test for each entry
of FEATURE_TEST_SETS:

- `-p libobs-rust --no-default-features`: libobs without GIO, as
  libobs/cmake/os-linux.cmake and os-freebsd.cmake build it when Gio is
  not found. obs-util is then built with gio off too.
- `-p obs-util`: obs-util's own test and bench targets with gio off.
  FEATURE_TEST_SETS runs its tests in this state, so the
  `#[cfg(not(feature = "gio"))]` code in platform_nix_inhibit.rs is
  compiled, linted and tested.
- `-p obs-studio-rust --features libobs-integration`: the native libobs
  contracts, which only a few macOS and Windows tests built before.

check_feature_sets() runs in the lint lane. It fails when a workspace
feature is not built both on and off by some clippy run (the --workspace
run or a FEATURE_SETS entry), so a new Cargo feature needs an entry or
an exemption with a reason. obs-studio-rust/bundled-native and
obs-sys/bundled are exempt: obs-sys/build.rs needs OBS_BUILD_RUST_ARCHIVE,
a release libobs-rust staticlib, and Tier 2 checks them after its native
build.

Without the entries, the check reports the six gaps of obs-rust#2056 on master:
libobs-rust/gio and obs-util/gio never off; obs-build/libobs-integration,
obs-studio-rust/libobs-integration, obs-studio-rust/bundled-native and
obs-sys/bundled never on.

docs/rust-port/testing-policy.md describes the rule.

Refs obs-rust#2056

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vpacher
vpacher requested a review from zackees as a code owner October 24, 2026 05:43
@zackees
zackees added this pull request to the merge queue Oct 24, 2026
Merged via the queue into obs-rust:master with commit bdbe899 Oct 24, 2026
30 checks passed
@vpacher
vpacher deleted the ci/2056-feature-matrix branch October 24, 2026 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants