fix(ci): Execute newly added or modified scheduled_only tests in pre-submits#4339
Open
mesakhcienet wants to merge 1 commit into
Open
fix(ci): Execute newly added or modified scheduled_only tests in pre-submits#4339mesakhcienet wants to merge 1 commit into
scheduled_only tests in pre-submits#4339mesakhcienet wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
81f5793 to
9e07cb9
Compare
xibinliu
reviewed
Jul 2, 2026
shralex
reviewed
Jul 3, 2026
Collaborator
Author
|
Thanks for the detailed review, @shralex @xibinliu — pushed an update addressing the feedback. summary of what changed: Applied as suggested
Adjusted with a small deviation (details in the threads)
Verification
Feel free to suggest changes. Thank you! |
14d996d to
71b8779
Compare
shralex
approved these changes
Jul 3, 2026
xibinliu
approved these changes
Jul 3, 2026
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.
Description
This change makes the pre-submit execute the
scheduled_onlytests that a PR introduces or modifies, so each is verified at least once before merge, while unrelatedscheduled_onlytests remain nightly-only (unchanged).How it works
tests/conftest.pycomputes the set of tests a PR adds or modifies — viagit diff --unified=0 origin/<base>...HEAD— and dynamically applies a newnewly_addedmarker to the matching collected tests.<marker> and not scheduled_onlyto<marker> and (not scheduled_only or newly_added). Scheduled (nightly) runs are untouched and continue to run everything.Detection details / robustness
tests/utils/newly_added_detection.py(parse_changed_testsis pure;get_changed_testswraps git). Keeping it out ofconftest.pylets it be tested without importing absl/pytest/jax.(file_path, test_name)— so identically named tests in different files (e.g.test_basic_callappears in 6 files) do not cross-contaminate and pull unrelatedscheduled_onlytests into pre-submit..gitattributessets*.py diff=pythonsogit diffhunk headers expose the enclosingdef test_*for edits inside class methods (the suite is overwhelmingly class-based). This enables detection of modified tests, not just brand-new ones.fetch-depth: 0so the three-dotorigin/main...HEADdiff has a reachable merge-base (otherwise the shallow clone forces a less precise fallback).GITHUB_BASE_REF(thenmain), so PRs targeting a non-mainbranch are handled.Files changed
tests/conftest.pynewly_added(file-qualified match)tests/utils/newly_added_detection.py(new)tests/unit/newly_added_detection_test.py(new).github/workflows/run_tests_against_package.ymlfetch-depth: 0.github/workflows/run_pathways_tests.yml.gitattributes(new)*.py diff=pythonpytest.ininewly_addedmarkerShortcomings / future work
maxtext_installed=true(the runner doescd /deps, which is not a git work tree). Not on the current PR pre-submit path, but worth noting.run_pathways_tests.ymlchecks out via a hardcodedgit clone https://github.com/google/maxtext.git, which does not resolve fork build SHAs (pre-existing, out of scope here).Tests
New unit tests in
tests/unit/newly_added_detection_test.py(markedcpu_only) cover the diff parser across: new top-level function, new class method, modified method detected via the hunk header, cross-file name-collision isolation, non-test /src/changes ignored, and multi-file diffs.All commands run locally against the repo
.venv(Python 3.12).1. Unit tests
2. Lint gate (same hooks as
code_quality.yml)3. End-to-end through the real
conftest.py— a temporaryscheduled_onlyprobe test committed on the branch, collected through the actualtests/conftest.py:This confirms the full chain:
git diff→ file-qualified parse →newly_addedmarker → survives-mselection → thescheduled_onlytest runs. The.gitattributeschange was separately verified to makegit diff --unified=0emit@@ ... @@ def test_column(...)headers for edits inside class methods (instead of the enclosingclass ...line).4. CI: the two modified workflows exercise this change on the actual TPU / GPU / CPU and Pathways pre-submit runners in this PR.
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.