diff --git a/.claude/skills/backend-development/SKILL.md b/.claude/skills/backend-development/SKILL.md index 45d219ecd..56d3443d6 100644 --- a/.claude/skills/backend-development/SKILL.md +++ b/.claude/skills/backend-development/SKILL.md @@ -93,7 +93,7 @@ npm run generate # writes src/__generated__/ via openapi-typescript-codegen ```bash cd backend uv run python3 main.py # run (migrations auto-apply on startup) -uv run pytest [path/file] # tests (subset by path); uv run pytest -vv for all +uv run pytest # tests - affected files only, NEVER the whole suite ``` - Tests: pytest + pytest-asyncio, isolated per `pytest-xdist` worker (per-worker DBs); `fakeredis`; `pytest-recording` VCR cassettes mock external APIs; Hypothesis for property tests. Mirror the `backend//` layout under `backend/tests/`. First-time test DB setup: `docker exec -i romm-db-dev mariadb -uroot -p < backend/romm_test/setup.sql`. diff --git a/.claude/skills/review-polish/SKILL.md b/.claude/skills/review-polish/SKILL.md index a6dc69988..4bf6cd302 100644 --- a/.claude/skills/review-polish/SKILL.md +++ b/.claude/skills/review-polish/SKILL.md @@ -210,7 +210,7 @@ With `uiVersion = "v2"`: Run from `backend/`: -1. `uv run pytest [path/file]` — zero failures (run the affected subset, or all with `-vv`). +1. `uv run pytest ` — zero failures on the tests affected by the diff. Never run the whole suite locally (20+ minutes); see [AGENTS.md](../../../AGENTS.md) for how to pick targets. CI runs it in full. 2. `trunk fmt && trunk check` — ruff/black/isort/mypy/bandit clean (CI enforces Trunk). 3. **If you added a migration:** `uv run alembic upgrade head` then `uv run alembic downgrade -1` to prove both directions; it must work on MariaDB **and** PostgreSQL (CI runs both). 4. **If a response schema or route signature changed:** regenerate frontend types (`npm run generate`) and typecheck the frontend. diff --git a/AGENTS.md b/AGENTS.md index 47ae8569e..dc6e8d20b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,3 +1,25 @@ # Repository Instructions Read and follow [CLAUDE.md](CLAUDE.md) for all repository instructions. + +## Never run the full backend test suite locally + +A bare `uv run pytest` (or `pytest -vv`) over `backend/` takes 20+ minutes and burns a +huge number of tokens on output. Don't do it, even to "double check" at the end. + +Instead, select the tests affected by the change and run only those: + +```bash +cd backend +uv run pytest tests/path/to/test_file.py # one file +uv run pytest tests/path/to/test_file.py::test_name # one test +uv run pytest tests/handler/ tests/endpoints/ # affected areas +uv run pytest -k "scan or queue" # by name pattern +``` + +Pick the targets from the diff: the test file mirroring each changed module +(`backend//x.py` → `backend/tests//test_x.py`), plus the tests of the +callers of anything whose signature or behavior you changed (`grep` for the symbol). + +CI runs the whole suite on the PR (`pytest.yml`, MariaDB + PostgreSQL). That is the +place for full-suite coverage; local runs stay scoped. diff --git a/CLAUDE.md b/CLAUDE.md index 4b69c2d4a..4449ac0a3 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -82,7 +82,7 @@ These live in `.claude/skills/` and carry the detailed rules. Invoke the one tha ```bash uv sync --all-extras --dev # install uv run main.py # run (migrations auto-apply) -uv run pytest [path/file] # test (subset) - or -vv for all +uv run pytest # test - affected files only, NEVER the whole suite uv run alembic revision --autogenerate -m "msg" # new migration (then HAND-REVIEW) uv run alembic upgrade head # apply migrations ```