Skip to content

build(just): run CI's guards from check, and let it work without a driver - #788

Merged
nihalpasham merged 2 commits into
NVIDIA:mainfrom
vyncint:fix/just-check-guards-and-driverless
Aug 11, 2026
Merged

nihalpasham merged 2 commits into
NVIDIA:mainfrom
vyncint:fix/just-check-guards-and-driverless

Conversation

@vyncint

@vyncint vyncint commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Two gaps in the one-command gate. Both surfaced by running just check rather
than reading it — I installed just specifically to check, and each attempt
failed for a different reason.

1. check skipped all four CI guards

It ran fmt, clippy, tests and docs, but none of the source-reading guards the
workflows enforce:

guard CI job
check-error-example-status.sh status-guard
check-example-smoketest-contract.sh status-guard
check-dependency-licenses.sh cargo-deny / license-manifest
check-example-license-policy.sh cargo-deny

They were reachable only by reading the workflows, so just check could pass
while status-guard or cargo-deny failed. None needs a GPU. All four now run from
a new check-guards.

They're invoked as bash scripts/..., matching the workflows — and that turns
out to be load-bearing: check-example-license-policy.sh and
check-example-smoketest-contract.sh carry no exec bit
, so a bare path exits
126 with "Permission denied". My first run hit exactly that.

2. check couldn't finish without a driver

The header said clippy and doc-check build cuda-bindings so a toolkit is needed
either way — true, but those need cuda.h at build time, while the
test-cuda binaries need libcuda.so.1 at load time. Different requirement,
and the one CONTRIBUTING calls the common case: "Most crates test on a machine
with no GPU and no NVIDIA driver."

$ just test-cuda      # on stock main, toolkit present, no driver
error while loading shared libraries: libcuda.so.1
exit 127

test-cuda now shadows the toolkit's link-time stub under that name itself —
the same thing unit-tests.yml does for driverless runners and CONTRIBUTING
documents by hand. No-op where a real driver provides the name; the shadow is a
mktemp -d removed on exit. This keeps the full coverage you wanted when you
added test-cuda to check, without requiring a driver to get it.

3. Incidental: just --list was showing sentence fragments

just uses a recipe's last comment line as its description, so multi-line
rationales leaked:

check      # used to skip entirely -- it needs `cargo-deny` on PATH.
test       # CI's own overrides.
doc-check  # valid Rust); its docs still build under the rustdoc allows ...

Five recipes now end their comment block with a one-line summary. Two of those
were pre-existing; fixing them alongside keeps the listing consistent.

Verified

With just 1.58 on a toolkit-only, driverless machine:

  • just --list reads cleanly
  • just check-guards → exit 0, all four guards report OK
  • just test-cuda → exit 127 before, exit 0 after
  • just check → exit 0 end to end

No GPU involved anywhere in this.

One thing I did not do: chmod +x the two guards missing the bit. Invoking via
bash matches how CI runs them and avoids a mode-only change, but say the word
if you'd rather have the bits made consistent instead.

…driver

Two gaps in the one-command gate, both found by running it rather than reading
it.

`check` ran fmt, clippy, tests and docs, but none of the four source-reading
guards CI enforces: the status-guard pair (error* examples in STATUS.md, and the
smoketest example contract) and the cargo-deny pair (the license inventory
covers the workspace and its example workspaces, and deny.toml holds over those
workspaces). They were reachable only by reading the workflows, so `just check`
could pass while status-guard or cargo-deny failed. None needs a GPU; all four
now run from `check-guards`.

They are invoked as `bash scripts/...`, which is how the workflows invoke them
and is load-bearing: `check-example-license-policy.sh` and
`check-example-smoketest-contract.sh` carry no exec bit, so a bare path exits
126 with "Permission denied". I hit that on the first run.

`check` also could not complete on a machine with a CUDA toolkit but no driver.
The header explained that clippy and doc-check build cuda-bindings so a toolkit
is needed either way, which is true, but those need `cuda.h` at build time while
the `test-cuda` binaries need `libcuda.so.1` at *load* time -- a different
requirement, and the one CONTRIBUTING calls the common case ("Most crates test
on a machine with no GPU and no NVIDIA driver"). On this machine:

    $ just test-cuda            # before
    error while loading shared libraries: libcuda.so.1
    exit 127

`test-cuda` now shadows the toolkit's link-time stub under that name itself, the
same thing unit-tests.yml does for driverless runners and CONTRIBUTING documents
by hand. It is a no-op where a real driver already provides the name, and the
shadow is a mktemp directory removed on exit.

Also gave five recipes a one-line summary as their last comment line. `just`
takes that line as the description, so a multi-line rationale left fragments in
`just --list`:

    check      # used to skip entirely -- it needs `cargo-deny` on PATH.
    test       # CI's own overrides.
    doc-check  # valid Rust); its docs still build under the rustdoc allows ...

Verified with `just` 1.58 on a toolkit-only, driverless machine: `just --list`
reads cleanly, `just check-guards` is exit 0 with all four guards reporting OK,
`just test-cuda` goes from exit 127 to exit 0, and the whole `just check` is
exit 0.

Signed-off-by: Vyncint Ng <[email protected]>
- check-guards now runs the root-workspace `cargo deny check`, so its
  claim of covering the cargo-deny workflow holds for all three of that
  workflow's jobs rather than two.
- The check comment names what stays CI-only (naming-guard's grep
  pipeline lives inline in its workflow with no script to invoke,
  examples-compile needs the CUDA codegen backend, plus the book build
  and CodeQL) instead of claiming every CI gate runs. The check-guards
  comment names its prerequisites: cargo-deny and python3.
- With LD_LIBRARY_PATH unset, the stub-shadow export ended in a colon,
  which puts the cwd on the loader search path. The
  ${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} expansion adds the joining
  colon only when the variable is set.
@nihalpasham nihalpasham added QoL-improvement Quality-of-life improvement; not a correctness fix build-related Build scripts, toolchain discovery, or compilation setup labels Aug 11, 2026
@nihalpasham

Copy link
Copy Markdown
Collaborator

Validated both ways:

  • with the real driver the stub branch is skipped and the tests run against the real libcuda;
  • a forced driverless dry run maps the toolkit stub with no trailing-colon cwd leak, and just check-guards / just check pass end to end.

I layered one commit on top: the root cargo deny check joins check-guards so its comment is true, the LD_LIBRARY_PATH expansion only adds a colon when the variable is set, and the comments now name precisely what stays CI-only. On your open question: keeping the bash prefix is right, it matches CI and two of the scripts are intentionally non-executable.

Merging.

@nihalpasham
nihalpasham merged commit 88b33d5 into NVIDIA:main Aug 11, 2026
38 checks passed
nihalpasham pushed a commit that referenced this pull request Aug 11, 2026
…803)

The follow-up offered on #794. That PR added a Command reference table
because the book documented 11 of the CLI's 15 subcommands; `test`, `fmt`,
`update` and `emit-ltoir` appeared nowhere. Nothing stops the table falling
behind again -- adding a variant to the clap enum is a one-line change and
no build compares the two.

`scripts/check-cli-doc-coverage.sh` compares the `Commands` enum in
`crates/cargo-oxide/src/main.rs` against the rows under `### Command
reference`, in both directions. A missing row is the common case; a row for
a command that no longer exists is worse, because a reader trusts it and
gets `unrecognized subcommand`.

Subcommands come from the enum rather than from `cargo oxide --help`: the
enum is the definition, reading it needs no cargo and no build, and that
keeps the guard in the same source-only class as its siblings. A guard that
needed a backend build to answer a documentation question would not get
run. The parse is cross-checked against the built binary -- both report the
same 15 commands, with no disagreement.

Deliberately not required to appear: anything carrying `hide = true`
(`__materializer-provenance` today) and clap's generated `help`, which is
not in the enum at all. Descriptions are out of scope, because clap's short
help is the doc-comment first line while the table's cells add MyST
backticks around names like `cuda-gdb`; comparing them literally would fail
on correct prose.

While wiring it up: `check-guards` was running five of the seven guards.
The crate-inventory and toolchain-parity jobs went into status-guard.yml in
#793 and #790 without being added to the recipe, so `just check` could pass
while status-guard failed -- exactly the drift #729 and #788 built that
recipe to prevent. My omission; all three are in now, and the stale counts
in its comment ("the status-guard pair", "two of the four") are fixed.

Verified: passes on the clean tree (15 documented, 1 hidden excluded), and
seven mutations each fail naming the cause -- new subcommand, deleted row,
invented row, a row for the hidden command, a rename, and both parse
self-tests. `just check-guards` is green end to end.

Signed-off-by: Vyncint Ng <[email protected]>
nihalpasham added a commit that referenced this pull request Aug 11, 2026
…805)

* ci: guard the book's CLI command reference against subcommand drift

The follow-up offered on #794. That PR added a Command reference table
because the book documented 11 of the CLI's 15 subcommands; `test`, `fmt`,
`update` and `emit-ltoir` appeared nowhere. Nothing stops the table falling
behind again -- adding a variant to the clap enum is a one-line change and
no build compares the two.

`scripts/check-cli-doc-coverage.sh` compares the `Commands` enum in
`crates/cargo-oxide/src/main.rs` against the rows under `### Command
reference`, in both directions. A missing row is the common case; a row for
a command that no longer exists is worse, because a reader trusts it and
gets `unrecognized subcommand`.

Subcommands come from the enum rather than from `cargo oxide --help`: the
enum is the definition, reading it needs no cargo and no build, and that
keeps the guard in the same source-only class as its siblings. A guard that
needed a backend build to answer a documentation question would not get
run. The parse is cross-checked against the built binary -- both report the
same 15 commands, with no disagreement.

