Merge pull request #484 from Luxuride/docs/contributing

docs(contributing): code quality rules for pull requests
This commit is contained in:
goldfishdev
2026-12-05 11:25:41 -06:00
committed by GitHub

133
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,133 @@
# Contributing
Small, single-subject pull requests get reviewed and merged fastest, and they are
what keeps a queue this busy reviewable. One fix, one feature, or one refactor per
PR: a maintainer can then take the part they are sure about and cherry-pick the rest
later, and a change that turns out wrong does not take the others down with it.
These are the quality rules reviews apply here, not style preferences. Each one
answers a failure that shows up quickly in a queue this size: a PR that mixes concerns
cannot be cherry-picked, an undocumented switch gets toggled by accident, a test
that would pass anyway hides the change it was written for.
How many commits that PR holds is yours to choose. Separate commits per decision make
cherry-picking easier and are welcome, but they are not required — the PR is what has
to hold one subject. Human and AI-assisted PRs are held to the same bar: never claim
a check ran or a behaviour was observed unless you ran it after your final edit.
`.github/pull_request_template.md` carries the six checks below as a checklist. The
two are meant to say the same thing: if you change a rule here, change it there.
## Titles
Start the title with the kind of change it is. This is a preference, not something
CI enforces — plenty of merged PRs here read as plain sentences — but it is what lets
the pull-request list be read at a glance:
- `feat(scope):` new behaviour
- `fix(scope):` a correction to behaviour that exists
- `perf(scope):` the same behaviour, faster
- `docs(scope):`, `test(scope):`, `refactor(scope):`, `chore(scope):` for the rest
`scope` is the area or crate the change touches (for example `gpu`, `shader`, `loader`,
`hle`, `formats`, `pe`, `pipeline`, `core`, `game`, `victory`, `run`, `tools`,
`xtask`, `docs`). It is optional: `fix: <what>` is fine when the area is obvious from
the sentence. Branch names read well as `fix/<what>` and `feat/<what>` too.
## Building on top of another pull request
Every pull request targets `main`. If your change depends on PRs that have not landed
yet, **keep it a draft until every one of them is merged.** Draft tells reviewers not
to read it yet; it comes off only after every dependency merges and the branch is
rebased onto `main`, not when the code is written.
- **List every dependency at the top of the description, as a checklist:**
```markdown
## Needs merged first
- [ ] #123
- [ ] #456
```
Check a box as each one merges. When the last one lands, rebase onto `main`, mark
the PR ready (`gh pr ready <number>`), and either remove the checklist or leave it
checked.
- **Branch from `main` whenever your files do not depend on their commits** (separate
files, or only referencing the PR number), so your diff contains only your own
commits.
- **If you had to stack on unmerged commits locally** to build or test, prefer waiting
until those PRs merge before opening upstream. If you open an early draft anyway,
target `main` (do not open PRs against someone else's branch or fork), note in
`## Needs merged first` which commits are borrowed, and strip them
(`git rebase --onto main <their-branch>`) once the dependencies land and before
marking the PR ready.
Never mark a PR ready for review while `## Needs merged first` still has unchecked
items or while the diff still carries unmerged commits from another PR: it reads as
one large change, gets their work reviewed twice, and breaks the moment their branch
moves.
## What a change has to hold
The quality bar, as opposed to the presentation rules above:
- **New behaviour (beyond bug fixes) is behind a switch that is off by default**, and
with the switch off the output is what `main` produces today. Say how the two were
compared.
- **Docs move with the code**: a new, changed, or removed switch is updated in docs
(`docs/SETTINGS.md` or `docs/DIAGNOSTICS.md`, and `run.conf.default` if
menu-exposed), and numbers in the docs match the code.
- **No unrelated cleanup**: reformatting, renames and dead-code removal belong in
their own PR; whole-tree formatting is the owner's pass over `main`, because it
rewrites files every other open PR touches.
- **A test that would pass without the change does not test the change** — name the
test that fails before it and passes after it, or say why no test can exercise it
here.
- **Check the queue before opening**: if an open PR already touches the same code or
problem, say whether this replaces it, follows it, or is independent of it.
- **Nothing that only exists in your fork**: `cargo xtask policy` passes (no
game/proprietary files or binaries), and version bumps, changelogs, personal
configuration and build output stay out.
## Checking it locally
```sh
cargo xtask install-hooks # run the asset policy on every commit
cargo xtask policy # check the whole tree
cargo test -p victory-shader # native Linux host tests
./build.sh check # MSVC target check for `victory`
PKG=victory-gpu ./build.sh test --lib # MSVC crate tests under Wine (needs `./setup.sh sdk`)
```
`victory-core`, `victory-pe`, `victory-formats`, `victory-pipeline`, `victory-game`,
`victory-shader` (without the `host` feature), and `xtask` build and test natively on
Linux (`cargo test -p <crate>`). `victory`, `victory-loader`, `victory-hle`,
`victory-gpu`, and `victory-shader --features host` require `x86_64-pc-windows-msvc`:
`./build.sh` builds and tests one crate at a time (`PKG=<crate> ./build.sh test`,
defaulting to `victory`), and `PROFILE=diag` includes `diagnostics`-gated modules and
tests that plain builds skip. Pure-Rust crates without C dependencies such as
`victory-loader` also pass `cargo check -p <crate> --target x86_64-pc-windows-msvc`
without the SDK.
When tests require Windows/D3D12 hardware, Wine, or a game title you do not have,
say clearly what compiled versus what actually ran. A clean `clippy` or `cargo check`
is not a passing test — it is the absence of one kind of complaint.
## What goes in the description
- What it does, in a couple of sentences.
- Which checks apply: GitHub counts every `- [ ]` and `- [x]` toward the PR's task
progress, so treat checklist items strictly as:
- `- [x]` — checked and done.
- `- N/A: <reason>` (plain `- ` bullet, or deleting the line) — does not apply
(e.g. docs-only PRs or plain bug fixes); ignored by GitHub's task counter.
- `- [ ]` — an open TODO signifying an unfinished PR (such as `- [ ] #123` in
`## Needs merged first` while a PR is still a draft). Never leave inapplicable
checks as `- [ ]` or tick them blindly.
- How it was checked, with the exact commands run, numbers measured, and what could
not be verified — a GPU-only change checked on Linux has to say so.
- What it costs: memory, frame time, new warnings, or a switch that is now on by
default.