test: add reusable workflow expansion test for ${{ needs... }} (#1362)
end-to-end tests for https://codeberg.org/forgejo/forgejo/pulls/10647 Reviewed-on: https://code.forgejo.org/forgejo/end-to-end/pulls/1362 Co-authored-by: Mathieu Fenniak <mathieu@fenniak.net> Co-committed-by: Mathieu Fenniak <mathieu@fenniak.net>
This commit is contained in:
parent
0e0b1429e6
commit
6e89c972c3
3 changed files with 27 additions and 0 deletions
|
|
@ -4,6 +4,9 @@ on:
|
||||||
input1:
|
input1:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
input3:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
outputs:
|
outputs:
|
||||||
output1:
|
output1:
|
||||||
value: ${{ jobs.callee-1.outputs.job-output }}
|
value: ${{ jobs.callee-1.outputs.job-output }}
|
||||||
|
|
@ -28,6 +31,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
set -x
|
set -x
|
||||||
test "top-level-input1" = "${{ inputs.input1 }}"
|
test "top-level-input1" = "${{ inputs.input1 }}"
|
||||||
|
test "dynamic output" = "${{ inputs.input3 }}"
|
||||||
- name: verify workflow secrets
|
- name: verify workflow secrets
|
||||||
run: |
|
run: |
|
||||||
set -x
|
set -x
|
||||||
|
|
@ -38,10 +42,13 @@ jobs:
|
||||||
run: touch /srv/example/callee-1
|
run: touch /srv/example/callee-1
|
||||||
|
|
||||||
layer-2:
|
layer-2:
|
||||||
|
needs: [callee-1]
|
||||||
uses: ./.forgejo/workflows/reusable-layer-2.yml
|
uses: ./.forgejo/workflows/reusable-layer-2.yml
|
||||||
with:
|
with:
|
||||||
input1: ${{ inputs.input1 }}
|
input1: ${{ inputs.input1 }}
|
||||||
input2: mid-level-input2
|
input2: mid-level-input2
|
||||||
|
input3: ${{ inputs.input3 }}
|
||||||
|
input4: ${{ needs.callee-1.outputs.job-output }}
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
|
|
||||||
callee-2:
|
callee-2:
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,12 @@ on:
|
||||||
input2:
|
input2:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
input3:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
input4:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
outputs:
|
outputs:
|
||||||
output3:
|
output3:
|
||||||
value: ${{ jobs.callee-3.outputs.job-output }}
|
value: ${{ jobs.callee-3.outputs.job-output }}
|
||||||
|
|
@ -28,6 +34,8 @@ jobs:
|
||||||
set -x
|
set -x
|
||||||
test "top-level-input1" = "${{ inputs.input1 }}"
|
test "top-level-input1" = "${{ inputs.input1 }}"
|
||||||
test "mid-level-input2" = "${{ inputs.input2 }}"
|
test "mid-level-input2" = "${{ inputs.input2 }}"
|
||||||
|
test "dynamic output" = "${{ inputs.input3 }}"
|
||||||
|
test "callee-1-output" = "${{ inputs.input4 }}"
|
||||||
- name: verify workflow secrets inherited
|
- name: verify workflow secrets inherited
|
||||||
run: |
|
run: |
|
||||||
set -x
|
set -x
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,22 @@ on:
|
||||||
push:
|
push:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
pre-job:
|
||||||
|
runs-on: docker
|
||||||
|
container:
|
||||||
|
image: data.forgejo.org/oci/node:22-bookworm
|
||||||
|
outputs:
|
||||||
|
dynamic: "${{ steps.dynamic-step.outputs.dynamic }}"
|
||||||
|
steps:
|
||||||
|
- id: dynamic-step
|
||||||
|
run: echo "dynamic=dynamic output" >> $FORGEJO_OUTPUT
|
||||||
|
|
||||||
layer-1:
|
layer-1:
|
||||||
|
needs: [pre-job]
|
||||||
uses: ./.forgejo/workflows/reusable-layer-1.yml
|
uses: ./.forgejo/workflows/reusable-layer-1.yml
|
||||||
with:
|
with:
|
||||||
input1: top-level-input1
|
input1: top-level-input1
|
||||||
|
input3: ${{ needs.pre-job.outputs.dynamic }}
|
||||||
secrets:
|
secrets:
|
||||||
secret1: AAAA
|
secret1: AAAA
|
||||||
secret2: BBBB1234
|
secret2: BBBB1234
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue