-
Notifications
You must be signed in to change notification settings - Fork 278
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
Fix run command exit codes #1733
Conversation
@@ -245,7 +245,7 @@ export async function runAndCopy({ | |||
result = await runner.exec({ | |||
// Pipe the output from the command to the /tmp/output pipe, including stderr. Some shell voodoo happening |
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.
This comment still applies 😛
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.
Mostly looks good, had a couple of questions and a comment on phrasing.
garden-service/src/commands/base.ts
Outdated
actionDescription: string | ||
}) { | ||
const prefix = success | ||
? `${capitalize(actionDescription)} result:` |
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.
Wondering about the phrasing here. "Run task result" and "Run test result" feel a little odd to me. How about using "output" instead of "result", and just using "Task" and "Test" for the action description? So it'd be simply "Task output" and "Test output". That feels more natural to me.
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.
Which btw also works for the error variant, e.g. "Test failed with error".
docs/misc/faq.md
Outdated
|
||
The `garden run test` command runs **a single test in interactive mode** regardless of whether or not it's cached. Interactive mode means that the output is streamed to the screen immediately and you can interact with it if applicable. | ||
|
||
Note that due to a current limitation, Garden can't copy artifacts for tests in interactive mode. You can disable it by setting `--interactive false`. [See here](https://docs.garden.io/reference/commands#garden-run-test) for the full synopsis. |
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.
Is there an open issue for that? Good to link that here.
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.
No but we should add it.
} | ||
|
||
return { result } | ||
return handleTaskResult({ log, actionDescription: "run task", result: result! }) |
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.
Should this be handleRunResult
?
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.
It should not. This handleTaskResult
function handles, as the name suggests, a result of type TaskResult
, from a garden.processTasks
call. The handleRunResult
handles results of type RunResult
, from calling something like garden.testModule
.
I opted for two functions since the types, and especially return types, are different and instead enforcing correctness at the test level, should they drift
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.
Gotcha. Maybe add comments on top of the handler functions to explain the difference?
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.
Good point!
return "basic" | ||
} | ||
return "fancy" | ||
} |
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.
Is this preferable to stopping the logger before running the interactive part?
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.
It felt more robust. Didn't really try the alternative.
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.
Actually it seems to work just fine.
9119ad4
to
2938099
Compare
548eada
to
76563f8
Compare
What this PR does / why we need it:
The first commit fixes an issue with
garden run test
returning exit code 0 if the test fails and artifacts are copied.As I was working on that, I noticed that
garden run task
would return the wrong exit code for local tasks, and some other inconsistencies in how the outputs were printed. The second commit addresses that.Which issue(s) this PR fixes:
This came up in a conversation on the community Slack.
Special notes for your reviewer:
I turned the
loggerType
static property into a function so that commands can dynamically decide what the logger type should be. For example, commands with--interactive=true
should use the basic logger.Here are screenshots from how the outputs look now: