fix: dryrun skip local actions + enable Tests (#1199)
* Update step_action_local.go * Enable Tests for DRYRUN * Update runner_test.go * Update runner_test.go * Move DRYRUN Test in it's own function Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
parent
28f5b37fd1
commit
b7d380b3f0
2 changed files with 36 additions and 0 deletions
|
@ -13,6 +13,7 @@ import (
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
assert "github.com/stretchr/testify/assert"
|
assert "github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
|
"github.com/nektos/act/pkg/common"
|
||||||
"github.com/nektos/act/pkg/model"
|
"github.com/nektos/act/pkg/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -186,6 +187,35 @@ func TestRunEvent(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDryrunEvent(t *testing.T) {
|
||||||
|
if testing.Short() {
|
||||||
|
t.Skip("skipping integration test")
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx := common.WithDryrun(context.Background(), true)
|
||||||
|
|
||||||
|
tables := []TestJobFileInfo{
|
||||||
|
// Shells
|
||||||
|
{workdir, "shells/defaults", "push", "", platforms},
|
||||||
|
{workdir, "shells/pwsh", "push", "", map[string]string{"ubuntu-latest": "ghcr.io/justingrote/act-pwsh:latest"}}, // custom image with pwsh
|
||||||
|
{workdir, "shells/bash", "push", "", platforms},
|
||||||
|
{workdir, "shells/python", "push", "", map[string]string{"ubuntu-latest": "node:16-buster"}}, // slim doesn't have python
|
||||||
|
{workdir, "shells/sh", "push", "", platforms},
|
||||||
|
|
||||||
|
// Local action
|
||||||
|
{workdir, "local-action-docker-url", "push", "", platforms},
|
||||||
|
{workdir, "local-action-dockerfile", "push", "", platforms},
|
||||||
|
{workdir, "local-action-via-composite-dockerfile", "push", "", platforms},
|
||||||
|
{workdir, "local-action-js", "push", "", platforms},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, table := range tables {
|
||||||
|
t.Run(table.workflowPath, func(t *testing.T) {
|
||||||
|
table.runTest(ctx, t, &Config{})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestRunDifferentArchitecture(t *testing.T) {
|
func TestRunDifferentArchitecture(t *testing.T) {
|
||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
t.Skip("skipping integration test")
|
t.Skip("skipping integration test")
|
||||||
|
|
|
@ -28,6 +28,9 @@ func (sal *stepActionLocal) pre() common.Executor {
|
||||||
sal.env = map[string]string{}
|
sal.env = map[string]string{}
|
||||||
|
|
||||||
return func(ctx context.Context) error {
|
return func(ctx context.Context) error {
|
||||||
|
if common.Dryrun(ctx) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
actionDir := filepath.Join(sal.getRunContext().Config.Workdir, sal.Step.Uses)
|
actionDir := filepath.Join(sal.getRunContext().Config.Workdir, sal.Step.Uses)
|
||||||
|
|
||||||
localReader := func(ctx context.Context) actionYamlReader {
|
localReader := func(ctx context.Context) actionYamlReader {
|
||||||
|
@ -65,6 +68,9 @@ func (sal *stepActionLocal) pre() common.Executor {
|
||||||
|
|
||||||
func (sal *stepActionLocal) main() common.Executor {
|
func (sal *stepActionLocal) main() common.Executor {
|
||||||
return runStepExecutor(sal, stepStageMain, func(ctx context.Context) error {
|
return runStepExecutor(sal, stepStageMain, func(ctx context.Context) error {
|
||||||
|
if common.Dryrun(ctx) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
actionDir := filepath.Join(sal.getRunContext().Config.Workdir, sal.Step.Uses)
|
actionDir := filepath.Join(sal.getRunContext().Config.Workdir, sal.Step.Uses)
|
||||||
return sal.runAction(sal, actionDir, nil)(ctx)
|
return sal.runAction(sal, actionDir, nil)(ctx)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue