Skip to content

Commit ce382bb

Browse files
authored
Fix bundle validate warning when sync patterns used with sync paths outside of bundle root (#7122)
## Changes Fix `bundle validate` warning that `sync.include` and `sync.exclude` patterns do not match any files when `sync.paths` includes a directory outside the bundle root. ## Why Fixes #7115 ## Tests Added an acceptance test <!-- If your PR needs to be included in the release notes for next release, add a changelog fragment: create .nextchanges/<section>/<name>.md with a one-line description (e.g. .nextchanges/cli/quickstart.md). See .nextchanges/README.md. -->
1 parent a1cf984 commit ce382bb

9 files changed

Lines changed: 59 additions & 1 deletion

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Fix `bundle validate` warning that `sync.include` and `sync.exclude` patterns do not match any files when `sync.paths` includes a directory outside the bundle root. ([#7122](https://github.com/databricks/cli/pull/7122))
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
bundle:
2+
name: test-bundle
3+
4+
sync:
5+
paths:
6+
- ../shared
7+
- .
8+
include:
9+
- ../shared/*.py
10+
exclude:
11+
- tests/**
12+
- missing/**
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def test_main():
2+
pass
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Cloud = false
2+
EnvMatrix.DMS = ["", "true"]
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
>>> [CLI] bundle validate
3+
Warning: Pattern app/missing/** does not match any files
4+
at sync.exclude[1]
5+
in databricks.yml:12:7
6+
7+
Name: test-bundle
8+
Target: default
9+
Workspace:
10+
User: [USERNAME]
11+
Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default
12+
13+
Found 1 warning
14+
15+
>>> [CLI] bundle validate -o json
16+
Warning: Pattern app/missing/** does not match any files
17+
at sync.exclude[1]
18+
in databricks.yml:12:7
19+
20+
{
21+
"exclude": [
22+
"app/tests/**",
23+
"app/missing/**"
24+
],
25+
"include": [
26+
"shared/*.py"
27+
],
28+
"paths": [
29+
"shared",
30+
"app"
31+
]
32+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# The sync root is the parent directory, so include/exclude patterns are rewritten
2+
# relative to it. Only missing/** should be reported as not matching any files.
3+
cd app
4+
trace $CLI bundle validate
5+
trace $CLI bundle validate -o json | jq '.sync'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print("shared")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Ignore = [".databricks"]

‎bundle/config/validate/validate_sync_patterns.go‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ func checkPatterns(ctx context.Context, patterns []string, path *structpath.Path
4646
// it means: do not include these files into result set
4747
p := strings.TrimPrefix(pattern, "!")
4848
errs.Go(func() error {
49-
fs, err := fileset.NewGlobSet(b.BundleRoot, []string{p})
49+
// SyncInferRoot rewrites patterns to be relative to the sync root,
50+
// which can be an ancestor of the bundle root.
51+
fs, err := fileset.NewGlobSet(b.SyncRoot, []string{p})
5052
if err != nil {
5153
return err
5254
}

0 commit comments

Comments
 (0)