Skip to content

Commit

Permalink
fix job outputs are only passed to children (fix #151)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Aug 28, 2022
1 parent 9703a84 commit d1ffd58
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rule_expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ func (rule *RuleExpression) populateDependantNeedsTypes(out *ObjectType, job *Jo
"result": StringType{},
})

rule.populateDependantNeedsTypes(out, j, root) // Add necessary needs props recursively
// Do not collect outputs type from parent of parent recursively. (#151)
}
}

Expand Down
1 change: 1 addition & 0 deletions testdata/err/issue151_child_of_child_job.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/test\.yaml:26:31: property "first" is not defined in object type {second: {.*outputs: {second: string}.*}} \[expression\]/
26 changes: 26 additions & 0 deletions testdata/err/issue151_child_of_child_job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test

on: push

jobs:
first:
runs-on: ubuntu-latest
outputs:
first: 'output from parent'
steps:
- run: echo 'first'

second:
needs: [first]
runs-on: ubuntu-latest
outputs:
second: 'output from second'
steps:
- run: echo 'second'

third:
needs: [second]
runs-on: ubuntu-latest
steps:
- run: echo '${{ toJSON(needs.second.outputs) }}'
- run: echo '${{ toJSON(needs.first.outputs) }}'
26 changes: 26 additions & 0 deletions testdata/ok/issue-151-child-of-child-job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test

on: push

jobs:
first:
runs-on: ubuntu-latest
outputs:
first: 'output from parent'
steps:
- run: echo 'first'

second:
needs: [first]
runs-on: ubuntu-latest
outputs:
second: 'output from second'
steps:
- run: echo 'second'

third:
needs: [first, second]
runs-on: ubuntu-latest
steps:
- run: echo '${{ toJSON(needs.second.outputs) }}'
- run: echo '${{ toJSON(needs.first.outputs) }}'

0 comments on commit d1ffd58

Please sign in to comment.