chore: use new style octal (#1630)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
Jason Song
2023-02-16 23:34:51 +08:00
committed by GitHub
parent b0a5068f6d
commit 1316307313
12 changed files with 35 additions and 30 deletions

View File

@@ -14,6 +14,7 @@ import (
"strings"
"github.com/kballard/go-shellquote"
"github.com/nektos/act/pkg/common"
"github.com/nektos/act/pkg/container"
"github.com/nektos/act/pkg/model"
@@ -30,6 +31,7 @@ type actionStep interface {
type readAction func(ctx context.Context, step *model.Step, actionDir string, actionPath string, readFile actionYamlReader, writeFile fileWriter) (*model.Action, error)
type actionYamlReader func(filename string) (io.Reader, io.Closer, error)
type fileWriter func(filename string, data []byte, perm fs.FileMode) error
type runAction func(step actionStep, actionDir string, remoteAction *remoteAction) common.Executor
@@ -61,7 +63,7 @@ func readActionImpl(ctx context.Context, step *model.Step, actionDir string, act
if b, err = trampoline.ReadFile("res/trampoline.js"); err != nil {
return nil, err
}
err2 := writeFile(filepath.Join(actionDir, actionPath, "trampoline.js"), b, 0400)
err2 := writeFile(filepath.Join(actionDir, actionPath, "trampoline.js"), b, 0o400)
if err2 != nil {
return nil, err2
}

View File

@@ -156,15 +156,15 @@ func (rc *RunContext) startHostEnvironment() common.Executor {
_, _ = rand.Read(randBytes)
miscpath := filepath.Join(cacheDir, hex.EncodeToString(randBytes))
actPath := filepath.Join(miscpath, "act")
if err := os.MkdirAll(actPath, 0777); err != nil {
if err := os.MkdirAll(actPath, 0o777); err != nil {
return err
}
path := filepath.Join(miscpath, "hostexecutor")
if err := os.MkdirAll(path, 0777); err != nil {
if err := os.MkdirAll(path, 0o777); err != nil {
return err
}
runnerTmp := filepath.Join(miscpath, "tmp")
if err := os.MkdirAll(runnerTmp, 0777); err != nil {
if err := os.MkdirAll(runnerTmp, 0o777); err != nil {
return err
}
toolCache := filepath.Join(cacheDir, "tool_cache")
@@ -197,11 +197,11 @@ func (rc *RunContext) startHostEnvironment() common.Executor {
return common.NewPipelineExecutor(
rc.JobContainer.Copy(rc.JobContainer.GetActPath()+"/", &container.FileEntry{
Name: "workflow/event.json",
Mode: 0644,
Mode: 0o644,
Body: rc.EventJSON,
}, &container.FileEntry{
Name: "workflow/envs.txt",
Mode: 0666,
Mode: 0o666,
Body: "",
}),
)(ctx)
@@ -280,11 +280,11 @@ func (rc *RunContext) startJobContainer() common.Executor {
rc.JobContainer.Start(false),
rc.JobContainer.Copy(rc.JobContainer.GetActPath()+"/", &container.FileEntry{
Name: "workflow/event.json",
Mode: 0644,
Mode: 0o644,
Body: rc.EventJSON,
}, &container.FileEntry{
Name: "workflow/envs.txt",
Mode: 0666,
Mode: 0o666,
Body: "",
}),
)(ctx)

View File

@@ -111,16 +111,16 @@ func runStepExecutor(step step, stage stepStage, executor common.Executor) commo
(*step.getEnv())["GITHUB_ENV"] = path.Join(actPath, envFileCommand)
_ = rc.JobContainer.Copy(actPath, &container.FileEntry{
Name: outputFileCommand,
Mode: 0666,
Mode: 0o666,
}, &container.FileEntry{
Name: stateFileCommand,
Mode: 0666,
Mode: 0o666,
}, &container.FileEntry{
Name: pathFileCommand,
Mode: 0666,
Mode: 0o666,
}, &container.FileEntry{
Name: envFileCommand,
Mode: 0666,
Mode: 0o666,
})(ctx)
err = executor(ctx)

View File

@@ -6,6 +6,7 @@ import (
"strings"
"github.com/kballard/go-shellquote"
"github.com/nektos/act/pkg/common"
"github.com/nektos/act/pkg/container"
"github.com/nektos/act/pkg/model"
@@ -72,7 +73,7 @@ func (sr *stepRun) setupShellCommandExecutor() common.Executor {
rc := sr.getRunContext()
return rc.JobContainer.Copy(rc.JobContainer.GetActPath(), &container.FileEntry{
Name: scriptName,
Mode: 0755,
Mode: 0o755,
Body: script,
})(ctx)
}

View File

@@ -6,17 +6,18 @@ import (
"io"
"testing"
"github.com/nektos/act/pkg/container"
"github.com/nektos/act/pkg/model"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/nektos/act/pkg/container"
"github.com/nektos/act/pkg/model"
)
func TestStepRun(t *testing.T) {
cm := &containerMock{}
fileEntry := &container.FileEntry{
Name: "workflow/1.sh",
Mode: 0755,
Mode: 0o755,
Body: "\ncmd\n",
}