Skip to content

acc: make changed-test detection reusable#5880

Open
pietern wants to merge 4 commits into
mainfrom
extract-changed-tests
Open

acc: make changed-test detection reusable#5880
pietern wants to merge 4 commits into
mainfrom
extract-changed-tests

Conversation

@pietern

@pietern pietern commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Extract the changed-test detection added in #5844 (DATABRICKS_TEST_SKIPLOCAL=withchanged) into acceptance/internal so it is generic for any functionality that wants to inspect which acceptance tests a diff touches, and harden it to catch cross-directory dependencies it previously missed.

  • internal.ChangedTests(baseRef, headRef, testDirs) runs the git diff; an empty headRef diffs against the working tree, a non-empty one diffs between two refs (checkout-independent). internal.ParseChangedTests is a pure function over git diff --name-status text, unit-tested with literal diff strings.
  • selectChangedLocalTests keeps only the skiplocal policy (added-first ordering, maxChangedLocalTests cap) and delegates detection.
  • Ignore deleted invariant configs: a deletion no longer adds an INPUT_CONFIG= filter for a variant that is gone.
  • Keep ChangedTest.Added sticky across diff lines so a newly-added dir stays added regardless of line order.
  • Detect cross-directory dependencies: a parent script.prepare/script.cleanup/test.toml re-enables its whole subtree; a change under acceptance/bin/ re-enables the whole suite; any other unowned file (a sourced _script, a fixture read via $TESTDIR/..) re-enables its subtree.

This pull request and its description were written by Isaac.

Move the "which acceptance test dirs did this branch's diff affect?" logic out
of the skiplocal_test.go helper and into acceptance/internal, so both the
existing DATABRICKS_TEST_SKIPLOCAL=withchanged path and future callers can share
one detection function.

- internal.ChangedTests(baseRef, headRef, testDirs) runs the git diff and returns
  a map of test dir -> ChangedTest{Added, VariantFilters}. An empty headRef diffs
  against the working tree (preserving withchanged's local-dev behavior of
  re-enabling uncommitted edits); a non-empty headRef diffs between two refs,
  independent of the checkout, for CI and replaying historical PRs.
- internal.ParseChangedTests is split out as a pure function over git diff text,
  unit-tested with literal diff strings (added dir, rename, nested dir, invariant
  config INPUT_CONFIG= expansion, files outside acceptance/).
- selectChangedLocalTests keeps only the skiplocal policy (added-first ordering
  and the maxChangedLocalTests cap) and delegates detection to ChangedTests.

No behavior change: the withchanged path produces the same selection as before.

Co-authored-by: Isaac
@pietern pietern temporarily deployed to test-trigger-is July 9, 2026 13:29 — with GitHub Actions Inactive
@pietern pietern temporarily deployed to test-trigger-is July 9, 2026 13:29 — with GitHub Actions Inactive
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Waiting for approval

Based on git history, these people are best suited to review:

  • @denik -- recent work in acceptance/internal/, acceptance/

Eligible reviewers: @andrewnester, @anton-107, @janniklasrose, @renaudhartert-db, @shreyas-goenka, @simonfaltum

Suggestions based on git history. See OWNERS for ownership rules.

A deleted invariant config (D status) previously added an INPUT_CONFIG= filter
for a variant that no longer exists, so the invariant subdirs were re-enabled
for a config that can never match. Skip deletions in the invariant-config branch.

Also add deletion coverage to the parser tests: a deleted file in a still-present
test dir re-enables that dir; a deleted whole test dir (script gone) is ignored;
a deleted config is ignored; and a deleted config alongside a modified one keeps
only the modified config's filter.

Co-authored-by: Isaac
@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Integration test report

Commit: dd8ba49

Run: 29027184389

