From 47f50d3257045e7d4d326363a643a9871c0b2bf9 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sat, 26 Jul 2025 11:23:39 +0000 Subject: [PATCH] actions: add test for reusable workflows (#839) It is working although undocumented. It appears that Forgejo Actions users depend on it and breaking it would meet some non negligible push back. This test ensures that future Forgejo runner versions do not break what is working. This came to light because some fixes are necessary to the schema validation to allow for that to keep working (see https://code.forgejo.org/forgejo/act/pulls/194). Reviewed-on: https://code.forgejo.org/forgejo/end-to-end/pulls/839 Reviewed-by: Michael Kriese Co-authored-by: Earl Warren Co-committed-by: Earl Warren --- actions/actions.sh | 2 +- .../.forgejo/workflows/reusable.yml | 27 +++++++++++++++++++ .../.forgejo/workflows/test.yml | 11 ++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 actions/example-workflow-call/.forgejo/workflows/reusable.yml create mode 100644 actions/example-workflow-call/.forgejo/workflows/test.yml diff --git a/actions/actions.sh b/actions/actions.sh index aa2401e8..8030b0e1 100755 --- a/actions/actions.sh +++ b/actions/actions.sh @@ -143,7 +143,7 @@ function test_actions() { done fi - for example in echo lxc config-options cache checkout service container expression local-action docker-action if if-fail push tag push-cancel artifacts pull-request context; do + for example in echo workflow-call lxc config-options cache checkout service container expression local-action docker-action if if-fail push tag push-cancel artifacts pull-request context; do run actions_verify_example $example done diff --git a/actions/example-workflow-call/.forgejo/workflows/reusable.yml b/actions/example-workflow-call/.forgejo/workflows/reusable.yml new file mode 100644 index 00000000..87659501 --- /dev/null +++ b/actions/example-workflow-call/.forgejo/workflows/reusable.yml @@ -0,0 +1,27 @@ +on: + workflow_call: + inputs: + parameter1: + required: true + type: string + +jobs: + callee: + runs-on: docker + container: + image: code.forgejo.org/oci/node:22-bookworm + volumes: + - /srv/example:/srv/example + steps: + + - run: | + set -x + test "${{ inputs.parameter1 }}" = "value1" + + - name: save event + run: | + d=/srv/example/push/contexts/$FORGEJO_EVENT_NAME + mkdir -p $d + cat > $d/github <<'EOF' + ${{ toJSON(github) }} + EOF diff --git a/actions/example-workflow-call/.forgejo/workflows/test.yml b/actions/example-workflow-call/.forgejo/workflows/test.yml new file mode 100644 index 00000000..e009eeef --- /dev/null +++ b/actions/example-workflow-call/.forgejo/workflows/test.yml @@ -0,0 +1,11 @@ +on: + push: + +jobs: + caller: + runs-on: docker + container: + image: code.forgejo.org/oci/node:22-bookworm + uses: ./.forgejo/workflows/reusable.yml + with: + parameter1: value1