mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-03-22 06:45:03 +01:00
fmt
This commit is contained in:
@@ -216,7 +216,6 @@ func execAsDocker(ctx context.Context, step actionStep, actionName, subpath stri
|
||||
if len(entrypoint) == 0 {
|
||||
if entrypointType == "pre-entrypoint" && action.Runs.PreEntrypoint != "" {
|
||||
entrypoint, err = shellquote.Split(action.Runs.PreEntrypoint)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -9,8 +9,10 @@ import (
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var commandPatternGA *regexp.Regexp
|
||||
var commandPatternADO *regexp.Regexp
|
||||
var (
|
||||
commandPatternGA *regexp.Regexp
|
||||
commandPatternADO *regexp.Regexp
|
||||
)
|
||||
|
||||
func init() {
|
||||
commandPatternGA = regexp.MustCompile("^::([^ ]+)( (.+))?::([^\r\n]*)[\r\n]+$")
|
||||
@@ -102,6 +104,7 @@ func (rc *RunContext) setEnv(ctx context.Context, kvPairs map[string]string, arg
|
||||
mergeIntoMap(rc.Env, newenv)
|
||||
mergeIntoMap(rc.GlobalEnv, newenv)
|
||||
}
|
||||
|
||||
func (rc *RunContext) setOutput(ctx context.Context, kvPairs map[string]string, arg string) {
|
||||
logger := common.Logger(ctx)
|
||||
stepID := rc.CurrentStep
|
||||
@@ -120,6 +123,7 @@ func (rc *RunContext) setOutput(ctx context.Context, kvPairs map[string]string,
|
||||
logger.WithFields(logrus.Fields{"command": "set-output", "name": outputName, "arg": arg}).Infof(" \U00002699 ::set-output:: %s=%s", outputName, arg)
|
||||
result.Outputs[outputName] = arg
|
||||
}
|
||||
|
||||
func (rc *RunContext) addPath(ctx context.Context, arg string) {
|
||||
common.Logger(ctx).WithFields(logrus.Fields{"command": "add-path", "arg": arg}).Infof(" \U00002699 ::add-path:: %s", arg)
|
||||
extraPath := []string{arg}
|
||||
@@ -142,6 +146,7 @@ func parseKeyValuePairs(kvPairs string, separator string) map[string]string {
|
||||
}
|
||||
return rtn
|
||||
}
|
||||
|
||||
func unescapeCommandData(arg string) string {
|
||||
escapeMap := map[string]string{
|
||||
"%25": "%",
|
||||
@@ -153,6 +158,7 @@ func unescapeCommandData(arg string) string {
|
||||
}
|
||||
return arg
|
||||
}
|
||||
|
||||
func unescapeCommandProperty(arg string) string {
|
||||
escapeMap := map[string]string{
|
||||
"%25": "%",
|
||||
@@ -166,6 +172,7 @@ func unescapeCommandProperty(arg string) string {
|
||||
}
|
||||
return arg
|
||||
}
|
||||
|
||||
func unescapeKvPairs(kvPairs map[string]string) map[string]string {
|
||||
for k, v := range kvPairs {
|
||||
kvPairs[k] = unescapeCommandProperty(v)
|
||||
|
||||
@@ -276,7 +276,8 @@ func TestInterpolate(t *testing.T) {
|
||||
func updateTestExpressionWorkflow(t *testing.T, tables []struct {
|
||||
in string
|
||||
out string
|
||||
}, rc *RunContext) {
|
||||
}, rc *RunContext,
|
||||
) {
|
||||
var envs string
|
||||
keys := make([]string, 0, len(rc.Env))
|
||||
for k := range rc.Env {
|
||||
|
||||
@@ -54,7 +54,7 @@ func newJobExecutor(info jobInfo, sf stepFactory, rc *RunContext) common.Executo
|
||||
return nil
|
||||
})
|
||||
|
||||
var setJobError = func(ctx context.Context, err error) error {
|
||||
setJobError := func(ctx context.Context, err error) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -75,7 +75,6 @@ func newJobExecutor(info jobInfo, sf stepFactory, rc *RunContext) common.Executo
|
||||
}
|
||||
|
||||
step, err := sf.newStep(stepModel, rc)
|
||||
|
||||
if err != nil {
|
||||
return common.NewErrorExecutor(err)
|
||||
}
|
||||
|
||||
@@ -26,9 +26,11 @@ const (
|
||||
gray = 37
|
||||
)
|
||||
|
||||
var colors []int
|
||||
var nextColor int
|
||||
var mux sync.Mutex
|
||||
var (
|
||||
colors []int
|
||||
nextColor int
|
||||
mux sync.Mutex
|
||||
)
|
||||
|
||||
func init() {
|
||||
nextColor = 0
|
||||
|
||||
@@ -757,7 +757,7 @@ func (rc *RunContext) steps() []*model.Step {
|
||||
// Executor returns a pipeline executor for all the steps in the job
|
||||
func (rc *RunContext) Executor() (common.Executor, error) {
|
||||
var executor common.Executor
|
||||
var jobType, err = rc.Run.Job().Type()
|
||||
jobType, err := rc.Run.Job().Type()
|
||||
|
||||
if exec, ok := rc.Config.CustomExecutor[jobType]; ok {
|
||||
executor = exec(rc)
|
||||
|
||||
@@ -172,7 +172,8 @@ func updateTestIfWorkflow(t *testing.T, tables []struct {
|
||||
in string
|
||||
out bool
|
||||
wantErr bool
|
||||
}, rc *RunContext) {
|
||||
}, rc *RunContext,
|
||||
) {
|
||||
var envs string
|
||||
keys := make([]string, 0, len(rc.Env))
|
||||
for k := range rc.Env {
|
||||
|
||||
@@ -84,6 +84,7 @@ func (runnerConfig *Config) GetGitHubServerURL() string {
|
||||
}
|
||||
return "https://" + runnerConfig.GitHubInstance
|
||||
}
|
||||
|
||||
func (runnerConfig *Config) GetGitHubAPIServerURL() string {
|
||||
if len(runnerConfig.GitHubAPIServerURL) > 0 {
|
||||
return runnerConfig.GitHubAPIServerURL
|
||||
@@ -93,6 +94,7 @@ func (runnerConfig *Config) GetGitHubAPIServerURL() string {
|
||||
}
|
||||
return fmt.Sprintf("https://%s/api/v3", runnerConfig.GitHubInstance)
|
||||
}
|
||||
|
||||
func (runnerConfig *Config) GetGitHubGraphQlAPIServerURL() string {
|
||||
if len(runnerConfig.GitHubGraphQlAPIServerURL) > 0 {
|
||||
return runnerConfig.GitHubGraphQlAPIServerURL
|
||||
@@ -102,6 +104,7 @@ func (runnerConfig *Config) GetGitHubGraphQlAPIServerURL() string {
|
||||
}
|
||||
return fmt.Sprintf("https://%s/api/graphql", runnerConfig.GitHubInstance)
|
||||
}
|
||||
|
||||
func (runnerConfig *Config) GetGitHubInstance() string {
|
||||
if len(runnerConfig.GitHubServerURL) > 0 {
|
||||
regex := regexp.MustCompile("^https?://(.*)$")
|
||||
@@ -234,7 +237,6 @@ func (runner *runnerImpl) NewPlanExecutor(plan *model.Plan) common.Executor {
|
||||
stageExecutor = append(stageExecutor, func(ctx context.Context) error {
|
||||
jobName := fmt.Sprintf("%-*s", maxJobNameLen, rc.String())
|
||||
executor, err := rc.Executor()
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -453,8 +453,7 @@ func TestPullAndPostStepFailureIsJobFailure(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
type mockCache struct {
|
||||
}
|
||||
type mockCache struct{}
|
||||
|
||||
func (c mockCache) Fetch(ctx context.Context, cacheDir string, url string, ref string, token string) (string, error) {
|
||||
_ = ctx
|
||||
@@ -464,6 +463,7 @@ func (c mockCache) Fetch(ctx context.Context, cacheDir string, url string, ref s
|
||||
_ = token
|
||||
return "", errors.New("fetch failure")
|
||||
}
|
||||
|
||||
func (c mockCache) GetTarArchive(ctx context.Context, cacheDir string, sha string, includePrefix string) (io.ReadCloser, error) {
|
||||
_ = ctx
|
||||
_ = cacheDir
|
||||
|
||||
@@ -164,7 +164,7 @@ func runStepExecutor(step step, stage stepStage, executor common.Executor) commo
|
||||
Mode: 0o666,
|
||||
}, &container.FileEntry{
|
||||
Name: envFileCommand,
|
||||
Mode: 0666,
|
||||
Mode: 0o666,
|
||||
}, &container.FileEntry{
|
||||
Name: summaryFileCommand,
|
||||
Mode: 0o666,
|
||||
|
||||
@@ -85,9 +85,7 @@ func (sd *stepDocker) runUsesContainer() common.Executor {
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
ContainerNewContainer = container.NewContainer
|
||||
)
|
||||
var ContainerNewContainer = container.NewContainer
|
||||
|
||||
func (sd *stepDocker) newStepContainer(ctx context.Context, image string, cmd []string, entrypoint []string) container.Container {
|
||||
rc := sd.RunContext
|
||||
|
||||
Reference in New Issue
Block a user