Skip to content

Commit

Permalink
fix(enterprise): add step skipped event
Browse files Browse the repository at this point in the history
We now emit a `workflowStepSkipped` event when a workflow step is
skipped.
  • Loading branch information
thsig committed Nov 6, 2020
1 parent b866079 commit f644cdb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 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 @@ -107,6 +107,7 @@ export class RunWorkflowCommand extends Command<Args, {}> {
outputs: {},
log: "",
}
garden.events.emit("workflowStepSkipped", { index })
continue
}

Expand Down
4 changes: 4 additions & 0 deletions core/src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ export interface Events extends LoggerEvents {
workflowStepProcessing: {
index: number
}
workflowStepSkipped: {
index: number
}
workflowStepComplete: {
index: number
durationMsec: number
Expand Down Expand Up @@ -202,6 +205,7 @@ export const eventNames: EventName[] = [
"workflowRunning",
"workflowComplete",
"workflowStepProcessing",
"workflowStepSkipped",
"workflowStepError",
"workflowStepComplete",
]
15 changes: 9 additions & 6 deletions core/test/unit/src/commands/run/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe("RunWorkflowCommand", () => {
name: "workflow-a",
kind: "Workflow",
path: garden.projectRoot,
steps: [{ command: ["deploy"] }, { command: ["test"] }],
steps: [{ command: ["deploy"] }, { command: ["build"], skip: true }, { command: ["test"] }],
},
])

Expand All @@ -137,13 +137,15 @@ describe("RunWorkflowCommand", () => {
expect(we[2].payload.index).to.eql(0)
expect(we[2].payload.durationMsec).to.gte(0)

expect(we[3]).to.eql({ name: "workflowStepProcessing", payload: { index: 1 } })
expect(we[3]).to.eql({ name: "workflowStepSkipped", payload: { index: 1 } })

expect(we[4]).to.eql({ name: "workflowStepProcessing", payload: { index: 2 } })

expect(we[4].name).to.eql("workflowStepComplete")
expect(we[4].payload.index).to.eql(1)
expect(we[4].payload.durationMsec).to.gte(0)
expect(we[5].name).to.eql("workflowStepComplete")
expect(we[5].payload.index).to.eql(2)
expect(we[5].payload.durationMsec).to.gte(0)

expect(we[5]).to.eql({ name: "workflowComplete", payload: {} })
expect(we[6]).to.eql({ name: "workflowComplete", payload: {} })
})

function filterLogEntries(entries: LogEntry[], msgRegex: RegExp): LogEntry[] {
Expand Down Expand Up @@ -663,6 +665,7 @@ function getWorkflowEvents(garden: TestGarden) {
"workflowRunning",
"workflowComplete",
"workflowStepProcessing",
"workflowStepSkipped",
"workflowStepError",
"workflowStepComplete",
]
Expand Down

0 comments on commit f644cdb

Please sign in to comment.