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:
Mathieu Fenniak 2026-01-01 18:17:58 +00:00 committed by Mathieu Fenniak
parent 0e0b1429e6
commit 6e89c972c3
3 changed files with 27 additions and 0 deletions

View file

@ -4,6 +4,9 @@ on:
input1:
required: true
type: string
input3:
required: true
type: string
outputs:
output1:
value: ${{ jobs.callee-1.outputs.job-output }}
@ -28,6 +31,7 @@ jobs:
run: |
set -x
test "top-level-input1" = "${{ inputs.input1 }}"
test "dynamic output" = "${{ inputs.input3 }}"
- name: verify workflow secrets
run: |
set -x
@ -38,10 +42,13 @@ jobs:
run: touch /srv/example/callee-1
layer-2:
needs: [callee-1]
uses: ./.forgejo/workflows/reusable-layer-2.yml
with:
input1: ${{ inputs.input1 }}
input2: mid-level-input2
input3: ${{ inputs.input3 }}
input4: ${{ needs.callee-1.outputs.job-output }}
secrets: inherit
callee-2:

View file

@ -7,6 +7,12 @@ on:
input2:
required: true
type: string
input3:
required: true
type: string
input4:
required: true
type: string
outputs:
output3:
value: ${{ jobs.callee-3.outputs.job-output }}
@ -28,6 +34,8 @@ jobs:
set -x
test "top-level-input1" = "${{ inputs.input1 }}"
test "mid-level-input2" = "${{ inputs.input2 }}"
test "dynamic output" = "${{ inputs.input3 }}"
test "callee-1-output" = "${{ inputs.input4 }}"
- name: verify workflow secrets inherited
run: |
set -x

View file

@ -2,10 +2,22 @@ on:
push:
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:
needs: [pre-job]
uses: ./.forgejo/workflows/reusable-layer-1.yml
with:
input1: top-level-input1
input3: ${{ needs.pre-job.outputs.dynamic }}
secrets:
secret1: AAAA
secret2: BBBB1234