Repository navigation
#890 feat: route the commit hook's unit tests by the staged paths - #892
Merged
Merged
Conversation
…reak The unit tier was ~12 min a commit, 87% of it dbt-duckdb fixture builds (profile on #890). `scripts/commit_tests.py` now picks the pytest the `pytest` hook runs from the staged set: - nothing staged (a manual run, CI) -> the whole unit tier; - docs/** or *.md only -> the test modules that name a doc (~25 s); - otherwise the unit tier without `dbt`, which a staged path adds back when it is in the dbt modules' import closure, under src/core/ingestion/ or tests/core/ingestion/, or is pyproject.toml, uv.lock or tests/conftest.py. pre-ship.sh still runs the whole tier before every push. `pytest.mark.dbt` marks every test that builds; an autouse guard in the root conftest fails an unmarked one, so none slips into the fast path. The mapping fixture's builds share one duckdb path and target, so dbt partial-parses after the first (~15% off the dbt tier); each keeps its own store, because the staging views read its paths (test_build_cache). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/plans/2026-11-26-commit-hook-test-routing-design.md records the profile, the routed hook, the dbt marker and partial parse, and what is out of scope (the integration profile, dbt execution speed, xdist on this host). docs/TESTING.md § Which tests run when: integration is opt-in (the whole marker only on request; by default the modules mirroring the touched code), the hook's routing, and the dbt marker. The mapping and applier tier sections move whole to docs/TESTING_INGESTION.md for the budget (#444 rule); TESTING.md 10,045 -> ~9,400 tokens. AGENTS.md's TESTING.md index line names the integration rule at the same length. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #890. The issue stays open for the
-m integrationprofile, deferred so it wouldn't share the test DB with the parallel #882 work.Why
The pre-commit unit hook ran the whole unit tier on every commit, docs-only included: 707–805 s here. The profile (posted on #890) shows 87% of that is dbt-duckdb fixture builds. The other ~3,600 tests take about 86 s.
What
scripts/commit_tests.py, thepytesthook's new entry). It reads the staged set (git diff --cached --no-renames -z, deletions included):--all-files) → the whole unit tier;docs/**or*.md→ only the test modules that name a doc (text match, plus a one-hop helper import);dbt, plusdbtwhen a staged path is in the unit dbt modules' import closure, undersrc/core/ingestion/ortests/core/ingestion/, or ispyproject.toml,uv.lockortests/conftest.py.scripts/pre-ship.shstill runs everything before a push.pytest.mark.dbton every test that builds. An autouse guard in the root conftest swaps the mapping package'sdbtRunnerfor one that fails any unmarked test (tests/test_dbt_marker_guard.py).test_build_cache.pypins that a later build doesn't change an earlier build's views.docs/TESTING_INGESTION.md(TESTING.md was over budget at 10,045 tokens and is now ~9,400).docs/plans/2026-11-26-commit-hook-test-routing-design.md.No version bump: dev tooling and tests only.
Measured (this VM, 2 vCPUs, other worktrees' suites often running alongside)
The docs-only commit isn't yet "seconds". Its remaining ~70 s is the other
always_runhooks:pytest-vendored15 s,bats-vendored16 s,vitest16 s andbats23 s.tests/test_vendored_subset.pypins those asalways_runfor the #755 refresh knob, so routing them belongs in a follow-up.Verification
test_commit_tests.py(module missing),test_dbt_marker_guard.py(DID NOT RAISE, marker unregistered), andtest_build_cache.py(no shared target).tests/scripts/test_curation_overlay_seam.pyandtests/core/ingestion/mapping/test_real_snapshot.py, the integration modules whose marker changed. The full-m integrationsuite did not run.scripts/pre-ship.sh: the vendored gate passed (3,996 unit tests, 334 vitest). The a11y step ran, becausetests/conftest.pyis in the admin scope list. The first run's browser tier failed with a deadlock and FK violations in its truncate-and-seed, the shared test DB in use elsewhere. A re-run with nothing else on the DB passed (lxml 203, browser 53).test_curation_overlay_seam: 1 passed.test_real_snapshot: 8 skipped by name (no landed store in a worktree).🤖 Generated with Claude Code