-
Notifications
You must be signed in to change notification settings - Fork 26
feat(deploy): 'deploy` command suggests 'run' command when no deploy script found #330
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
Open
srtaalej
wants to merge
10
commits into
main
Choose a base branch
from
ale-deploy-cmd-teach-run
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
71fdf86
feat(deploy): improve error message when no deploy script found
srtaalej d3b7256
Update cmd/platform/deploy.go
srtaalej d1165b7
Merge branch 'main' into ale-deploy-cmd-teach-run
srtaalej 1f7430a
format deploy.go
srtaalej 40b65e3
test: update test to expect correct docs url
srtaalej d4842f4
Merge branch 'main' into ale-deploy-cmd-teach-run
mwbrooks 9084770
adjust print format to highlight cmd
srtaalej e2e46ec
tests: add errormissingdeployhook test to table test
srtaalej c93ada7
tests: add test case to deploy table test
srtaalej a9c3e29
tests: fix deploy table tests
srtaalej 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
Some comments aren't visible on the classic Files Changed page.
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
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 | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -111,12 +111,14 @@ func TestDeployCommand(t *testing.T) { | |||||||||||||||||||
|
|
||||||||||||||||||||
| func TestDeployCommand_HasValidDeploymentMethod(t *testing.T) { | ||||||||||||||||||||
| tests := map[string]struct { | ||||||||||||||||||||
| app types.App | ||||||||||||||||||||
| manifest types.SlackYaml | ||||||||||||||||||||
| manifestError error | ||||||||||||||||||||
| manifestSource config.ManifestSource | ||||||||||||||||||||
| deployScript string | ||||||||||||||||||||
| expectedError error | ||||||||||||||||||||
| app types.App | ||||||||||||||||||||
| manifest types.SlackYaml | ||||||||||||||||||||
| manifestError error | ||||||||||||||||||||
| manifestSource config.ManifestSource | ||||||||||||||||||||
| deployScript string | ||||||||||||||||||||
| expectedError error | ||||||||||||||||||||
| expectedMessage string | ||||||||||||||||||||
| expectedRemediation []string | ||||||||||||||||||||
| }{ | ||||||||||||||||||||
| "fails when no manifest exists": { | ||||||||||||||||||||
| manifestError: slackerror.New(slackerror.ErrInvalidManifest), | ||||||||||||||||||||
|
|
@@ -142,8 +144,10 @@ func TestDeployCommand_HasValidDeploymentMethod(t *testing.T) { | |||||||||||||||||||
| deployScript: "sleep 4", | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| "fails if no deploy hook is provided": { | ||||||||||||||||||||
| manifestSource: config.ManifestSourceLocal, | ||||||||||||||||||||
| expectedError: slackerror.New(slackerror.ErrSDKHookNotFound), | ||||||||||||||||||||
| manifestSource: config.ManifestSourceLocal, | ||||||||||||||||||||
| expectedError: slackerror.New(slackerror.ErrSDKHookNotFound), | ||||||||||||||||||||
| expectedMessage: "No deploy script found", | ||||||||||||||||||||
| expectedRemediation: []string{"https://docs.slack.dev/tools/slack-cli/reference/hooks/#deploy", "run"}, | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| "succeeds if the app exists and the manifest source is remote": { | ||||||||||||||||||||
| app: types.App{ | ||||||||||||||||||||
|
|
@@ -183,11 +187,14 @@ func TestDeployCommand_HasValidDeploymentMethod(t *testing.T) { | |||||||||||||||||||
| err := hasValidDeploymentMethod(ctx, clients, app, types.SlackAuth{}) | ||||||||||||||||||||
| if tc.expectedError != nil { | ||||||||||||||||||||
| require.Error(t, err) | ||||||||||||||||||||
| assert.Equal( | ||||||||||||||||||||
| t, | ||||||||||||||||||||
| slackerror.ToSlackError(tc.expectedError).Code, | ||||||||||||||||||||
| slackerror.ToSlackError(err).Code, | ||||||||||||||||||||
| ) | ||||||||||||||||||||
| slackErr := slackerror.ToSlackError(err) | ||||||||||||||||||||
| assert.Equal(t, slackerror.ToSlackError(tc.expectedError).Code, slackErr.Code) | ||||||||||||||||||||
| if tc.expectedMessage != "" { | ||||||||||||||||||||
| assert.Contains(t, slackErr.Message, tc.expectedMessage) | ||||||||||||||||||||
| } | ||||||||||||||||||||
| for _, r := range tc.expectedRemediation { | ||||||||||||||||||||
| assert.Contains(t, slackErr.Remediation, r) | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } else { | ||||||||||||||||||||
| require.NoError(t, err) | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
@@ -197,10 +204,13 @@ func TestDeployCommand_HasValidDeploymentMethod(t *testing.T) { | |||||||||||||||||||
|
|
||||||||||||||||||||
| func TestDeployCommand_DeployHook(t *testing.T) { | ||||||||||||||||||||
| tests := map[string]struct { | ||||||||||||||||||||
| command string | ||||||||||||||||||||
| expectedStderr []string | ||||||||||||||||||||
| expectedStdout string | ||||||||||||||||||||
| expectedError error | ||||||||||||||||||||
| command string | ||||||||||||||||||||
| emptyDeployHook bool | ||||||||||||||||||||
| expectedStderr []string | ||||||||||||||||||||
| expectedStdout string | ||||||||||||||||||||
| expectedError error | ||||||||||||||||||||
| expectedMessage string | ||||||||||||||||||||
| expectedRemediation string | ||||||||||||||||||||
| }{ | ||||||||||||||||||||
| "fails to execute an unknown script path": { | ||||||||||||||||||||
| command: "./deployer.sh", | ||||||||||||||||||||
|
|
@@ -257,7 +267,11 @@ func TestDeployCommand_DeployHook(t *testing.T) { | |||||||||||||||||||
| clientsMock.AddDefaultMocks() | ||||||||||||||||||||
| sdkConfigMock := hooks.NewSDKConfigMock() | ||||||||||||||||||||
| sdkConfigMock.Config.SupportedProtocols = []hooks.Protocol{hooks.HookProtocolDefault} | ||||||||||||||||||||
| sdkConfigMock.Hooks.Deploy = hooks.HookScript{Name: "Deploy", Command: tc.command} | ||||||||||||||||||||
| if tc.emptyDeployHook { | ||||||||||||||||||||
| sdkConfigMock.Hooks.Deploy = hooks.HookScript{} | ||||||||||||||||||||
| } else { | ||||||||||||||||||||
| sdkConfigMock.Hooks.Deploy = hooks.HookScript{Name: "Deploy", Command: tc.command} | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
Comment on lines
+270
to
+274
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
🪓 |
||||||||||||||||||||
|
|
||||||||||||||||||||
| stdoutLogger := log.Logger{} | ||||||||||||||||||||
| stdoutBuffer := bytes.Buffer{} | ||||||||||||||||||||
|
|
@@ -281,6 +295,15 @@ func TestDeployCommand_DeployHook(t *testing.T) { | |||||||||||||||||||
| cmd.PreRunE = func(cmd *cobra.Command, args []string) error { return nil } | ||||||||||||||||||||
| testutil.MockCmdIO(clients.IO, cmd) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if tc.emptyDeployHook { | ||||||||||||||||||||
| err := errorMissingDeployHook(clients) | ||||||||||||||||||||
| require.Error(t, err) | ||||||||||||||||||||
| slackErr := slackerror.ToSlackError(err) | ||||||||||||||||||||
| assert.Equal(t, tc.expectedError.(*slackerror.Error).Code, slackErr.Code) | ||||||||||||||||||||
| assert.Contains(t, slackErr.Message, tc.expectedMessage) | ||||||||||||||||||||
| assert.Contains(t, slackErr.Remediation, tc.expectedRemediation) | ||||||||||||||||||||
| return | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
Comment on lines
+298
to
+306
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
🪓 |
||||||||||||||||||||
| err := cmd.ExecuteContext(ctx) | ||||||||||||||||||||
| assert.Contains(t, stdoutBuffer.String(), tc.command) | ||||||||||||||||||||
| if tc.expectedError != nil { | ||||||||||||||||||||
|
|
||||||||||||||||||||
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.
🔮 question: Can we revert these changes too?