Repository navigation
CI: add asset-policy and formatting verification workflow - #540
pushkarreddyy wants to merge 4 commits into
Conversation
Technical Verification & Implementation DetailsContext & ArchitectureRule #1 (Asset Policy) is the central safeguard of the project. Prior to this PR, there was no automated GitHub Actions workflow to check incoming PRs for asset policy violations or formatting deviations. This workflow establishes an automated gate that runs in ~30 seconds on every push and PR. Changes & Workflow Design
Git Log Line & Verification
|
Call for Maintainer Review & MergeInfrastructure and quality assurance improvement:
@Marvisak: Ready for review and merge when convenient! |
mercuryVM
left a comment
There was a problem hiding this comment.
Read only, not built: a GitHub Actions workflow. The YAML is valid, has contents: read and a 10-minute timeout, and only runs cargo xtask policy and cargo fmt. Nothing in it is unsafe to run.
Two problems as written:
- The format step fails on every PR today.
cargo fmt --all -- --checkalready fails onmain: there are 168 diff hunks in files no PR touches (I measured this while reviewing #547). So every pull request goes red regardless of its own changes, which trains contributors to ignore the check. Either land a one-timecargo fmt --allcommit first, or check only the changed files (git diff --name-only origin/main... -- '*.rs' | xargs rustfmt --edition 2024 --check). cargo xtask policyonubuntu-latest: it works only if the xtask builds without the Windows-only crates. If it pulls in the workspace'swindows/windows-sysconsumers, it will fail on Linux. Worth one green run on a fork before relying on it.
Minor: dtolnay/rust-toolchain@stable with toolchain: 1.98.1 works but mixes two pins. Pinning the action to a commit SHA is the usual hardening for third-party actions.
Not merging this into our fork, since there it would run Actions on every push.
AI-assisted (Claude Code).
|
The format step is red on current If someone does that pass on its own, two things to know. Formatting moves the With the format pass and those two fixes, the same two commands this workflow runs both pass locally on AI-assisted. |
|
Thanks @mercuryVM and @sebastianspicker for the detailed measurement and context! You're completely right: running I've updated the workflow in commit |
mercuryVM
left a comment
There was a problem hiding this comment.
Read only, not built: CI workflow change (.github/workflows/policy.yml); I can't run GitHub Actions here. The new commit 5b7eb8a checks formatting only on the files a PR changes, which fixes the main-is-already-unformatted problem from my earlier comment. Two issues in the new step:
- Deleted files break it.
git diff --name-only origin/main...HEAD -- '*.rs'also lists.rsfiles the PR deletes, andxargs rustfmt --checkthen fails on a missing path. Add--diff-filter=d(orACMR) to thegit diff. #545'schanged_rust_filesalready filters withis_file(). - On pushes to main,
cargo fmt --all -- --check || truecan never fail, so the step reports success while checking nothing. Either drop the step forpushevents, or make it informative only (continue-on-error: truewith the real exit code), so a green tick isn't mistaken for "main is formatted". - Nit: unquoted
xargssplits on whitespace.git diff -z … | xargs -0 rustfmt …is safer if a path ever contains a space.
AI-assisted (Claude Code).
|
Thanks @mercuryVM for the sharp edge-case analysis! You're completely right on all three points:
I've updated the workflow in commit
|
catminou4
left a comment
There was a problem hiding this comment.
Workflow is well-formed: least-privilege contents: read, concurrency cancellation, 10-minute timeout, and the formatting step scoped to changed .rs files on PRs (origin/main...HEAD, which works here because fetch-depth: 0 fetches all refs). The main-branch cargo fmt --check is correctly continue-on-error while the tree is not fully formatted.
Two notes (non-blocking):
- It overlaps with #545's
cargo xtask qa(which also runs policy + rustfmt + clippy) — landing both is fine, but the maintainer may want one canonical gate. - Ordering with #547: this workflow only checks changed files, so the 179 pre-existing format diffs #547 would introduce won't fail unrelated PRs — #547 still needs its own reformat commit regardless.
Static review only (GitHub Actions YAML; not executed here).
sebastianspicker
left a comment
There was a problem hiding this comment.
Thanks for the quick updates. I ran the new format step from 72361d1 verbatim (bash -e, rustfmt 1.98.1) against GitHub-style merge commits on ffe310e. Deleted files, renames and paths with spaces work now. It still fails on code a PR didn't touch, though: rustfmt <file> also checks every mod that file declares, and stable rustfmt can't turn that off (skip_children is nightly-only).
- A one-line, already-formatted addition to
victory-gpu/src/lib.rsfails on 14 other files invictory-gpu. - The same addition to
victory-formats/src/texture.rsfails on that file's existing hunks. - On
ffe310e, 41 of 125.rsfiles fail when checked on their own, including the crate roots of formats, gpu, hle, loader and shader. By path, 317 of the 423 open PRs that touch Rust change at least one of them.
So pre-existing diffs do fail unrelated PRs whenever they touch a file that declares an unformatted module. I'd drop the changed-files step and keep a plain cargo fmt --all -- --check, landed with or after the format pass in #112.
Two smaller things. ci.yml landed on main after this PR (8e79c80) and already runs the asset policy through cargo test --workspace (repository_passes_policy), so the cargo xtask policy step here mostly adds a faster Linux signal. It doesn't need the Windows crates: it builds and passes on macOS at ffe310e (asset policy: 154 files ok). If you keep it, matching ci.yml (actions/checkout@v5, rustup toolchain install from rust-toolchain.toml) avoids a second toolchain pin. And the || true after git diff hides a failed diff: with origin/main missing (say after a fetch-depth change) the step prints "No Rust files modified in this PR." and exits 0 even with an unformatted file added.
The workflow hasn't run yet (both runs on the branch are action_required), so a green run on your fork would help.
|
Thank you @catminou4 for the thorough workflow review and approval! Much appreciated for verifying the least-privilege permissions, concurrency cancellation, and changed-file scoping. Regarding your notes:
Now that PR #540 is approved by @catminou4, it is ready for maintainer merge! |
|
This overlaps two other PRs before it is reviewed on its own merits: #17 runs the same rustfmt check with less machinery, and #481 already runs If this one is kept instead of #17/#481, two details: the toolchain is hard-coded to
AI-assisted review. |
|
Thanks @ricarmandoagent for the review and perspective! Regarding PR #540:
We are very happy to adapt to whichever approach @Marvisak and the maintainers prefer for the repository! |
|
Updated commit 637452f incorporates @ricarmandoagent's helpful suggestion to omit the explicit oolchain: input so dtolnay/rust-toolchain defers directly to |
…at check continue-on-error
637452f to
6b0a412
Compare
|
Automated triage for the maintainers. Closing because it does not change behaviour the project needs (formatting, guards for cases that cannot occur, or notes and translations that cannot be kept current). Second workflow for the asset-policy check, which main's ci.yml already runs inside the tests, plus rustfmt on changed files, which fails for any touched file because the workspace is not rustfmt-clean (#502). Installs If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution. |
Motivation
Rule #1 (Asset Policy) is the fundamental safeguard of the repository: "The repository holds only small text files we wrote. Zero proprietary game assets, executables, or long hex/base64 strings."
Currently, there is no automated GitHub Actions workflow to check incoming pull requests for asset policy violations or formatting deviations. A fast, dedicated workflow guarantees that every PR and commit is verified before review.
Solution
.github/workflows/policy.ymltargetingpushandpull_requestonmain.cargo xtask policy.cargo fmt --all -- --check.No game files used.