diff --git a/rule_expression.go b/rule_expression.go index c09d729aa..52068c958 100644 --- a/rule_expression.go +++ b/rule_expression.go @@ -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) } } diff --git a/testdata/err/issue151_child_of_child_job.out b/testdata/err/issue151_child_of_child_job.out new file mode 100644 index 000000000..5dbf5bc3a --- /dev/null +++ b/testdata/err/issue151_child_of_child_job.out @@ -0,0 +1 @@ +/test\.yaml:26:31: property "first" is not defined in object type {second: {.*outputs: {second: string}.*}} \[expression\]/ diff --git a/testdata/err/issue151_child_of_child_job.yaml b/testdata/err/issue151_child_of_child_job.yaml new file mode 100644 index 000000000..0bf446d80 --- /dev/null +++ b/testdata/err/issue151_child_of_child_job.yaml @@ -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) }}' diff --git a/testdata/ok/issue-151-child-of-child-job.yaml b/testdata/ok/issue-151-child-of-child-job.yaml new file mode 100644 index 000000000..0567b5b90 --- /dev/null +++ b/testdata/ok/issue-151-child-of-child-job.yaml @@ -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) }}'