MCPcopy
hub / github.com/go-task/task / Run

Method Run

task.go:42–109  ·  view source on GitHub ↗

Run runs Task

(ctx context.Context, calls ...*Call)

Source from the content-addressed store, hash-verified

40
41// Run runs Task
42func (e *Executor) Run(ctx context.Context, calls ...*Call) error {
43 // check if given tasks exist
44 for _, call := range calls {
45 task, err := e.GetTask(call)
46 if err != nil {
47 if _, ok := err.(*errors.TaskNotFoundError); ok {
48 if _, err := e.ListTasks(ListOptions{ListOnlyTasksWithDescriptions: true}); err != nil {
49 return err
50 }
51 }
52 return err
53 }
54
55 if task.Internal {
56 if _, ok := err.(*errors.TaskNotFoundError); ok {
57 if _, err := e.ListTasks(ListOptions{ListOnlyTasksWithDescriptions: true}); err != nil {
58 return err
59 }
60 }
61 return &errors.TaskInternalError{TaskName: call.Task}
62 }
63 }
64
65 if e.Summary {
66 for i, c := range calls {
67 compiledTask, err := e.FastCompiledTask(c)
68 if err != nil {
69 return nil
70 }
71 summary.PrintSpaceBetweenSummaries(e.Logger, i)
72 summary.PrintTask(e.Logger, compiledTask)
73 }
74 return nil
75 }
76
77 // Prompt for all required vars from deps upfront (parallel execution)
78 if err := e.promptDepsVars(calls); err != nil {
79 return err
80 }
81
82 regularCalls, watchCalls, err := e.splitRegularAndWatchCalls(calls...)
83 if err != nil {
84 return err
85 }
86
87 g := &errgroup.Group{}
88 if e.Failfast {
89 g, ctx = errgroup.WithContext(ctx)
90 }
91 for _, c := range regularCalls {
92 if e.Parallel {
93 g.Go(func() error { return e.RunTask(ctx, c) })
94 } else {
95 if err := e.RunTask(ctx, c); err != nil {
96 return err
97 }
98 }
99 }

Callers 15

runMethod · 0.95
TestFileWatchFunction · 0.95
RunMethod · 0.95
TestGeneratesFunction · 0.95
TestStatusChecksumFunction · 0.95
TestStatusTimestampFunction · 0.95
TestStatusVariablesFunction · 0.95
TestCmdsVariablesFunction · 0.95
TestCyclicDepFunction · 0.95
TestTaskIgnoreErrorsFunction · 0.95
TestExpandFunction · 0.95

Calls 9

GetTaskMethod · 0.95
ListTasksMethod · 0.95
FastCompiledTaskMethod · 0.95
promptDepsVarsMethod · 0.95
RunTaskMethod · 0.95
watchTasksMethod · 0.95
PrintTaskFunction · 0.92

Tested by 15

runMethod · 0.76
TestFileWatchFunction · 0.76
RunMethod · 0.76
TestGeneratesFunction · 0.76
TestStatusChecksumFunction · 0.76
TestStatusTimestampFunction · 0.76
TestStatusVariablesFunction · 0.76
TestCmdsVariablesFunction · 0.76
TestCyclicDepFunction · 0.76
TestTaskIgnoreErrorsFunction · 0.76
TestExpandFunction · 0.76