-
Notifications
You must be signed in to change notification settings - Fork 178
Add databricks version --check to check for available CLI updates
#5469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
45ff3e7
Add `databricks version --check` to check for CLI updates
simonfaltum 68ed2a4
Add NEXT_CHANGELOG entry for version --check
simonfaltum c6abc0e
Fail gently when `version --check` can't reach GitHub
simonfaltum b2cb055
Merge remote-tracking branch 'origin/main' into simonfaltum/v-check-m…
simonfaltum 790f989
Merge remote-tracking branch 'origin/main' into simonfaltum/version-u…
simonfaltum bd82457
Pin the GitHub API version on the release lookup
simonfaltum b10e558
Fold the update check into the version command itself
simonfaltum 8ed809b
Keep bare version lightweight; put the check behind --check only
simonfaltum 8273649
Merge branch 'main' into simonfaltum/version-update-check
simonfaltum 675ab6e
Merge branch 'main' into simonfaltum/version-update-check
simonfaltum File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
|
|
||
| === version stays lightweight | ||
|
|
||
| >>> [CLI] version | ||
| Databricks CLI v[DEV_VERSION] | ||
|
|
||
| === version --check | ||
|
|
||
| >>> [CLI] version --check | ||
| Databricks CLI v[DEV_VERSION] | ||
| This is a development build; skipping the update check. | ||
|
|
||
| === version --check --output json | ||
|
|
||
| >>> [CLI] version --check --output json | ||
| { | ||
| "current_version": "[DEV_VERSION]", | ||
| "update_available": false, | ||
| "development_build": true | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| title "version stays lightweight\n" | ||
| trace $CLI version | ||
|
|
||
| # The acceptance binary is a development build, so the check short-circuits | ||
| # without contacting GitHub. This exercises command wiring and output rendering. | ||
| title "version --check\n" | ||
| trace $CLI version --check | ||
|
|
||
| title "version --check --output json\n" | ||
| trace $CLI version --check --output json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # The update check is not bundle-aware; run it once instead of per-engine. | ||
| [EnvMatrix] | ||
| DATABRICKS_BUNDLE_ENGINE = [] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| package version | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/databricks/cli/libs/cmdio" | ||
| "github.com/databricks/cli/libs/versioncheck" | ||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestUpdateCheckTemplate(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| result versioncheck.Result | ||
| want string | ||
| }{ | ||
| { | ||
| name: "update available with upgrade command", | ||
| result: versioncheck.Result{ | ||
| CurrentVersion: "0.240.0", | ||
| LatestVersion: "0.245.0", | ||
| UpdateAvailable: true, | ||
| InstallMethod: versioncheck.InstallHomebrew, | ||
| UpgradeCommand: "brew upgrade databricks", | ||
| }, | ||
| want: `Databricks CLI v0.240.0 | ||
| A new version is available: 0.245.0 | ||
| To upgrade, run: | ||
| brew upgrade databricks | ||
| `, | ||
| }, | ||
| { | ||
| name: "update available without known install method", | ||
| result: versioncheck.Result{ | ||
| CurrentVersion: "0.240.0", | ||
| LatestVersion: "0.245.0", | ||
| UpdateAvailable: true, | ||
| InstallMethod: versioncheck.InstallUnknown, | ||
| }, | ||
| want: `Databricks CLI v0.240.0 | ||
| A new version is available: 0.245.0 | ||
| Download the latest release: https://github.com/databricks/cli/releases | ||
| `, | ||
| }, | ||
| { | ||
| name: "up to date", | ||
| result: versioncheck.Result{ | ||
| CurrentVersion: "0.245.0", | ||
| LatestVersion: "0.245.0", | ||
| UpdateAvailable: false, | ||
| }, | ||
| want: `Databricks CLI v0.245.0 | ||
| You're on the latest version. | ||
| `, | ||
| }, | ||
| { | ||
| name: "development build", | ||
| result: versioncheck.Result{ | ||
| CurrentVersion: "0.0.0-dev+abc123", | ||
| DevelopmentBuild: true, | ||
| }, | ||
| want: `Databricks CLI v0.0.0-dev+abc123 | ||
| This is a development build; skipping the update check. | ||
| `, | ||
| }, | ||
| { | ||
| name: "check failed", | ||
| result: versioncheck.Result{ | ||
| CurrentVersion: "0.240.0", | ||
| CheckFailed: true, | ||
| }, | ||
| want: `Databricks CLI v0.240.0 | ||
| Could not reach GitHub to check for a newer version. See https://github.com/databricks/cli/releases for the latest release. | ||
| `, | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| ctx, out := cmdio.NewTestContextWithStdout(t.Context()) | ||
| err := cmdio.RenderWithTemplate(ctx, tt.result, "", updateCheckTemplate) | ||
| require.NoError(t, err) | ||
| assert.Equal(t, tt.want, out.String()) | ||
| }) | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been using
[]as well but now realize that it is better to keep["direct"]to avoid running these both in terraform and direct variant on CI.