From 616d7fcaebfc3b9c9eaccf2f5bb811dcf62aefdd Mon Sep 17 00:00:00 2001 From: Justin Grote Date: Tue, 4 May 2021 22:57:33 -0700 Subject: [PATCH] Remove pwsh -login and add Pwsh test (#660) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Remove pwsh -login and add Pwsh test * Add Shell Command Test for coverage * 🧪 Move PWSH Platform definition to inline test, it can always be expanded out later Reference: https://github.com/nektos/act/pull/660#discussion_r626171728 * Test MacOS Build for transient failure Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- pkg/model/workflow.go | 2 +- pkg/model/workflow_test.go | 16 ++++++++++++++++ pkg/runner/runner_test.go | 4 +++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/pkg/model/workflow.go b/pkg/model/workflow.go index 50221b0..25f419a 100644 --- a/pkg/model/workflow.go +++ b/pkg/model/workflow.go @@ -258,7 +258,7 @@ func (s *Step) ShellCommand() string { case "", "bash": shellCommand = "bash --login --noprofile --norc -e -o pipefail {0}" case "pwsh": - shellCommand = "pwsh -login -command . '{0}'" + shellCommand = "pwsh -command . '{0}'" case "python": shellCommand = "python {0}" case "sh": diff --git a/pkg/model/workflow_test.go b/pkg/model/workflow_test.go index 1a96969..692ee17 100644 --- a/pkg/model/workflow_test.go +++ b/pkg/model/workflow_test.go @@ -130,3 +130,19 @@ jobs: assert.Equal(t, workflow.Jobs["test"].Steps[3].Type(), StepTypeUsesDockerURL) assert.Equal(t, workflow.Jobs["test"].Steps[4].Type(), StepTypeUsesActionLocal) } + +func TestStep_ShellCommand(t *testing.T) { + tests := []struct { + shell string + want string + }{ + {"pwsh", "pwsh -command . '{0}'"}, + {"powershell", "powershell -command . '{0}'"}, + } + for _, tt := range tests { + t.Run(tt.shell, func(t *testing.T) { + got := (&Step{Shell: tt.shell}).ShellCommand() + assert.Equal(t, got, tt.want) + }) + } +} diff --git a/pkg/runner/runner_test.go b/pkg/runner/runner_test.go index 6c83c1d..044625e 100644 --- a/pkg/runner/runner_test.go +++ b/pkg/runner/runner_test.go @@ -83,10 +83,13 @@ func TestRunEvent(t *testing.T) { platforms := map[string]string{ "ubuntu-latest": "node:12.20.1-buster-slim", } + tables := []TestJobFileInfo{ {"testdata", "basic", "push", "", platforms, ""}, {"testdata", "fail", "push", "exit with `FAILURE`: 1", platforms, ""}, {"testdata", "runs-on", "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, ""}, {"testdata", "job-container-non-root", "push", "", platforms, ""}, {"testdata", "uses-docker-url", "push", "", platforms, ""}, @@ -102,7 +105,6 @@ func TestRunEvent(t *testing.T) { {"testdata", "defaults-run", "push", "", platforms, ""}, {"testdata", "uses-composite", "push", "", platforms, ""}, {"testdata", "issue-597", "push", "", platforms, ""}, - // {"testdata", "powershell", "push", "", platforms, ""}, // Powershell is not available on default act test runner (yet) but preserving here for posterity // {"testdata", "issue-228", "push", "", platforms, ""}, // TODO [igni]: Remove this once everything passes // single test for different architecture: linux/arm64