Repository navigation
pr_gates: affected gate -- run the test files a branch can break, importers included (#6733) - #6736
Merged
Merged
Conversation
…mporters included (#6733) tests/tools/affected_tests.py selects every test file whose imports reach a changed .py file (an ast scan of tests/ and gitgalaxy/: gitgalaxy.* imports, bare tests/tools and harness imports, strings naming a .py tool), the readers of changed docs (docs_read_by_tests.txt) and the .py files that name any other changed file (a workflow, a case's data, a runtime source), then runs them nearest first within a 300 s budget (.test_durations) and names what it leaves to CI. In --fast, so churn's precheck runs it. Replayed on 30 churn collateral-break fix runs of 10-19..25: 20 of the 22 culprit tests the fix reports name were in the within-budget selection, 1 over budget, 1 missed (a glob over every case); run on #6561 and #6495's broken heads it fails on the culprit test. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…3813; test_source_reads) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # tests/tools/pr_gates.py
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.
Closes #6733.
Why. A PR breaking other existing tests is the send-back cause that jumps with PR size. In the churn fix runs from 10-18 to 10-26 it went from 1.2 per 100 PRs at 1-2 hand-written files to 17.7 at 5. A PR's own tests failing stayed flat at 2-5. Workers test what they wrote, and CI finds the rest one push later.
What. New
tests/tools/affected_tests.pyand anaffectedgate inpr_gates.py, also in--fast, so churn's precheck runs it.Selection:
astimport graph overtests/andgitgalaxy/(about 6 s):gitgalaxy.*imports (relative ones too), bare imports oftests/toolsmodules and per-directory harnesses, and string constants naming a.pytool (subprocess runs)docs_read_by_tests.txt.pyfiles that name any other changed file: a workflow by its unique file name, a case'scase.json/seed.sqlby the case directory, a runtime's.java/.csourceconftest.pyselects the tests under itRunning: nearest first (distance 0 = a test the branch changed, 1 = a direct importer, ...), then cheapest by
.test_durations, within--budget 300s. Whatever is left is named as "left to CI", never skipped silently.--listprints the selection without running anything.Replay on the 30 code-collateral churn fix runs of 10-19..25. A culprit is a test file that the fix commit changed and the fix run's report names. Of 22 culprits, 20 were in the within-budget selection, 1 was selected but over budget, and 1 was missed: #6101's
test_cbsa_generated_siblings.pyglobs every case directory, so no static scan can see it.I ran the gate itself on two broken heads:
65df10381fails ontest_sweep_plan.py::test_a_pull_request_or_push_ignores_cobol_mainframe_and_nothing_else_doesde4324b9afails ontest_pipeline_pins.py::test_our_own_pipelines_are_clean[.github/workflows/full-suite-gate.yml]Those are the tests their fixes changed, and the culprits pass on the fixed heads. (The replay copied the tool in as an untracked file, which made
docs_read_by_tests.txtlook stale there; that check aside, both fixed heads are green.)It also caught its own branch. A first draft held the literals
docs/and.claude/, which made the classifier think this tool reads every doc. The gate's first run on this branch failed 10 classifier and plan tests. They're fixed here, anddocs_read_by_tests.txtgains only the true.test_durationsreader.Checks:
test_affected_tests.py(9 tests).pr_gates --only lint audits affectedpasses (affected: 219 s on this branch). Placed besidegoldenso it doesn't touch #6734'sderivedentry.Related: #6731 / #6734 (stale derived files), #6735 (main-wide durations fix).
🤖 Generated with Claude Code