From 026f1ed16c9bc685155661e3963e74fd6c38f171 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 13 Aug 2025 18:48:38 +0200 Subject: [PATCH 1/3] fix: ensure unique container names for reusable workflows --- act/runner/run_context.go | 2 +- act/runner/run_context_test.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/act/runner/run_context.go b/act/runner/run_context.go index 84c03188..9d795d4e 100644 --- a/act/runner/run_context.go +++ b/act/runner/run_context.go @@ -97,7 +97,7 @@ func (rc *RunContext) GetEnv() map[string]string { } func (rc *RunContext) jobContainerName() string { - return createSimpleContainerName(rc.Config.ContainerNamePrefix, "WORKFLOW-"+common.Sha256(rc.Run.Workflow.Name), "JOB-"+rc.Name) + return createSimpleContainerName(rc.Config.ContainerNamePrefix, "WORKFLOW-"+common.Sha256(rc.String()), "JOB-"+rc.Name) } func getDockerDaemonSocketMountPath(daemonPath string) string { diff --git a/act/runner/run_context_test.go b/act/runner/run_context_test.go index 296afd1b..177e2af7 100644 --- a/act/runner/run_context_test.go +++ b/act/runner/run_context_test.go @@ -794,7 +794,7 @@ jobs: }, inputs: []container.NewContainerInput{ { - Name: "WORKFLOW-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855_JOB", + Name: "WORKFLOW-8a5edab282632443219e051e4ade2d1d5bbc671c781051bf1437897cbdfea0f1_JOB", Image: "some:image", Username: "containerusername", Password: "containerpassword", @@ -814,7 +814,7 @@ jobs: JobOptions: "", }, { - Name: "WORKFLOW-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca49599-fe7f4c0058dbd2161ebe4aafa71cd83bd96ee19d3ca8043d5e4bc477a664a80c", + Name: "WORKFLOW-8a5edab282632443219e051e4ade2d1d5bbc671c781051bf143789-d083efaebdcab24d231fa091b85dbb8768b47136582b340132c197d9cb5e7430", Image: "service1:image", Username: "service1username", Password: "service1password", @@ -834,7 +834,7 @@ jobs: JobOptions: "", }, { - Name: "WORKFLOW-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca49599-c233cf913e1d0c90cc1404ee09917e625f9cb82156ca3d7cb10b729d563728ea", + Name: "WORKFLOW-8a5edab282632443219e051e4ade2d1d5bbc671c781051bf143789-4c44cd5731ec445ebe33780a3e39ed5e20e80f8a697a6e34c7acdd3675e631a8", Image: "service2:image", Username: "service2username", Password: "service2password", From 43c5b23c838228d58485f0ebc567b1241a2ba90d Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 3 Aug 2025 17:02:23 +0200 Subject: [PATCH 2/3] chore: enable test cases for reusable workflows --- act/runner/runner_test.go | 5 ++--- act/runner/testdata/uses-workflow/local-workflow.yml | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/act/runner/runner_test.go b/act/runner/runner_test.go index 8f2ab0db..192ab4a6 100644 --- a/act/runner/runner_test.go +++ b/act/runner/runner_test.go @@ -256,9 +256,8 @@ func TestRunner_RunEvent(t *testing.T) { {workdir, "uses-composite-check-for-input-in-if-uses", "push", "", platforms, secrets}, // {workdir, "remote-action-composite-js-pre-with-defaults", "push", "", platforms, secrets}, {workdir, "remote-action-composite-action-ref", "push", "", platforms, secrets}, - // reusable workflow not fully implemented yet - // {workdir, "uses-workflow", "push", "", platforms, map[string]string{"secret": "keep_it_private"}}, - // {workdir, "uses-workflow", "pull_request", "", platforms, map[string]string{"secret": "keep_it_private"}}, + {workdir, "uses-workflow", "push", "", platforms, map[string]string{"secret": "keep_it_private"}}, + {workdir, "uses-workflow", "pull_request", "", platforms, map[string]string{"secret": "keep_it_private"}}, {workdir, "uses-docker-url", "push", "", platforms, secrets}, {workdir, "act-composite-env-test", "push", "", platforms, secrets}, diff --git a/act/runner/testdata/uses-workflow/local-workflow.yml b/act/runner/testdata/uses-workflow/local-workflow.yml index 2e9a08d7..d571a9fb 100644 --- a/act/runner/testdata/uses-workflow/local-workflow.yml +++ b/act/runner/testdata/uses-workflow/local-workflow.yml @@ -3,7 +3,7 @@ on: pull_request jobs: reusable-workflow: - uses: ./.github/workflows/local-reusable-workflow.yml + uses: ./testdata/.github/workflows/local-reusable-workflow.yml with: string_required: string bool_required: ${{ true }} @@ -12,7 +12,7 @@ jobs: secret: keep_it_private reusable-workflow-with-inherited-secrets: - uses: ./.github/workflows/local-reusable-workflow.yml + uses: ./testdata/.github/workflows/local-reusable-workflow.yml with: string_required: string bool_required: ${{ true }} @@ -20,10 +20,10 @@ jobs: secrets: inherit reusable-workflow-with-on-string-notation: - uses: ./.github/workflows/local-reusable-workflow-no-inputs-string.yml + uses: ./testdata/.github/workflows/local-reusable-workflow-no-inputs-string.yml reusable-workflow-with-on-array-notation: - uses: ./.github/workflows/local-reusable-workflow-no-inputs-array.yml + uses: ./testdata/.github/workflows/local-reusable-workflow-no-inputs-array.yml output-test: runs-on: ubuntu-latest From 2207ff4518153fcfc55bd309d534e2e031bcf9ef Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Fri, 15 Aug 2025 08:43:36 +0200 Subject: [PATCH 3/3] fix: a remote reusable workflow may be from any host --- act/runner/reusable_workflow.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/act/runner/reusable_workflow.go b/act/runner/reusable_workflow.go index 3a805b0a..acb4bf4d 100644 --- a/act/runner/reusable_workflow.go +++ b/act/runner/reusable_workflow.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "io/fs" + "net/url" "os" "path" "regexp" @@ -54,9 +55,14 @@ func newLocalReusableWorkflowExecutor(rc *RunContext) common.Executor { func newRemoteReusableWorkflowExecutor(rc *RunContext) common.Executor { uses := rc.Run.Job().Uses - remoteReusableWorkflow := newRemoteReusableWorkflowWithPlat(rc.Config.GitHubInstance, uses) + url, err := url.Parse(uses) + if err != nil { + return common.NewErrorExecutor(fmt.Errorf("'%s' cannot be parsed as a URL: %v", uses, err)) + } + + remoteReusableWorkflow := newRemoteReusableWorkflowWithPlat(url.Host, strings.TrimPrefix(url.Path, "/")) if remoteReusableWorkflow == nil { - return common.NewErrorExecutor(fmt.Errorf("expected format {owner}/{repo}/.{git_platform}/workflows/{filename}@{ref}. Actual '%s' Input string was not in a correct format", uses)) + return common.NewErrorExecutor(fmt.Errorf("expected format {owner}/{repo}/.{git_platform}/workflows/{filename}@{ref}. Actual '%s' Input string was not in a correct format", url.Path)) } // uses with safe filename makes the target directory look something like this {owner}-{repo}-.github-workflows-{filename}@{ref}