From 7efe25f13de216f68e6e94c40dbec3e55373d7d5 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Thu, 28 Aug 2025 16:58:49 +0200 Subject: [PATCH] chore: local action name collision regression tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the tag name collide (e.g. v9.1.1), it will fail with: ``` [push.yml/test] [DEBUG] Working directory '/home/earl-warren/software/runner/act/runner/testdata/local-action-dockerfile-tag/example2' [push.yml/test] ❌ Failure - Main [[ "example1 SOMEONE" == "example2 SOMEONE" ]] ``` --- act/runner/runner_test.go | 2 ++ .../testdata/local-action-dockerfile-tag/README.txt | 4 ++++ .../example1/actions/docker-local/Dockerfile | 8 ++++++++ .../example1/actions/docker-local/action.yml | 12 ++++++++++++ .../example1/actions/docker-local/entrypoint.sh | 3 +++ .../local-action-dockerfile-example1/push.yml | 11 +++++++++++ .../example2/actions/docker-local/Dockerfile | 8 ++++++++ .../example2/actions/docker-local/action.yml | 12 ++++++++++++ .../example2/actions/docker-local/entrypoint.sh | 3 +++ .../local-action-dockerfile-example2/push.yml | 11 +++++++++++ 10 files changed, 74 insertions(+) create mode 100644 act/runner/testdata/local-action-dockerfile-tag/README.txt create mode 100644 act/runner/testdata/local-action-dockerfile-tag/example1/actions/docker-local/Dockerfile create mode 100644 act/runner/testdata/local-action-dockerfile-tag/example1/actions/docker-local/action.yml create mode 100755 act/runner/testdata/local-action-dockerfile-tag/example1/actions/docker-local/entrypoint.sh create mode 100644 act/runner/testdata/local-action-dockerfile-tag/example1/local-action-dockerfile-example1/push.yml create mode 100644 act/runner/testdata/local-action-dockerfile-tag/example2/actions/docker-local/Dockerfile create mode 100644 act/runner/testdata/local-action-dockerfile-tag/example2/actions/docker-local/action.yml create mode 100755 act/runner/testdata/local-action-dockerfile-tag/example2/actions/docker-local/entrypoint.sh create mode 100644 act/runner/testdata/local-action-dockerfile-tag/example2/local-action-dockerfile-example2/push.yml diff --git a/act/runner/runner_test.go b/act/runner/runner_test.go index 83523c1e..7f3b46e9 100644 --- a/act/runner/runner_test.go +++ b/act/runner/runner_test.go @@ -245,6 +245,8 @@ func TestRunner_RunEvent(t *testing.T) { {workdir, "local-action-fails-schema-validation", "push", "Job 'test' failed", platforms, secrets}, {workdir, "local-action-docker-url", "push", "", platforms, secrets}, {workdir, "local-action-dockerfile", "push", "", platforms, secrets}, + {workdir + "/local-action-dockerfile-tag/example1", "local-action-dockerfile-example1", "push", "", platforms, secrets}, + {workdir + "/local-action-dockerfile-tag/example2", "local-action-dockerfile-example2", "push", "", platforms, secrets}, {workdir, "local-action-via-composite-dockerfile", "push", "", platforms, secrets}, {workdir, "local-action-js", "push", "", platforms, secrets}, diff --git a/act/runner/testdata/local-action-dockerfile-tag/README.txt b/act/runner/testdata/local-action-dockerfile-tag/README.txt new file mode 100644 index 00000000..aba97f3b --- /dev/null +++ b/act/runner/testdata/local-action-dockerfile-tag/README.txt @@ -0,0 +1,4 @@ +example1 and example2 eacho use a local actions that have the same +path (actions/docker-local) but do not behave the same. This verifies +that the locally built images have different names and do not collide +despite both being called with `uses: ./actions/docker-local. diff --git a/act/runner/testdata/local-action-dockerfile-tag/example1/actions/docker-local/Dockerfile b/act/runner/testdata/local-action-dockerfile-tag/example1/actions/docker-local/Dockerfile new file mode 100644 index 00000000..b8054873 --- /dev/null +++ b/act/runner/testdata/local-action-dockerfile-tag/example1/actions/docker-local/Dockerfile @@ -0,0 +1,8 @@ +# Container image that runs your code +FROM code.forgejo.org/oci/alpine:latest + +# Copies your code file from your action repository to the filesystem path `/` of the container +COPY entrypoint.sh /entrypoint.sh + +# Code file to execute when the docker container starts up (`entrypoint.sh`) +ENTRYPOINT ["/entrypoint.sh"] diff --git a/act/runner/testdata/local-action-dockerfile-tag/example1/actions/docker-local/action.yml b/act/runner/testdata/local-action-dockerfile-tag/example1/actions/docker-local/action.yml new file mode 100644 index 00000000..a6b97460 --- /dev/null +++ b/act/runner/testdata/local-action-dockerfile-tag/example1/actions/docker-local/action.yml @@ -0,0 +1,12 @@ +inputs: + who-to-greet: +outputs: + whoami: + description: 'The time we greeted you' +runs: + using: 'docker' + image: 'Dockerfile' + env: + WHOAMI: ${{ inputs.who-to-greet }} + args: + - ${{ inputs.who-to-greet }} diff --git a/act/runner/testdata/local-action-dockerfile-tag/example1/actions/docker-local/entrypoint.sh b/act/runner/testdata/local-action-dockerfile-tag/example1/actions/docker-local/entrypoint.sh new file mode 100755 index 00000000..7047838a --- /dev/null +++ b/act/runner/testdata/local-action-dockerfile-tag/example1/actions/docker-local/entrypoint.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +echo ::set-output "name=whoami::example1 $WHOAMI" diff --git a/act/runner/testdata/local-action-dockerfile-tag/example1/local-action-dockerfile-example1/push.yml b/act/runner/testdata/local-action-dockerfile-tag/example1/local-action-dockerfile-example1/push.yml new file mode 100644 index 00000000..fd24e76e --- /dev/null +++ b/act/runner/testdata/local-action-dockerfile-tag/example1/local-action-dockerfile-example1/push.yml @@ -0,0 +1,11 @@ +on: push +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./actions/docker-local + id: dockerlocal + with: + who-to-greet: 'SOMEONE' + - run: '[[ "${{ steps.dockerlocal.outputs.whoami }}" == "example1 SOMEONE" ]]' diff --git a/act/runner/testdata/local-action-dockerfile-tag/example2/actions/docker-local/Dockerfile b/act/runner/testdata/local-action-dockerfile-tag/example2/actions/docker-local/Dockerfile new file mode 100644 index 00000000..b8054873 --- /dev/null +++ b/act/runner/testdata/local-action-dockerfile-tag/example2/actions/docker-local/Dockerfile @@ -0,0 +1,8 @@ +# Container image that runs your code +FROM code.forgejo.org/oci/alpine:latest + +# Copies your code file from your action repository to the filesystem path `/` of the container +COPY entrypoint.sh /entrypoint.sh + +# Code file to execute when the docker container starts up (`entrypoint.sh`) +ENTRYPOINT ["/entrypoint.sh"] diff --git a/act/runner/testdata/local-action-dockerfile-tag/example2/actions/docker-local/action.yml b/act/runner/testdata/local-action-dockerfile-tag/example2/actions/docker-local/action.yml new file mode 100644 index 00000000..a6b97460 --- /dev/null +++ b/act/runner/testdata/local-action-dockerfile-tag/example2/actions/docker-local/action.yml @@ -0,0 +1,12 @@ +inputs: + who-to-greet: +outputs: + whoami: + description: 'The time we greeted you' +runs: + using: 'docker' + image: 'Dockerfile' + env: + WHOAMI: ${{ inputs.who-to-greet }} + args: + - ${{ inputs.who-to-greet }} diff --git a/act/runner/testdata/local-action-dockerfile-tag/example2/actions/docker-local/entrypoint.sh b/act/runner/testdata/local-action-dockerfile-tag/example2/actions/docker-local/entrypoint.sh new file mode 100755 index 00000000..c6750948 --- /dev/null +++ b/act/runner/testdata/local-action-dockerfile-tag/example2/actions/docker-local/entrypoint.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +echo ::set-output "name=whoami::example2 $WHOAMI" diff --git a/act/runner/testdata/local-action-dockerfile-tag/example2/local-action-dockerfile-example2/push.yml b/act/runner/testdata/local-action-dockerfile-tag/example2/local-action-dockerfile-example2/push.yml new file mode 100644 index 00000000..b6f39f47 --- /dev/null +++ b/act/runner/testdata/local-action-dockerfile-tag/example2/local-action-dockerfile-example2/push.yml @@ -0,0 +1,11 @@ +on: push +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./actions/docker-local + id: dockerlocal + with: + who-to-greet: 'SOMEONE' + - run: '[[ "${{ steps.dockerlocal.outputs.whoami }}" == "example2 SOMEONE" ]]'