nolint:contextcheck
(info jobInfo, sf stepFactory, rc *RunContext)
| 21 | |
| 22 | //nolint:contextcheck |
| 23 | func newJobExecutor(info jobInfo, sf stepFactory, rc *RunContext) common.Executor { |
| 24 | steps := make([]common.Executor, 0) |
| 25 | preSteps := make([]common.Executor, 0) |
| 26 | var postExecutor common.Executor |
| 27 | |
| 28 | steps = append(steps, func(ctx context.Context) error { |
| 29 | logger := common.Logger(ctx) |
| 30 | if len(info.matrix()) > 0 { |
| 31 | logger.Infof("\U0001F9EA Matrix: %v", info.matrix()) |
| 32 | } |
| 33 | return nil |
| 34 | }) |
| 35 | |
| 36 | infoSteps := info.steps() |
| 37 | |
| 38 | if len(infoSteps) == 0 { |
| 39 | return common.NewDebugExecutor("No steps found") |
| 40 | } |
| 41 | |
| 42 | preSteps = append(preSteps, func(ctx context.Context) error { |
| 43 | // Have to be skipped for some Tests |
| 44 | if rc.Run == nil { |
| 45 | return nil |
| 46 | } |
| 47 | rc.ExprEval = rc.NewExpressionEvaluator(ctx) |
| 48 | // evaluate environment variables since they can contain |
| 49 | // GitHub's special environment variables. |
| 50 | for k, v := range rc.GetEnv() { |
| 51 | rc.Env[k] = rc.ExprEval.Interpolate(ctx, v) |
| 52 | } |
| 53 | return nil |
| 54 | }) |
| 55 | |
| 56 | var setJobError = func(ctx context.Context, err error) error { |
| 57 | if err == nil { |
| 58 | return nil |
| 59 | } |
| 60 | logger := common.Logger(ctx) |
| 61 | logger.Errorf("%v", err) |
| 62 | common.SetJobError(ctx, err) |
| 63 | return err |
| 64 | } |
| 65 | |
| 66 | for i, stepModel := range infoSteps { |
| 67 | if stepModel == nil { |
| 68 | return func(_ context.Context) error { |
| 69 | return fmt.Errorf("invalid Step %v: missing run or uses key", i) |
| 70 | } |
| 71 | } |
| 72 | if stepModel.ID == "" { |
| 73 | stepModel.ID = fmt.Sprintf("%d", i) |
| 74 | } |
| 75 | |
| 76 | step, err := sf.newStep(stepModel, rc) |
| 77 | |
| 78 | if err != nil { |
| 79 | return common.NewErrorExecutor(err) |
| 80 | } |
searching dependent graphs…