Skip to content

Commit

Permalink
fix(enterprise): add workflowError event
Browse files Browse the repository at this point in the history
This new event is necessary to correctly handle failed workflows when
combined with the `when` modifier.

Also streamlined the module version included in task outputs in event
payloads.
  • Loading branch information
thsig committed Nov 20, 2020
1 parent e272d09 commit 2709fab
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/src/commands/run/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ export class RunWorkflowCommand extends Command<Args, {}> {

if (size(stepErrors) > 0) {
printResult({ startedAt, log: outerLog, workflow, success: false })
garden.events.emit("workflowError", {})
return { result, errors: flatten(Object.values(stepErrors)) }
}

Expand Down
5 changes: 5 additions & 0 deletions core/src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ export function toGraphResultEventPayload(result: GraphResult): GraphResultEvent
const payload = omit(result, "dependencyResults")
if (result.output) {
payload.output = omit(result.output, "dependencyResults", "log", "buildLog")
if (result.output.version) {
payload.output.version = result.output.version.versionString || null
}
}
return payload
}
Expand Down Expand Up @@ -160,6 +163,7 @@ export interface Events extends LoggerEvents {
// Workflow events
workflowRunning: {}
workflowComplete: {}
workflowError: {}
workflowStepProcessing: {
index: number
}
Expand Down Expand Up @@ -204,6 +208,7 @@ export const eventNames: EventName[] = [
"serviceStatus",
"workflowRunning",
"workflowComplete",
"workflowError",
"workflowStepProcessing",
"workflowStepSkipped",
"workflowStepError",
Expand Down
2 changes: 2 additions & 0 deletions core/test/unit/src/commands/run/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ describe("RunWorkflowCommand", () => {
expect(we[2].name).to.eql("workflowStepError")
expect(we[2].payload.index).to.eql(0)
expect(we[2].payload.durationMsec).to.gte(0)
expect(we[3].name).to.eql("workflowError")
})

it("should write a file with string data ahead of the run, before resolving providers", async () => {
Expand Down Expand Up @@ -713,6 +714,7 @@ function getWorkflowEvents(garden: TestGarden) {
const eventNames = [
"workflowRunning",
"workflowComplete",
"workflowError",
"workflowStepProcessing",
"workflowStepSkipped",
"workflowStepError",
Expand Down

0 comments on commit 2709fab

Please sign in to comment.