Deliberately not required to appear: anything carrying `hide = true`
(`__materializer-provenance` today) and clap's generated `help`, which is
not in the enum at all. Descriptions are out of scope, because clap's short
help is the doc-comment first line while the table's cells add MyST
backticks around names like `cuda-gdb`; comparing them literally would fail
on correct prose.

While wiring it up: `check-guards` was running five of the seven guards.
The crate-inventory and toolchain-parity jobs went into status-guard.yml in
#793 and #790 without being added to the recipe, so `just check` could pass
while status-guard failed -- exactly the drift #729 and #788 built that
recipe to prevent. My omission; all three are in now, and the stale counts
in its comment ("the status-guard pair", "two of the four") are fixed.

Verified: passes on the clean tree (15 documented, 1 hidden excluded), and
seven mutations each fail naming the cause -- new subcommand, deleted row,
invented row, a row for the hidden command, a rename, and both parse
self-tests. `just check-guards` is green end to end.

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

* ci: cover the codegen backend's own workspace in both license guards

The second pass asked for in the #662 review: "a second pass over
`crates/rustc-codegen-cuda` (its own workspace, invisible to both
cargo-deny and this guard today)". Still true, and it had already cost a
row.

That crate carries its own `[workspace]` for the rustc-private dylibs, so
it is a third resolution alongside the root and the examples, and neither
existing guard reached it. The inventory guard read the root workspace
through `cargo metadata`, which stops at that boundary; the policy side ran
`cargo deny check` on the root and a script over the examples.

**Inventory, and a live omission.** `rustc_codegen_cuda` had no row in
dependency-licenses.csv at all -- the largest first-party crate in the
tree, missing from the inventory, while every other member carried a
`1st Party (workspace)` row. Nothing could have caught it. The guard now
unions the declared crates of both first-party workspaces, which takes it
from 41 to 55, and the missing row is added.

**Policy.** `cargo deny` now runs over that workspace too, in the same job
as the root run so the install is shared. This is narrower than it looks
and worth stating precisely: all 82 of its third-party crate *names* also
appear in the root graph, so nothing is unlicensed today. What differs is
versions -- 17 (name, version) pairs resolve there and nowhere else,
including `anyhow 1.0.100`, `libc 0.2.187` and `linkme 0.3.35` -- and
advisory and license verdicts are per version, so an advisory against one
of those 17 is invisible to the root run.

Verified:

  * the inventory guard passes with the row (55 crates) and, with the row
    removed again, fails naming exactly `rustc_codegen_cuda`;
  * banning `anyhow =1.0.100`, a backend-only version, leaves the root run
    at `bans ok` and makes the backend run fail with `error[banned]` --
    the new leg covers crates the root one cannot see;
  * `cargo deny --manifest-path crates/rustc-codegen-cuda/Cargo.toml
    --locked check` is clean on the current tree, so the policy half is
    prevention rather than a fix;
  * `just check-guards` green end to end, and both workflow files parse.

No `--config` on the new run: cargo-deny walks up from the manifest
directory to the repository-root deny.toml, the same resolution the
example-policy script already relies on.

Stacked on #803, which adds the CLI-reference guard to the same
`check-guards` recipe -- review only the second commit.

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

---------

Signed-off-by: Vyncint Ng <[email protected]>
Co-authored-by: nihalpasham <[email protected]>
nihalpasham added a commit that referenced this pull request Aug 12, 2026
* docs(contributing): point contributors at `just check`

CONTRIBUTING never mentions `just`, so the one-command gate that #729 and
#788 exist to provide is invisible to the person it was built for. The
Formatting and Style section lists the individual commands and even says of
clippy that "there is no single command covering them" -- true of that one
scope, but a reader comes away thinking hand-assembly is the only route,
and quietly skips the guards, the tests CI runs, and the docs gate.

Adds a short "Running the checks" section ahead of it: `just check`, what it
needs (a CUDA toolkit and cargo-deny, no GPU -- the CUDA-linked test
packages shadow the toolkit's libcuda stub themselves), and `just --list`
for the individual recipes.

It deliberately does not restate which CI jobs stay outside `just check`.
That list changes -- three PRs in flight move pieces in and out of it right
now -- and a copy here would rot the way the toolchain pin's copies did.
The `check` recipe's own comment is the single place that names them, so the
text points there instead. The hand commands below stay, since they are
worth knowing when you want one scope rather than the whole gate.

Verified: every claim checked against the Justfile -- `check` exists, 29
recipes carry the `--list` descriptions, the cargo-deny prerequisite and the
libcuda-stub shadowing are both real, and `check`'s comment does name the
CI-only jobs. `just --list` runs.

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

* docs(contributing): list python3 among the just check prerequisites

Signed-off-by: nihalpasham <[email protected]>

---------

Signed-off-by: Vyncint Ng <[email protected]>
Signed-off-by: nihalpasham <[email protected]>
Co-authored-by: nihalpasham <[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 QoL-improvement Quality-of-life improvement; not a correctness fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants