Checks and tests run for the part a change is in
The pre-commit hook ran clippy on the whole workspace for any Rust change; it now checks the crates touched and those built on them (ipx uses ipx-directory, both use ipx-feed), and nothing for a change to the page alone. CLAUDE.md says which tests go with which part. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,13 +1,26 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Refuses a commit whose Rust is not as rustfmt writes it, or that clippy warns about. Clippy only
|
# Refuses a commit whose Rust is not as rustfmt writes it, or that clippy warns about. Clippy only
|
||||||
# checks and never links, so it is light beside a test build (CLAUDE.md, Tests); with the line-tables
|
# checks and never links, so it is light beside a test build (CLAUDE.md, Tests). It checks the
|
||||||
# profile it takes about a minute after a change and seconds otherwise.
|
# crates the commit touches and those built on them, not the workspace: ipx uses ipx-directory,
|
||||||
git diff --cached --name-only --diff-filter=ACM | grep -q '\.rs$' || exit 0
|
# and both use ipx-feed. A commit to the page alone runs nothing here.
|
||||||
|
staged=$(git diff --cached --name-only --diff-filter=ACMD)
|
||||||
|
echo "$staged" | grep -q -e '\.rs$' -e 'Cargo\.toml$' -e '^Cargo\.lock$' || exit 0
|
||||||
if ! cargo fmt --all --check >/dev/null 2>&1; then
|
if ! cargo fmt --all --check >/dev/null 2>&1; then
|
||||||
echo "pre-commit: the Rust is not formatted; run cargo fmt --all" >&2
|
echo "pre-commit: the Rust is not formatted; run cargo fmt --all" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if ! cargo clippy --workspace --all-targets -q -- -D warnings; then
|
if echo "$staged" | grep -q -e '^Cargo\.toml$' -e '^Cargo\.lock$' -e '^crates/feed/'; then
|
||||||
echo "pre-commit: clippy has warnings; fix them, or allow one where it is wrong, with a comment saying why" >&2
|
pkgs="ipx-feed ipx-directory ipx"
|
||||||
|
elif echo "$staged" | grep -q '^crates/directory/'; then
|
||||||
|
pkgs="ipx-directory ipx"
|
||||||
|
elif echo "$staged" | grep -q '^crates/ipx/'; then
|
||||||
|
pkgs="ipx"
|
||||||
|
else
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
args=$(for p in $pkgs; do printf ' -p %s' "$p"; done)
|
||||||
|
# shellcheck disable=SC2086 # one word a flag
|
||||||
|
if ! cargo clippy $args --all-targets -q -- -D warnings; then
|
||||||
|
echo "pre-commit: clippy has warnings in $pkgs; fix them, or allow one where it is wrong, with a comment saying why" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
14
CLAUDE.md
14
CLAUDE.md
@@ -198,8 +198,18 @@ session was stopped. So:
|
|||||||
run in the background beside another, and never two crates' builds at once. Do not tune `-j`.
|
run in the background beside another, and never two crates' builds at once. Do not tune `-j`.
|
||||||
* Look at the load before and after each (`cat /proc/loadavg`). Above about 24, Tower's twelve
|
* Look at the load before and after each (`cat /proc/loadavg`). Above about 24, Tower's twelve
|
||||||
threads twice over, wait for it to come down before starting another.
|
threads twice over, wait for it to come down before starting another.
|
||||||
* Build only the crate the change is in (`cargo build -p ipx-directory`), and run only its tests
|
* Test only what the change is in. ipx uses ipx-directory, and both use ipx-feed, so:
|
||||||
until the change is done; the whole workspace's once, at the end.
|
|
||||||
|
| changed | run |
|
||||||
|
|---|---|
|
||||||
|
| `web/` alone | the three page checks; `npx playwright test -g '<what changed>'`; no cargo |
|
||||||
|
| `crates/ipx/` | `cargo test -p ipx`; the browser tests too if the API changed |
|
||||||
|
| `crates/directory/` | `cargo test -p ipx-directory`, then `-p ipx` |
|
||||||
|
| `crates/feed/` | `cargo test -p ipx-feed`, then `-p ipx-directory`, then `-p ipx` |
|
||||||
|
| `Cargo.toml`, `Cargo.lock` | all three, one at a time |
|
||||||
|
|
||||||
|
The pre-commit hook's clippy follows the same table. The whole browser suite once, at the end
|
||||||
|
of a change to the page or the API; never `cargo test` for the workspace in one command.
|
||||||
* Builds and test binaries live under `target/`, a link to `/mnt/fast`; linking through
|
* Builds and test binaries live under `target/`, a link to `/mnt/fast`; linking through
|
||||||
`/mnt/user` (FUSE) once took the load to 248 on its own.
|
`/mnt/user` (FUSE) once took the load to 248 on its own.
|
||||||
* **Memory is the tighter limit.** Tower has 31 GB, no swap, and the containers leave about 4-7
|
* **Memory is the tighter limit.** Tower has 31 GB, no swap, and the containers leave about 4-7
|
||||||
|
|||||||
Reference in New Issue
Block a user