mirror of https://github.com/databricks/cli.git
acc: Propagate user's UV_CACHE_DIR to tests (#2239)
There is a speed up in 0.5s but it is still 4.4s, so something else is slow there. Benchmarking bundle/templates/experimental-jobs-as-code: ``` # Without UV_CACHE_DIR ~/work/cli/acceptance/bundle/templates/experimental-jobs-as-code % hyperfine --warmup 2 'testme -count=1' Benchmark 1: testme -count=1 Time (mean ± σ): 4.950 s ± 0.079 s [User: 2.730 s, System: 8.524 s] Range (min … max): 4.838 s … 5.076 s 10 runs # With UV_CACHE_DIR ~/work/cli/acceptance/bundle/templates/experimental-jobs-as-code % hyperfine --warmup 2 'testme -count=1' Benchmark 1: testme -count=1 Time (mean ± σ): 4.410 s ± 0.049 s [User: 2.669 s, System: 8.710 s] Range (min … max): 4.324 s … 4.467 s 10 runs ```
This commit is contained in:
parent
65fbbd9a7c
commit
52bf7e388a
|
@ -100,6 +100,10 @@ func testAccept(t *testing.T, InprocessMode bool, singleTest string) int {
|
||||||
// Prevent CLI from downloading terraform in each test:
|
// Prevent CLI from downloading terraform in each test:
|
||||||
t.Setenv("DATABRICKS_TF_EXEC_PATH", tempHomeDir)
|
t.Setenv("DATABRICKS_TF_EXEC_PATH", tempHomeDir)
|
||||||
|
|
||||||
|
// Make use of uv cache; since we set HomeEnvVar to temporary directory, it is not picked up automatically
|
||||||
|
uvCache := getUVDefaultCacheDir(t)
|
||||||
|
t.Setenv("UV_CACHE_DIR", uvCache)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
cloudEnv := os.Getenv("CLOUD_ENV")
|
cloudEnv := os.Getenv("CLOUD_ENV")
|
||||||
|
|
||||||
|
@ -486,3 +490,16 @@ func ListDir(t *testing.T, src string) []string {
|
||||||
}
|
}
|
||||||
return files
|
return files
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getUVDefaultCacheDir(t *testing.T) string {
|
||||||
|
// According to uv docs https://docs.astral.sh/uv/concepts/cache/#caching-in-continuous-integration
|
||||||
|
// the default cache directory is
|
||||||
|
// "A system-appropriate cache directory, e.g., $XDG_CACHE_HOME/uv or $HOME/.cache/uv on Unix and %LOCALAPPDATA%\uv\cache on Windows"
|
||||||
|
cacheDir, err := os.UserCacheDir()
|
||||||
|
require.NoError(t, err)
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
return cacheDir + "\\uv\\cache"
|
||||||
|
} else {
|
||||||
|
return cacheDir + "/uv"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ trace $CLI bundle init experimental-jobs-as-code --config-file ./input.json --ou
|
||||||
cd output/my_jobs_as_code
|
cd output/my_jobs_as_code
|
||||||
|
|
||||||
# silence uv output because it's non-deterministic
|
# silence uv output because it's non-deterministic
|
||||||
uv sync 2> /dev/null
|
uv sync -q
|
||||||
|
|
||||||
# remove version constraint because it always creates a warning on dev builds
|
# remove version constraint because it always creates a warning on dev builds
|
||||||
cat databricks.yml | grep -v databricks_cli_version > databricks.yml.new
|
cat databricks.yml | grep -v databricks_cli_version > databricks.yml.new
|
||||||
|
|
Loading…
Reference in New Issue