Skip to content

ci: clippy skips three nested example workspaces and the device-only fixture - #1026

Merged
nihalpasham merged 2 commits into
NVIDIA:mainfrom
vyncint:ci/clippy-nested-example-workspaces
Aug 19, 2026
Merged

nihalpasham merged 2 commits into
NVIDIA:mainfrom
vyncint:ci/clippy-nested-example-workspaces

Conversation

@vyncint

@vyncint vyncint commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Summary

clippy.yml's per-example loop is one level deep:

for ex in crates/rustc-codegen-cuda/examples/*/; do

Three manifests sit below that and are not reachable from their parent either, because the parent does not list them in [workspace] members:

Manifest Why the parent run misses it
cutile_inter_kernel/simt own [workspace]
interop_cubin_identity/device own [workspace]
mathdx_ffi_test/libmathdx-sys plain path dependency

cargo builds the third as a dependency of its parent but never lints it, and the first two are separate workspace roots the parent run stops at. So none of the three has ever been linted — while fmt.yml reaches all three through its **/Cargo.toml glob. That asymmetry is what makes this a gap rather than a policy.

Membership is the test rather than a hardcoded list of three, so a future nesting is picked up without editing this file again.

A fourth, outside examples/ entirely

crates/cuda-macros/tests/device-only is its own workspace, so the root cargo clippy --workspace stops at it and the examples loop never sees it. It is also the only thing proving the #701/#702 property that a kernel-only crate needs no host surface, and check-device-only-build.sh runs cargo check on it but never a lint. Added explicitly.

Testing

Local, no GPU. All four are clean today, so this fails nothing now — verified by running cargo clippy --all-targets -- -D warnings in each:

cutile_inter_kernel/simt        Finished, no warnings (needs CUDA_TOOLKIT_PATH)
interop_cubin_identity/device   Finished, no warnings
mathdx_ffi_test/libmathdx-sys   Finished, no warnings
cuda-macros/tests/device-only   Finished, no warnings
  • Verified the step itself by extracting its run block from the parsed YAML and executing it with cargo clippy stubbed to echo: it visits 219 directories — the 215 top-level examples it visited before, plus the three nested manifests and the fixture — and the three parents are still visited separately, so nothing is lost
  • clippy.yml still parses
  • cargo oxide run <example> — not applicable, CI workflow only

vyncint and others added 2 commits August 18, 2026 23:53
…fixture

