Repository navigation
pre-commit registers only the commit's own tests #22056
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5f04fda
ab47600
cc72cde
5437983
00bbfa2
e571cad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -26,10 +26,24 @@ cd "$REPO_ROOT" | |||||
|
|
||||||
| # Register new Python tests that a workflow already runs, so adding a test and | ||||||
| # its ci-guards.yml step is all a commit needs. Best effort: CI still validates. | ||||||
| # Only this commit's tests: the ones it adds, and the ones its workflow changes | ||||||
| # name. Registering every unregistered test the base carries wrote the same | ||||||
| # entries into every pull request, which then conflicted (#21946). | ||||||
| REGISTRY="tests/test-execution.toml" | ||||||
| if git diff --cached --name-only --diff-filter=ACMRT | grep -Eq '^(tests/test_[^/]+\.py|\.github/workflows/.+)$' \ | ||||||
| && git diff --quiet -- "$REGISTRY"; then | ||||||
| "$PYTHON3_BIN" -I "$REGISTRY_VALIDATOR" --repo-root "$REPO_ROOT" --write >/dev/null 2>&1 || true | ||||||
| OWN_TESTS=() | ||||||
| while IFS= read -r test_path; do | ||||||
| [[ -n "$test_path" ]] && OWN_TESTS+=(--only "$test_path") | ||||||
| done < <( | ||||||
| { | ||||||
| git diff --cached --name-only --diff-filter=A -- 'tests/test_*.py' | ||||||
| git diff --cached -U0 -- .github/workflows | grep -E '^\+' | grep -oE 'tests/test_[A-Za-z0-9_]+\.py' || true | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The workflow matcher excludes supported test names containing Use the validator's
Suggested change
|
||||||
| } | sort -u | ||||||
| ) | ||||||
| if (( ${#OWN_TESTS[@]} > 0 )); then | ||||||
| "$PYTHON3_BIN" -I "$REGISTRY_VALIDATOR" --repo-root "$REPO_ROOT" --write "${OWN_TESTS[@]}" >/dev/null 2>&1 || true | ||||||
| fi | ||||||
| if ! git diff --quiet -- "$REGISTRY"; then | ||||||
| git add "$REGISTRY" | ||||||
| echo "pre-commit: registered new tests in $REGISTRY" | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.