mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-08-06 17:40:58 +00:00
Add needs
job output (#629)
* Add outputs field to job model * Add output interpolation for jobs * Add otto config reference for interpolated job output values into 'needs' context * Add output interpolation call after job has completed. * gofmt * Remove whitespace * goimports Co-authored-by: Casey Lee <cplee@nektos.com>
This commit is contained in:
parent
4229505f5d
commit
5ed5bc15b3
5 changed files with 76 additions and 1 deletions
|
@ -131,6 +131,48 @@ jobs:
|
|||
assert.Equal(t, workflow.Jobs["test"].Steps[4].Type(), StepTypeUsesActionLocal)
|
||||
}
|
||||
|
||||
// See: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idoutputs
|
||||
func TestReadWorkflow_JobOutputs(t *testing.T) {
|
||||
yaml := `
|
||||
name: job outputs definition
|
||||
|
||||
jobs:
|
||||
test1:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- id: test1_1
|
||||
run: |
|
||||
echo "::set-output name=a_key::some-a_value"
|
||||
echo "::set-output name=b-key::some-b-value"
|
||||
outputs:
|
||||
some_a_key: ${{ steps.test1_1.outputs.a_key }}
|
||||
some-b-key: ${{ steps.test1_1.outputs.b-key }}
|
||||
|
||||
test2:
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- test1
|
||||
steps:
|
||||
- name: test2_1
|
||||
run: |
|
||||
echo "${{ needs.test1.outputs.some_a_key }}"
|
||||
echo "${{ needs.test1.outputs.some-b-key }}"
|
||||
`
|
||||
|
||||
workflow, err := ReadWorkflow(strings.NewReader(yaml))
|
||||
assert.NoError(t, err, "read workflow should succeed")
|
||||
assert.Len(t, workflow.Jobs, 2)
|
||||
|
||||
assert.Len(t, workflow.Jobs["test1"].Steps, 1)
|
||||
assert.Equal(t, StepTypeRun, workflow.Jobs["test1"].Steps[0].Type())
|
||||
assert.Equal(t, "test1_1", workflow.Jobs["test1"].Steps[0].ID)
|
||||
assert.Len(t, workflow.Jobs["test1"].Outputs, 2)
|
||||
assert.Contains(t, workflow.Jobs["test1"].Outputs, "some_a_key")
|
||||
assert.Contains(t, workflow.Jobs["test1"].Outputs, "some-b-key")
|
||||
assert.Equal(t, "${{ steps.test1_1.outputs.a_key }}", workflow.Jobs["test1"].Outputs["some_a_key"])
|
||||
assert.Equal(t, "${{ steps.test1_1.outputs.b-key }}", workflow.Jobs["test1"].Outputs["some-b-key"])
|
||||
}
|
||||
|
||||
func TestStep_ShellCommand(t *testing.T) {
|
||||
tests := []struct {
|
||||
shell string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue