testsAndMisc/docs/superpowers/evidence/python-tests-minimal-deps-2026-08-23.json
Krzysztof kuhy Rudnicki e4b8ad0cfe Install only the test deps in Python tests CI: 79 packages -> 17
python-tests.yml runs pytest and nothing else, but installed the full
requirements.txt -- 79 packages, of which ~62 are linters, formatters and
type checkers that job never invokes. Installing them was the workflow's
slowest step: 49s, against 35s actually running the tests.

meta/requirements-test.txt holds the 17 that matter. Derived by static
import analysis over python_pkg/ and linux_configuration/tests/, then
VERIFIED rather than assumed -- a clean Python 3.11 venv with only this
list runs the whole suite:

  2174 passed, TOTAL 100.00%, 7138 stmts / 1748 branches, 0 missing

identical to the full-requirements run. Install of the subset: 6.2s.

The pytest-* entries are in the list even though nothing imports them:
randomly reorders tests, timeout enforces a limit, sugar changes
reporting and xdist provides -n. Dropping one changes how the suite runs.

Drift is gated, not left to discipline: a new requirements-test-sync hook
reuses check_requirements_sync.py's existing --requirements flag, so a
new third-party import fails at commit time rather than as a bare
ModuleNotFoundError in CI. The new file is also in both path filters.

pre-commit.yml keeps the full list -- it needs every formatter.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PJrqKERAo5QUeEHWS5Asgp
2026-08-23 16:29:24 +02:00

46 lines
2.6 KiB
JSON

{
"intent": "Stop the Python tests workflow installing ~62 linters and formatters it never invokes, by giving it a requirements file scoped to what the suite actually needs.",
"scope": [
"meta/requirements-test.txt (new)",
".github/workflows/python-tests.yml",
".pre-commit-config.yaml (new requirements-test-sync hook)",
"Non-goal: changing pre-commit.yml, which genuinely needs every formatter"
],
"changes": [
"Added meta/requirements-test.txt: 17 packages, down from 79. Derived by static import analysis over python_pkg/ and linux_configuration/tests/, then verified by running the suite against only that list.",
"python-tests.yml installs the subset, caches on it, and lists it in both path filters so a change to it triggers the workflow.",
"Added a requirements-test-sync pre-commit hook reusing check_requirements_sync.py's existing --requirements flag, so a new third-party import cannot silently break CI with a ModuleNotFoundError.",
"The pytest-* plugins are included deliberately: randomly, timeout, sugar and xdist change how the suite runs even though nothing imports them."
],
"verification": [
{
"command": "python3.11 venv + pip install -r meta/requirements-test.txt + full pytest run with coverage",
"result": "pass",
"evidence": "2174 passed, TOTAL 100.00%, 7138 statements / 1748 branches, 0 missing -- identical to the full-requirements run"
},
{
"command": "pip install -r meta/requirements-test.txt (timed)",
"result": "pass",
"evidence": "6.2s for 17 packages against a warm local cache; the full 79-package list took 49-55s on the CI runner"
},
{
"command": "python3 meta/scripts/check_requirements_sync.py --package python_pkg --requirements meta/requirements-test.txt",
"result": "pass",
"evidence": "exit 0 -- every third-party import in python_pkg is declared in the subset"
},
{
"command": "pre-commit run requirements-test-sync --all-files",
"result": "pass",
"evidence": "Passed"
}
],
"risks": [
"A new runtime import that is not added here would fail CI. Mitigated by the new hook, which gates on the same analysis and runs on every python_pkg .py change.",
"The subset can drift from the full list's version bounds. Both are >= ranges on the same packages, so a divergence surfaces as a resolver conflict rather than a silent mismatch."
],
"rollback": [
"Point the Install dependencies step and cache-dependency-path back at requirements.txt and delete the hook.",
"After rollback, confirm the install step returns to ~50s."
]
}