Skip to content

Commit

Permalink
align name of job in output
Browse files Browse the repository at this point in the history
  • Loading branch information
Unit Test committed Feb 17, 2020
1 parent 299cdd6 commit d0ffd80
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package runner

import (
"context"
"fmt"
"io/ioutil"

"github.com/nektos/act/pkg/common"
Expand Down Expand Up @@ -49,6 +50,16 @@ func New(runnerConfig *Config) (Runner, error) {
}

func (runner *runnerImpl) NewPlanExecutor(plan *model.Plan) common.Executor {
maxJobNameLen := 0
for _, stage := range plan.Stages {
for _, run := range stage.Runs {
jobNameLen := len(run.String())
if jobNameLen > maxJobNameLen {
maxJobNameLen = jobNameLen
}
}
}

pipeline := make([]common.Executor, 0)
for _, stage := range plan.Stages {
stageExecutor := make([]common.Executor, 0)
Expand Down Expand Up @@ -93,8 +104,17 @@ func (runner *runnerImpl) NewPlanExecutor(plan *model.Plan) common.Executor {
matrixes = append(matrixes, make(map[string]interface{}))
}

jobName := fmt.Sprintf("%-*s", maxJobNameLen, run.String())
for _, matrix := range matrixes {
stageExecutor = append(stageExecutor, runner.NewRunExecutor(run, matrix))
m := matrix
runExecutor := runner.NewRunExecutor(run, matrix)
stageExecutor = append(stageExecutor, func(ctx context.Context) error {
ctx = WithJobLogger(ctx, jobName)
if len(m) > 0 {
common.Logger(ctx).Infof("\U0001F9EA Matrix: %v", m)
}
return runExecutor(ctx)
})
}
}
pipeline = append(pipeline, common.NewParallelExecutor(stageExecutor...))
Expand All @@ -120,11 +140,5 @@ func (runner *runnerImpl) NewRunExecutor(run *model.Run, matrix map[string]inter
rc.StepResults = make(map[string]*stepResult)
rc.Matrix = matrix
rc.ExprEval = rc.NewExpressionEvaluator()
return func(ctx context.Context) error {
ctx = WithJobLogger(ctx, rc.Run.String())
if len(rc.Matrix) > 0 {
common.Logger(ctx).Infof("\U0001F9EA Matrix: %v", rc.Matrix)
}
return rc.Executor()(ctx)
}
return rc.Executor()
}

0 comments on commit d0ffd80

Please sign in to comment.