`clippy.yml`'s per-example loop is one level deep:

    for ex in crates/rustc-codegen-cuda/examples/*/; do

Three manifests sit below that and are not reachable from their parent either,
because the parent does not list them in `[workspace] members`:

  cutile_inter_kernel/simt          own [workspace]
  interop_cubin_identity/device     own [workspace]
  mathdx_ffi_test/libmathdx-sys     plain path dependency

cargo *builds* the third as a dependency of its parent but never lints it, and
the first two are separate workspace roots the parent run stops at. So none of
the three has ever been linted, while `fmt.yml` reaches all three through its
`**/Cargo.toml` glob -- the asymmetry is what makes this a gap rather than a
policy.

Membership is the test rather than a hardcoded list of three, so a future
nesting is picked up without editing this file again.

A fourth workspace is outside `examples/` entirely and outside every existing
scope: `crates/cuda-macros/tests/device-only`. It is its own workspace, so the
root `cargo clippy --workspace` stops at it, and the examples loop never sees
it. It is also the only thing proving the NVIDIA#701/NVIDIA#702 property that a kernel-only
crate needs no host surface, and `check-device-only-build.sh` runs
`cargo check` on it but never a lint. Added explicitly.

All four are clean today, so this fails nothing now -- verified by running
`cargo clippy --all-targets -- -D warnings` in each:

  cutile_inter_kernel/simt        Finished, no warnings (needs CUDA_TOOLKIT_PATH)
  interop_cubin_identity/device   Finished, no warnings
  mathdx_ffi_test/libmathdx-sys   Finished, no warnings
  cuda-macros/tests/device-only   Finished, no warnings

Verified the step itself by extracting its `run` block from the parsed YAML and
executing it with `cargo clippy` stubbed to `echo`: it visits 219 directories --
the 215 top-level examples it visited before, plus the three nested manifests
and the fixture -- and the three parents are still visited separately, so
nothing is lost. `clippy.yml` still parses.

Signed-off-by: Vyncint Ng <[email protected]>
…ssumptions

All four directories the new step visits resolve against tracked
lockfiles: cutile_inter_kernel/simt, interop_cubin_identity/device and
the device-only fixture carry their own Cargo.lock, and
mathdx_ffi_test/libmathdx-sys resolves through its parent's lock as a
path-dependency member. check-device-only-build.sh already runs the
fixture with --locked because a check that can rewrite its own input is
not a check; the lint invocations now hold the same line. Verified with
cargo metadata --locked in all four directories.

Also record the two assumptions behind the members-list grep: skipping
a member is only safe because the parent's own clippy run lints it, and
a [workspace] exclude entry would match the pattern the same way and
wrongly skip that directory (no example uses exclude today).
@nihalpasham nihalpasham added enhancement New feature or request build-related Build scripts, toolchain discovery, or compilation setup labels Aug 19, 2026
@nihalpasham

Copy link
Copy Markdown
Collaborator
  • Dry-ran the discovery loop against the tree: it visits the three nested workspace roots plus the fixture and skips the seven parent-workspace members. The mathdx gap is real: libmathdx-sys hides behind a non-default feature the parent clippy run never builds.
  • One commit layered on: the four new invocations now pass --locked (three of the four directories track lockfiles, and the fixture's guard script already treats unlocked re-resolution as a defect), plus a comment recording the members-grep's assumptions.

@nihalpasham
nihalpasham merged commit fa90871 into NVIDIA:main Aug 19, 2026
80 of 81 checks passed
nihalpasham pushed a commit that referenced this pull request Aug 19, 2026
…checks (#1047)

CONTRIBUTING tells contributors to run `cargo oxide fmt` rather than a bare
`cargo fmt` for one stated reason: otherwise the gate "will fail on code you
never had a chance to format." That only holds while the command covers what
the gate covers, and since #1027 it does not.

`.github/workflows/fmt.yml` checks four scopes: the root workspace, the codegen
backend, `crates/cuda-macros/tests/device-only`, and every `Cargo.toml` under
`examples/` via a `**` glob -- 225 manifests, nested ones included.
`format_all` checked three: root, backend, and `cargo fmt --all` in each of the
215 top-level example directories. That misses exactly three manifests:

  * the device-only fixture, which is not under `examples/` at all and had no
    scope of its own here (the gate gained one in #1027)
  * `examples/cutile_inter_kernel/simt`
  * `examples/interop_cubin_identity/device`

The last two are the only nested example manifests declaring their own
`[workspace]`, so the parent's `cargo fmt --all` stops before reaching them.
The other eight nested manifests are path-dependency members and were already
covered.

Measured, with one unformatted function appended to a file in each of the
three: `cargo fmt --all` in `cutile_inter_kernel` and in
`interop_cubin_identity` both exit 0, and `cargo oxide fmt --check` walked 185
scopes -- including both of those parents -- reporting no failure and never
printing a fixture scope at all. The gate catches all three: the fixture step
exits 1, and `cargo fmt --manifest-path` on each nested manifest exits 1.

The examples loop becomes one `--manifest-path` run per manifest found, which
is what the gate does, for the two reasons the gate's own comment gives:
`--all` stops at a nested `[workspace]`, and `--all` also formats an example's
path dependencies, so running it per example re-formats the large shared
workspaces 215 times. That second point was expensive: the old implementation
had not finished 185 of 217 scopes after roughly 25 minutes, while the new one
covers all 228 in 19 seconds.

The walk skips `target` and dot directories. The gate's glob does not need to
-- a fresh checkout has no build directories -- but a working tree does, and a
packaged or vendored manifest under one is not a crate this repository formats.
A unit test covers the walk: nested manifests found, workspace members found,
`target/` and dot directories skipped.

Three documentation sites stated the old three-scope shape and are corrected:
the function's own doc comment, CONTRIBUTING's formatting section (whose clippy
paragraph also said "the same three scopes" -- clippy has more, since #1026),
and the `cargo oxide fmt` comment in the book's CLI block.

Verified: 228 scopes visited, matching the gate's four exactly; with the three
probe files unformatted it reports exactly those three diffs and exits 1; on
the clean tree it exits 0 in 19 seconds; and `cargo test -p cargo-oxide
--all-targets` passes 177 tests with `clippy --all-targets -- -D warnings`
clean.

Signed-off-by: Vyncint Ng <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build-related Build scripts, toolchain discovery, or compilation setup enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants