Hotfix: Skip Checkout Regression (#680)
* Fix: Skip Checkout Regression * Fix test name * Add newline to end of checkout push test * Restore .gitignore from node12 test. Todo: Restore that file after the test * Format workflow * Test: Fix path slash direction for windows relative source path * Add explicit nil test for newRemoteAction * Regress .secrets during tests Co-authored-by: Ryan (hackercat) <me@hackerc.at>
This commit is contained in:
parent
aa68181f6b
commit
ef0da2ab9e
|
@ -579,7 +579,7 @@ func (rc *RunContext) getGithubContext() *githubContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ghc *githubContext) isLocalCheckout(step *model.Step) bool {
|
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
|
// This will be errored out by the executor later, we need this here to avoid a null panic though
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -587,6 +587,10 @@ func (ghc *githubContext) isLocalCheckout(step *model.Step) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
remoteAction := newRemoteAction(step.Uses)
|
remoteAction := newRemoteAction(step.Uses)
|
||||||
|
if remoteAction == nil {
|
||||||
|
// IsCheckout() will nil panic if we dont bail out early
|
||||||
|
return false
|
||||||
|
}
|
||||||
if !remoteAction.IsCheckout() {
|
if !remoteAction.IsCheckout() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ type TestJobFileInfo struct {
|
||||||
containerArchitecture string
|
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) {
|
t.Run(tjfi.workflowPath, func(t *testing.T) {
|
||||||
workdir, err := filepath.Abs(tjfi.workdir)
|
workdir, err := filepath.Abs(tjfi.workdir)
|
||||||
assert.NilError(t, err, workdir)
|
assert.NilError(t, err, workdir)
|
||||||
|
@ -55,7 +55,6 @@ func runTestJobFile(ctx context.Context, t *testing.T, tjfi TestJobFileInfo, sec
|
||||||
Platforms: tjfi.platforms,
|
Platforms: tjfi.platforms,
|
||||||
ReuseContainers: false,
|
ReuseContainers: false,
|
||||||
ContainerArchitecture: tjfi.containerArchitecture,
|
ContainerArchitecture: tjfi.containerArchitecture,
|
||||||
Secrets: secrets,
|
|
||||||
GitHubInstance: "github.com",
|
GitHubInstance: "github.com",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,6 +88,7 @@ func TestRunEvent(t *testing.T) {
|
||||||
{"testdata", "basic", "push", "", platforms, ""},
|
{"testdata", "basic", "push", "", platforms, ""},
|
||||||
{"testdata", "fail", "push", "exit with `FAILURE`: 1", platforms, ""},
|
{"testdata", "fail", "push", "exit with `FAILURE`: 1", platforms, ""},
|
||||||
{"testdata", "runs-on", "push", "", 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
|
// 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", "powershell", "push", "", map[string]string{"ubuntu-latest": "ghcr.io/justingrote/act-pwsh:latest"}, ""},
|
||||||
{"testdata", "job-container", "push", "", platforms, ""},
|
{"testdata", "job-container", "push", "", platforms, ""},
|
||||||
|
@ -116,11 +116,9 @@ func TestRunEvent(t *testing.T) {
|
||||||
log.SetLevel(log.DebugLevel)
|
log.SetLevel(log.DebugLevel)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
secretspath, _ := filepath.Abs("../../.secrets")
|
|
||||||
secrets, _ := godotenv.Read(secretspath)
|
|
||||||
|
|
||||||
for _, table := range tables {
|
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{
|
for _, v := range []containerPathJob{
|
||||||
{"/mnt/c/Users/act/go/src/github.com/nektos/act", "C:\\Users\\act\\go\\src\\github.com\\nektos\\act\\", ""},
|
{"/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/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)},
|
{fmt.Sprintf("/mnt/%v/act", rootDriveLetter), "act", fmt.Sprintf("%s\\", rootDrive)},
|
||||||
} {
|
} {
|
||||||
if v.workDir != "" {
|
if v.workDir != "" {
|
||||||
|
|
|
@ -77,7 +77,7 @@ func (sc *StepContext) Executor() common.Executor {
|
||||||
github := rc.getGithubContext()
|
github := rc.getGithubContext()
|
||||||
if remoteAction.IsCheckout() && github.isLocalCheckout(step) {
|
if remoteAction.IsCheckout() && github.isLocalCheckout(step) {
|
||||||
return func(ctx context.Context) error {
|
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
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,8 @@ package runner
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"path/filepath"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/joho/godotenv"
|
|
||||||
"github.com/nektos/act/pkg/common"
|
"github.com/nektos/act/pkg/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -25,8 +23,7 @@ func TestStepContextExecutor(t *testing.T) {
|
||||||
}
|
}
|
||||||
// These tests are sufficient to only check syntax.
|
// These tests are sufficient to only check syntax.
|
||||||
ctx := common.WithDryrun(context.Background(), true)
|
ctx := common.WithDryrun(context.Background(), true)
|
||||||
secrets, _ := godotenv.Read(filepath.Join("..", ".secrets"))
|
|
||||||
for _, table := range tables {
|
for _, table := range tables {
|
||||||
runTestJobFile(ctx, t, table, secrets)
|
runTestJobFile(ctx, t, table)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
name: checkout
|
||||||
|
on: push
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
checkout:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
Loading…
Reference in New Issue