diff --git a/pkg/runner/run_context.go b/pkg/runner/run_context.go index 1ebaa334..5dbee29d 100755 --- a/pkg/runner/run_context.go +++ b/pkg/runner/run_context.go @@ -579,7 +579,7 @@ func (rc *RunContext) getGithubContext() *githubContext { } func (ghc *githubContext) isLocalCheckout(step *model.Step) bool { - if step.Type() != model.StepTypeInvalid { + if step.Type() == model.StepTypeInvalid { // This will be errored out by the executor later, we need this here to avoid a null panic though return false } @@ -587,6 +587,10 @@ func (ghc *githubContext) isLocalCheckout(step *model.Step) bool { return false } remoteAction := newRemoteAction(step.Uses) + if remoteAction == nil { + // IsCheckout() will nil panic if we dont bail out early + return false + } if !remoteAction.IsCheckout() { return false } diff --git a/pkg/runner/runner_test.go b/pkg/runner/runner_test.go index 53fc5007..44df4ff3 100644 --- a/pkg/runner/runner_test.go +++ b/pkg/runner/runner_test.go @@ -43,7 +43,7 @@ type TestJobFileInfo struct { containerArchitecture string } -func runTestJobFile(ctx context.Context, t *testing.T, tjfi TestJobFileInfo, secrets map[string]string) { +func runTestJobFile(ctx context.Context, t *testing.T, tjfi TestJobFileInfo) { t.Run(tjfi.workflowPath, func(t *testing.T) { workdir, err := filepath.Abs(tjfi.workdir) assert.NilError(t, err, workdir) @@ -55,7 +55,6 @@ func runTestJobFile(ctx context.Context, t *testing.T, tjfi TestJobFileInfo, sec Platforms: tjfi.platforms, ReuseContainers: false, ContainerArchitecture: tjfi.containerArchitecture, - Secrets: secrets, GitHubInstance: "github.com", } @@ -89,6 +88,7 @@ func TestRunEvent(t *testing.T) { {"testdata", "basic", "push", "", platforms, ""}, {"testdata", "fail", "push", "exit with `FAILURE`: 1", platforms, ""}, {"testdata", "runs-on", "push", "", platforms, ""}, + {"testdata", "checkout", "push", "", platforms, ""}, // Pwsh is not available in default worker (yet) so we use a separate image for testing {"testdata", "powershell", "push", "", map[string]string{"ubuntu-latest": "ghcr.io/justingrote/act-pwsh:latest"}, ""}, {"testdata", "job-container", "push", "", platforms, ""}, @@ -116,11 +116,9 @@ func TestRunEvent(t *testing.T) { log.SetLevel(log.DebugLevel) ctx := context.Background() - secretspath, _ := filepath.Abs("../../.secrets") - secrets, _ := godotenv.Read(secretspath) for _, table := range tables { - runTestJobFile(ctx, t, table, secrets) + runTestJobFile(ctx, t, table) } } @@ -220,7 +218,7 @@ func TestContainerPath(t *testing.T) { for _, v := range []containerPathJob{ {"/mnt/c/Users/act/go/src/github.com/nektos/act", "C:\\Users\\act\\go\\src\\github.com\\nektos\\act\\", ""}, {"/mnt/f/work/dir", `F:\work\dir`, ""}, - {"/mnt/c/windows/to/unix", "windows/to/unix", fmt.Sprintf("%s\\", rootDrive)}, + {"/mnt/c/windows/to/unix", "windows\\to\\unix", fmt.Sprintf("%s\\", rootDrive)}, {fmt.Sprintf("/mnt/%v/act", rootDriveLetter), "act", fmt.Sprintf("%s\\", rootDrive)}, } { if v.workDir != "" { diff --git a/pkg/runner/step_context.go b/pkg/runner/step_context.go index adc5c428..615cf02d 100644 --- a/pkg/runner/step_context.go +++ b/pkg/runner/step_context.go @@ -77,7 +77,7 @@ func (sc *StepContext) Executor() common.Executor { github := rc.getGithubContext() if remoteAction.IsCheckout() && github.isLocalCheckout(step) { return func(ctx context.Context) error { - common.Logger(ctx).Debugf("Skipping actions/checkout") + common.Logger(ctx).Debugf("Skipping local actions/checkout because workdir was already copied") return nil } } diff --git a/pkg/runner/step_context_test.go b/pkg/runner/step_context_test.go index e02a9776..af79e5ee 100644 --- a/pkg/runner/step_context_test.go +++ b/pkg/runner/step_context_test.go @@ -2,10 +2,8 @@ package runner import ( "context" - "path/filepath" "testing" - "github.com/joho/godotenv" "github.com/nektos/act/pkg/common" ) @@ -25,8 +23,7 @@ func TestStepContextExecutor(t *testing.T) { } // These tests are sufficient to only check syntax. ctx := common.WithDryrun(context.Background(), true) - secrets, _ := godotenv.Read(filepath.Join("..", ".secrets")) for _, table := range tables { - runTestJobFile(ctx, t, table, secrets) + runTestJobFile(ctx, t, table) } } diff --git a/pkg/runner/testdata/checkout/push.yml b/pkg/runner/testdata/checkout/push.yml new file mode 100644 index 00000000..c18eaa1a --- /dev/null +++ b/pkg/runner/testdata/checkout/push.yml @@ -0,0 +1,8 @@ +name: checkout +on: push + +jobs: + checkout: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2