Add default regex for DEV_VERSION (#2241)

## Changes

- Replace development version with $DEV_VERSION
- Update experimental-jobs-as-code to make use of it.

## Tests
- Existing tests.
- Using this in https://github.com/databricks/cli/pull/2213
This commit is contained in:
Denis Bilenko 2025-01-27 15:34:53 +01:00 committed by GitHub
parent 52bf7e388a
commit 67d1413db5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 18 additions and 4 deletions

View File

@ -128,6 +128,7 @@ func testAccept(t *testing.T, InprocessMode bool, singleTest string) int {
testdiff.PrepareReplacementsUser(t, &repls, *user) testdiff.PrepareReplacementsUser(t, &repls, *user)
testdiff.PrepareReplacementsWorkspaceClient(t, &repls, workspaceClient) testdiff.PrepareReplacementsWorkspaceClient(t, &repls, workspaceClient)
testdiff.PrepareReplacementsUUID(t, &repls) testdiff.PrepareReplacementsUUID(t, &repls)
testdiff.PrepareReplacementsDevVersion(t, &repls)
testDirs := getTests(t) testDirs := getTests(t)
require.NotEmpty(t, testDirs) require.NotEmpty(t, testDirs)

View File

@ -10,6 +10,8 @@ Please refer to the README.md file for "getting started" instructions.
See also the documentation at https://docs.databricks.com/dev-tools/bundles/index.html. See also the documentation at https://docs.databricks.com/dev-tools/bundles/index.html.
>>> $CLI bundle validate -t dev --output json >>> $CLI bundle validate -t dev --output json
Warning: Ignoring Databricks CLI version constraint for development build. Required: >= 0.238.0, current: $DEV_VERSION
{ {
"jobs": { "jobs": {
"my_jobs_as_code_job": { "my_jobs_as_code_job": {

View File

@ -3,6 +3,7 @@
bundle: bundle:
name: my_jobs_as_code name: my_jobs_as_code
uuid: <UUID> uuid: <UUID>
databricks_cli_version: ">= 0.238.0"
experimental: experimental:
python: python:

View File

@ -5,10 +5,6 @@ cd output/my_jobs_as_code
# silence uv output because it's non-deterministic # silence uv output because it's non-deterministic
uv sync -q uv sync -q
# remove version constraint because it always creates a warning on dev builds
cat databricks.yml | grep -v databricks_cli_version > databricks.yml.new
mv databricks.yml.new databricks.yml
trace $CLI bundle validate -t dev --output json | jq ".resources" trace $CLI bundle validate -t dev --output json | jq ".resources"
rm -fr .venv resources/__pycache__ uv.lock my_jobs_as_code.egg-info rm -fr .venv resources/__pycache__ uv.lock my_jobs_as_code.egg-info

View File

@ -33,3 +33,7 @@ $TMPDIR/subdir/a/b/c
1234 1234
CUSTOM_NUMBER_REGEX CUSTOM_NUMBER_REGEX
123456 123456
=== Testing --version
>>> $CLI --version
Databricks CLI v$DEV_VERSION

View File

@ -24,3 +24,6 @@ printf "\n=== Custom regex can be specified in [[Repl]] section\n"
echo 1234 echo 1234
echo 12345 echo 12345
echo 123456 echo 123456
printf "\n=== Testing --version"
trace $CLI --version

View File

@ -23,6 +23,8 @@ var (
uuidRegex = regexp.MustCompile(`[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}`) uuidRegex = regexp.MustCompile(`[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}`)
numIdRegex = regexp.MustCompile(`[0-9]{3,}`) numIdRegex = regexp.MustCompile(`[0-9]{3,}`)
privatePathRegex = regexp.MustCompile(`(/tmp|/private)(/.*)/([a-zA-Z0-9]+)`) privatePathRegex = regexp.MustCompile(`(/tmp|/private)(/.*)/([a-zA-Z0-9]+)`)
// Version could v0.0.0-dev+21e1aacf518a or just v0.0.0-dev (the latter is currently the case on Windows)
devVersionRegex = regexp.MustCompile(`0\.0\.0-dev(\+[a-f0-9]{10,16})?`)
) )
type Replacement struct { type Replacement struct {
@ -211,3 +213,8 @@ func PrepareReplacementsTemporaryDirectory(t testutil.TestingT, r *ReplacementsC
t.Helper() t.Helper()
r.append(privatePathRegex, "/tmp/.../$3") r.append(privatePathRegex, "/tmp/.../$3")
} }
func PrepareReplacementsDevVersion(t testutil.TestingT, r *ReplacementsContext) {
t.Helper()
r.append(devVersionRegex, "$$DEV_VERSION")
}