From 8505f73fe4dab03b4d5d60640e1c2268e9f98b51 Mon Sep 17 00:00:00 2001 From: Christopher Homberger Date: Fri, 6 Feb 2026 11:11:34 +0000 Subject: [PATCH] fix: fallback of localRepository cache being nil (#29) Doing `act --local-repository test/self-ref@main=/folder-path/self-ref` caused a null pointer exception while fetching a non mapped entry, due to missing remote fallback. Reviewed-on: https://gitea.com/actions-oss/act-cli/pulls/29 Co-authored-by: Christopher Homberger Co-committed-by: Christopher Homberger --- cmd/root.go | 8 +++++--- cmd/root_test.go | 14 ++++++++++++++ .../push.yml | 9 +++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 pkg/runner/testdata/remote-action-composite-action-ref-partial-override/push.yml diff --git a/cmd/root.go b/cmd/root.go index 920f50ef..0a93ac67 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -653,11 +653,13 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str ContainerNetworkMode: docker_container.NetworkMode(input.networkName), Parallel: input.parallel, } + actionCache := runner.GoGitActionCache{ + Path: config.ActionCacheDir, + } + config.ActionCache = &actionCache if input.actionOfflineMode { config.ActionCache = &runner.GoGitActionCacheOfflineMode{ - Parent: runner.GoGitActionCache{ - Path: config.ActionCacheDir, - }, + Parent: actionCache, } } if len(input.localRepository) > 0 { diff --git a/cmd/root_test.go b/cmd/root_test.go index 0d417434..cb010edb 100644 --- a/cmd/root_test.go +++ b/cmd/root_test.go @@ -3,6 +3,7 @@ package cmd import ( "context" "path" + "path/filepath" "testing" "github.com/stretchr/testify/assert" @@ -93,3 +94,16 @@ func TestWorkflowCall(t *testing.T) { })(rootCmd, []string{"workflow_call"}) assert.NoError(t, err) } + +func TestLocalRepositories(t *testing.T) { + wd, _ := filepath.Abs("../pkg/runner/testdata/") + rootCmd := createRootCommand(context.Background(), &Input{}, "") + err := newRunCommand(context.Background(), &Input{ + githubInstance: "github.com", + platforms: []string{"ubuntu-latest=node:16-buster-slim"}, + workdir: wd, + workflowsPath: "./remote-action-composite-action-ref-partial-override/push.yml", + localRepository: []string{"needs/override@main=" + wd + "/actions-environment-and-context-tests"}, + })(rootCmd, []string{"push"}) + assert.NoError(t, err) +} diff --git a/pkg/runner/testdata/remote-action-composite-action-ref-partial-override/push.yml b/pkg/runner/testdata/remote-action-composite-action-ref-partial-override/push.yml new file mode 100644 index 00000000..237e778b --- /dev/null +++ b/pkg/runner/testdata/remote-action-composite-action-ref-partial-override/push.yml @@ -0,0 +1,9 @@ +name: remote-action-composite-action-ref +on: push + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: nektos/act-test-actions/composite-assert-action-ref-action@main + - uses: needs/override/js@main \ No newline at end of file