Skip to content
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

feat(exec): separate stdout and stderr in Run and Test exec-action outputs #6572

Merged
merged 3 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions core/src/plugins/exec/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ export const execRuntimeOutputsSchema = s.object({
.describe(
"The full log output from the executed command. (Pro-tip: Make it machine readable so it can be parsed by dependants)"
),
stdout: s
.string()
.default("")
.describe(
"The stdout log output from the executed command. (Pro-tip: Make it machine readable so it can be parsed by dependants)"
),
stderr: s
.string()
.default("")
.describe(
"The stderr log output from the executed command. (Pro-tip: Make it machine readable so it can be parsed by dependants)"
),
})

export const execCommonSchema = s.object({
Expand Down
2 changes: 2 additions & 0 deletions core/src/plugins/exec/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ execRun.addHandler("run", async ({ artifactsPath, log, action, ctx }) => {
detail,
outputs: {
log: commandResult.outputLog,
stdout: commandResult.stdout,
stderr: commandResult.stderr,
},
} as const

Expand Down
3 changes: 3 additions & 0 deletions core/src/plugins/exec/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ execTest.addHandler("run", async ({ log, action, artifactsPath, ctx }) => {
detail,
outputs: {
log: commandResult.outputLog,
stdout: commandResult.stdout,
stderr: commandResult.stderr,
},
} as const

Expand All @@ -102,5 +104,6 @@ execTest.addHandler("run", async ({ log, action, artifactsPath, ctx }) => {
})
)
}

return result
})
2 changes: 2 additions & 0 deletions core/test/unit/src/plugins/exec/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ describe("exec plugin", () => {
})

expect(res.outputs.log).to.eql(basePath)
expect(res.outputs.stdout).to.eql(basePath)
})

it("should receive version as an env var", async () => {
Expand Down Expand Up @@ -480,6 +481,7 @@ describe("exec plugin", () => {
silent: false,
})
expect(res.outputs.log).to.equal(action.versionString())
expect(res.outputs.stdout).to.equal(action.versionString())
})
})

Expand Down
16 changes: 16 additions & 0 deletions docs/reference/action-types/Build/exec.md
Original file line number Diff line number Diff line change
Expand Up @@ -460,3 +460,19 @@ The full log output from the executed command. (Pro-tip: Make it machine readabl
| -------- | ------- |
| `string` | `""` |

### `${actions.build.<name>.outputs.stdout}`

The stdout log output from the executed command. (Pro-tip: Make it machine readable so it can be parsed by dependants)

| Type | Default |
| -------- | ------- |
| `string` | `""` |

### `${actions.build.<name>.outputs.stderr}`

The stderr log output from the executed command. (Pro-tip: Make it machine readable so it can be parsed by dependants)

| Type | Default |
| -------- | ------- |
| `string` | `""` |

16 changes: 16 additions & 0 deletions docs/reference/action-types/Deploy/exec.md
Original file line number Diff line number Diff line change
Expand Up @@ -459,3 +459,19 @@ The full log output from the executed command. (Pro-tip: Make it machine readabl
| -------- | ------- |
| `string` | `""` |

### `${actions.deploy.<name>.outputs.stdout}`

The stdout log output from the executed command. (Pro-tip: Make it machine readable so it can be parsed by dependants)

| Type | Default |
| -------- | ------- |
| `string` | `""` |

### `${actions.deploy.<name>.outputs.stderr}`

The stderr log output from the executed command. (Pro-tip: Make it machine readable so it can be parsed by dependants)

| Type | Default |
| -------- | ------- |
| `string` | `""` |

16 changes: 16 additions & 0 deletions docs/reference/action-types/Run/exec.md
Original file line number Diff line number Diff line change
Expand Up @@ -439,3 +439,19 @@ The full log output from the executed command. (Pro-tip: Make it machine readabl
| -------- | ------- |
| `string` | `""` |

### `${actions.run.<name>.outputs.stdout}`

The stdout log output from the executed command. (Pro-tip: Make it machine readable so it can be parsed by dependants)

| Type | Default |
| -------- | ------- |
| `string` | `""` |

### `${actions.run.<name>.outputs.stderr}`

The stderr log output from the executed command. (Pro-tip: Make it machine readable so it can be parsed by dependants)

| Type | Default |
| -------- | ------- |
| `string` | `""` |

16 changes: 16 additions & 0 deletions docs/reference/action-types/Test/exec.md
Original file line number Diff line number Diff line change
Expand Up @@ -439,3 +439,19 @@ The full log output from the executed command. (Pro-tip: Make it machine readabl
| -------- | ------- |
| `string` | `""` |

### `${actions.test.<name>.outputs.stdout}`

The stdout log output from the executed command. (Pro-tip: Make it machine readable so it can be parsed by dependants)

| Type | Default |
| -------- | ------- |
| `string` | `""` |

### `${actions.test.<name>.outputs.stderr}`

The stderr log output from the executed command. (Pro-tip: Make it machine readable so it can be parsed by dependants)

| Type | Default |
| -------- | ------- |
| `string` | `""` |