Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,21 @@ jobs:
with:
cache-key: test-${{ matrix.deployment }}

# Make origin/main available with enough history for `git diff --merge-base
# origin/main`, which the acceptance subset selector uses to always run the
# tests this PR adds/changes on the windows/macOS cells. actions/checkout does
# a shallow single-ref clone by default, so origin/main is otherwise absent and
# the diff fails, silently disabling change detection. This must run AFTER
# setup-build-environment, whose own checkout would re-shallow the repo. Only
# PRs subset tests, so the fetch is unnecessary elsewhere.
- name: Fetch origin/main for change detection
if: ${{ github.event_name == 'pull_request' }}
run: |
git fetch --no-tags origin +refs/heads/main:refs/remotes/origin/main
if [ "$(git rev-parse --is-shallow-repository)" = "true" ]; then
git fetch --no-tags --unshallow origin
fi

- name: Run tests
env:
ENVFILTER: DATABRICKS_BUNDLE_ENGINE=${{ matrix.deployment }}
Expand Down
2 changes: 1 addition & 1 deletion acceptance/acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ func testAccept(t *testing.T, inprocessMode bool, singleTest string) int {
// subset selector keep these tests, so detect them at most once here.
var changedTests map[string][]string
if skipLocalWithChanged || subset.enabled {
changedTests = selectChangedLocalTests(testDirsSet)
changedTests = selectChangedLocalTests(t, testDirsSet)
}
subset.changed = changedTests

Expand Down
19 changes: 17 additions & 2 deletions acceptance/skiplocal_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package acceptance_test

import (
"errors"
"os/exec"
"path/filepath"
"slices"
"strings"
"testing"
)

// DATABRICKS_TEST_SKIPLOCAL controls skipping of Local acceptance tests.
Expand Down Expand Up @@ -61,8 +63,21 @@ func testDirForFile(repoRelPath string, testDirs map[string]bool) string {
// committed. The three-dot form origin/main...HEAD only covers committed
// changes and misses unstaged edits, which breaks the "touch a config, run
// the test" local dev workflow (same reason lintdiff.py uses --merge-base).
func selectChangedLocalTests(testDirs map[string]bool) map[string][]string {
out, _ := exec.Command("git", "diff", "--name-status", "--merge-base", "-M", "origin/main").Output()
func selectChangedLocalTests(t *testing.T, testDirs map[string]bool) map[string][]string {
out, err := exec.Command("git", "diff", "--name-status", "--merge-base", "-M", "origin/main").Output()
if err != nil {
// A failed diff (most commonly a missing origin/main in a shallow CI
// checkout) disables change detection, so newly added tests fall back to
// the seeded subset and may not run. Log loudly but continue: failing the
// test here breaks integration runs whose checkout has no origin/main. The
// push.yml PR cells fetch full history so origin/main resolves there.
stderr := ""
if exitErr, ok := errors.AsType[*exec.ExitError](err); ok {
stderr = strings.TrimSpace(string(exitErr.Stderr))
}
t.Logf("WARNING: change detection disabled: git diff --merge-base origin/main failed: %v\n%s", err, stderr)
return nil
}
diff := strings.TrimSpace(string(out))

// result accumulates dirs with their filters; added tracks brand-new dirs.
Expand Down
Loading