Env 🔄​flaky 💚​RECOVERED 🙈​SKIP ✅​pass 🙈​skip Time
🔄​ aws linux 4 4 4 226 1077 5:57
💚​ aws windows 4 4 232 1075 6:57
💚​ aws-ucws linux 4 4 314 995 5:51
💚​ aws-ucws windows 4 4 316 993 7:24
💚​ azure linux 4 4 230 1076 5:08
💚​ azure windows 4 4 232 1074 6:56
💚​ azure-ucws linux 4 4 316 992 6:00
💚​ azure-ucws windows 4 4 318 990 6:52
💚​ gcp linux 4 4 229 1078 4:59
💚​ gcp windows 4 4 231 1076 7:00
12 interesting tests: 4 RECOVERED, 4 SKIP, 4 flaky
Test Name aws linux aws windows aws-ucws linux aws-ucws windows azure linux azure windows azure-ucws linux azure-ucws windows gcp linux gcp windows
💚​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
🙈​ TestAccept/bundle/invariant/no_drift 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_endpoints/drift/recreated_same_name 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_indexes/recreate/embedding_dimension 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/ssh/connection 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🔄​ TestSecretsPutSecretBytesValue 🔄​f ✅​p 🙈​s 🙈​s ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p
🔄​ TestSecretsPutSecretStringValue 🔄​f ✅​p 🙈​s 🙈​s ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p
🔄​ TestFilerWorkspaceNotebook 🔄​f ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p
🔄​ TestFilerWorkspaceNotebook/sqlNb.sql 🔄​f ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p
💚​ TestFetchRepositoryInfoAPI_FromRepo 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
💚​ TestFetchRepositoryInfoAPI_FromRepo/root 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
💚​ TestFetchRepositoryInfoAPI_FromRepo/subdir 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
Top 10 slowest tests (at least 2 minutes):
duration env testname
6:03 gcp windows TestAccept
5:55 aws-ucws windows TestAccept
5:54 aws windows TestAccept
5:53 azure windows TestAccept
5:53 azure-ucws windows TestAccept
2:57 azure linux TestAccept
2:54 aws-ucws linux TestAccept
2:53 aws linux TestAccept
2:52 gcp linux TestAccept
2:48 azure-ucws linux TestAccept

ParseChangedTests overwrote the whole ChangedTest for every changed file in a
dir, so a later diff line (e.g. test.toml) reset Added to false after an added
script had set it true. Since git diff lines for a dir arrive in arbitrary
order, a brand-new dir could end up Added=false, breaking the added-first
ordering that selectChangedLocalTests relies on under maxChangedLocalTests.

Preserve the existing entry when a direct change re-enables all variants: clear
VariantFilters but OR in Added. This restores parity with the pre-refactor
algorithm's separate added map. Add tests covering both diff-line orders and the
added-subdir-overrides-config-filter interaction.

Co-authored-by: Isaac
@pietern pietern changed the title acc: extract changed-test detection into internal.ChangedTests acc: make changed-test detection reusable Jul 9, 2026
@pietern pietern temporarily deployed to test-trigger-is July 9, 2026 14:17 — with GitHub Actions Inactive
@pietern pietern temporarily deployed to test-trigger-is July 9, 2026 14:17 — with GitHub Actions Inactive
The mapper only saw a changed file's own innermost test dir, so it missed
changes to files that affect tests in other dirs:

- A parent script.prepare/script.cleanup/test.toml is concatenated or inherited
  into every descendant test, so it now re-enables that whole subtree (works
  even when its own dir is also a test dir with nested test dirs under it).
- A helper under acceptance/bin/ is on PATH for every test, so a change there
  re-enables the whole suite.
- Any other changed file that no test dir owns (a sourced _script, a fixture
  read via $TESTDIR/..) re-enables every test dir in its subtree. This
  over-selects but errs toward running more tests, never skipping a real one.
  A stray file at the acceptance root maps to nothing and is ignored.

Verified against real commits: a root script.prepare change (49ea8ae) now
re-enables every test dir; earlier resource/config PRs are unchanged.

Co-authored-by: Isaac
@pietern pietern temporarily deployed to test-trigger-is July 9, 2026 14:52 — with GitHub Actions Inactive
@pietern pietern temporarily deployed to test-trigger-is July 9, 2026 14:52 — with GitHub Actions Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants