xtask: add qa command to run policy, rustfmt, and clippy checks #545
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/545"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-24T04:43:01Z.
Motivation
Currently, contributors and CI systems have to run separate ad-hoc commands to verify repository requirements (
cargo xtask policy,cargo fmt,cargo clippy). There is no unified quality assurance command inxtaskto run all repository quality gates in sequence.Solution
Cmd::Qa { fix: bool }toxtask:Rule #1) viapolicy::run(root, false).cargo fmt --all -- --check(or automatically formats if--fixis passed).cargo clippy --workspace --all-targets).cargo xtask qa/cargo xtask qa --fix) to ensure their branch is ready for submission.No game files used.
Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-24T04:51:54Z.
### Technical Verification & Implementation Details
Context & Architecture
Contributors and CI systems previously had to invoke disparate commands to verify repository requirements (
cargo xtask policy,cargo fmt,cargo clippy). Adding a unifiedqasubcommand inxtaskallows contributors to run all repository quality gates in sequence locally before submitting a PR.Changes & Implementation
Cmd::Qa { fix: bool }toxtask/src/main.rs:policy::run(root, false).cargo fmt --all -- --check(or auto-formats with--fix).cargo clippy --workspace --all-targets).cargo xtask qaandcargo xtask qa --fix.Git Log Line & Verification
ext bdb014d xtask: add qa command to run policy, rustfmt, and clippy checks xtask/src/main.rs | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-)cargo xtask policy(Rule #1 compliance, zero game assets).rustfmt --edition 2024.Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-24T06:24:41Z.
### Call for Maintainer Review & Merge
Infrastructure and quality assurance improvement:
@Marvisak: Ready for review and merge when convenient!
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T08:45:56Z.
Review: COMMENTED
Read by hand before building:
xtask/src/main.rsaddsCommand::new("cargo")calls forfmtandclippyonly, with fixed arguments, run in the workspace root. That is safe. Atbdb014dthe xtask builds (cargo build -p xtask) on Windows 11, MSVC. I didn't runcargo xtask qa.As written, though, the gate can't pass:
maintoday.cargo fmt --all -- --checkreports 168 hunks in files nobody's PR touched (measured during #547's review). Soqafails for every contributor regardless of their change.qa --fixis risky. It runscargo fmt --allover the whole workspace, so a contributor following the hint reformats hundreds of unrelated lines into their PR, which makes it much harder to review and merge alongside the 400+ open PRs.-D warnings, so step 3 passes with warnings. That's fine if intended, but then "lints OK" overstates it.Suggestion: until main is formatted once, check only the files changed against
origin/main(rustfmt --edition 2024 --check <files>), and limit--fixto those files too.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-24T11:23:44Z.
Thanks @mercuryVM for the practical feedback on workspace formatting dynamics!
You're completely right: running
cargo fmt --allacross the whole tree causedqato fail on main's preexisting 168 unformatted hunks, and--fixwould pull unrelated formatting changes into contributors' PRs.I've updated
xtask/src/main.rsin commit366f485so that step 2:origin/main...HEAD/ working tree.rustfmt --edition 2024only on the modified files (with--checkon check, or formatting them on--fix).This ensures contributors can run
cargo xtask qa/cargo xtask qa --fixcleanly on their PR without touching or failing on unrelated files.Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T12:13:16Z.
Review: APPROVED
Re-tested
366f485on Windows 11, RTX 5070, MSVC:cargo xtask qanow completes ("All quality assurance checks passed") on this branch. The two existingundocumented_unsafe_blockswarnings are reported but don't fail it, and the working tree is untouched afterwards.This addresses my earlier comment, where
qafailed on main's pre-existing formatting and--fixrewrote the whole workspace:changed_rust_fileslimitsrustfmt(with or without--check) to the files changed againstorigin/main...HEAD, thenHEAD, then the work tree.root.join(line).is_file()), so deleted files don't break it.git,rustfmtandcargo, all from the user's own toolchain.--edition 2024is hard-coded. Reading it from the workspaceCargo.toml, or relying onrustfmt.toml, would keep it right after an edition bump.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T12:38:18Z.
Review: APPROVED
Useful QA gate.
run_qachains policy → rustfmt → clippy with clear step output and actionable failure messages (cargo xtask qa --fix). Details check out:rustfmt --edition 2024matches the workspace edition (verified in the rootCargo.toml).changed_rust_filestries committed diff (origin/main...HEAD), thenHEAD, then the working tree, dedups, and only checks files that still exist — reasonable for a pre-PR gate. Formatting only changed files keeps it fast.--workspace --all-targets; on this macOS machine the workspace clippy is clean, so the gate passes here.Verified locally: test-merge with current main (
ffe310e) clean;cargo test -p xtask --locked(macOS arm64, rustc 1.98.1) → 4 passed / 0 failed. Minor nit (non-blocking):run_qa/changed_rust_fileshave no unit tests — the git-diff fallback chain would be the part worth pinning if you want coverage later.Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-24T12:38:06Z.
Thank you @mercuryVM for testing and approving!
Acknowledged on the edition nit: reading the edition dynamically from
rustfmt.tomlor workspaceCargo.tomlis indeed a cleaner pattern to prevent edition bump drift. I'll include that refinement in future tooling updates.Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-24T12:56:48Z.
Thank you @catminou4 for testing and approving!
Much appreciated for verifying clean test-merge with main (
ffe310e) and passingcargo test -p xtask --lockedon macOS arm64.Regarding the nit on unit test coverage for the
run_qagit-diff fallback chain: completely agreed. Pinning the fallback logic (origin/main...HEAD->HEAD-> working tree) with mock git rev-parse/diff fixtures will make a great follow-up test improvement once this core command lands.Now with approvals from both @mercuryVM and @catminou4, PR #545 is clean, verified cross-platform, and ready for @Marvisak to merge!
Imported from Marvisak/VIctory. Originally posted by sebastianspicker on 2026-11-24T13:03:04Z.
Review: CHANGES_REQUESTED
I checked the
qaformat step at366f485by running its exactgit diffandrustfmtcalls onffe310e(macOS, rustfmt 1.98.1). I didn't runcargo xtask qaitself.rustfmt <file>also formats everymodthat file declares, and stable rustfmt can't turn that off. After a one-line, already-formatted change tovictory-gpu/src/lib.rs, the check fails on 14 other files, andqa --fixrewrites all 14. Two of them arelist.rsandwatch.rs, where formatting detaches the// SAFETY:comments (see #502), so the contributor's PR then fails Windows clippy inci.yml.-- -D warnings, soqaprints "All quality assurance checks passed" with the twoundocumented_unsafe_blockswarnings mercuryVM saw, whileci.ymlfails on them. Running it the wayci.ymldoes (cargo clippy --workspace --all-targets --locked -- -D warnings) would makeqapredict CI.changed_rust_filesstops at the first non-empty list, so once a branch has a commit, uncommitted edits are skipped. Withgpu/src/lib.rscommitted and an unformatted edit tovictory-pe/src/layout.rsin the work tree, onlylib.rsis checked.The first point has the same cause as #540: until a format pass lands (#502 or #112), per-file rustfmt checks files the PR didn't touch. After it lands,
cargo fmt --all -- --checkis enough and the file selection isn't needed.AI-assisted.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:23:00Z.
Automated triage for the maintainers.
Needs work. This needs the maintainer's decision: the new
cargo xtask qa(run_qaandchanged_rust_filesinxtask/src/main.rs) startsgit,rustfmtandcargoas child processes.The new head
f13d04ehas the same code as the head reviewed before, so the earlier points still apply:.github/workflows/ci.ymlruns Clippy with--locked -- -D warnings, once by default and once with--all-features.run_qaruns plaincargo clippy --workspace --all-targets, so warnings don't fail it and the all-features configuration is never checked.qacan pass a branch that CI rejects.changed_rust_filesstops at the firstgit diffthat lists any files. Once the branch has commits againstorigin/main, uncommitted edits are never checked. It also depends on a localorigin/mainref.--edition 2024rather than taken from the workspace.If the maintainer wants the command, matching the two CI Clippy invocations exactly would fix the main gap.
CI: passing.
Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-28T07:41:56Z.
@sebastianspicker Thank you for the detailed review! Updated the PR branch:
cargo clippy --workspace --all-targets --locked -- -D warningsto matchci.yml.changed_rust_filesnow collects across all threegit diffpasses (origin/main...HEAD,HEAD, and unstaged) without breaking early, so uncommitted edits are included alongside committed ones.(Note: stable
rustfmtstill recurses intomodchildren when formatting a crate root likelib.rsuntil a workspace-wide format pass lands.)@sebastianspicker Please re-review when convenient, and @Marvisak please review and merge once CI is green. Testers on untested setups are welcome to test.
AI-assisted: yes (Gemini 4 Neon)
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.