plan: raise error on cyclic task + cue error formatting

Signed-off-by: Sam Alba <samalba@users.noreply.github.com>
This commit is contained in:
Sam Alba 2022-03-09 16:26:39 -08:00
parent e4f284c4ea
commit c5660995f5
2 changed files with 7 additions and 6 deletions

View File

@ -1,4 +0,0 @@
# generated by dagger
dagger.lock
dagger.io
universe.dagger.io

View File

@ -107,6 +107,11 @@ func (r *Runner) initTasks() {
}
func (r *Runner) addTask(t *cueflow.Task) {
// avoid circular dependencies
if _, ok := r.tasks.Load(t.Path().String()); ok {
return
}
r.tasks.Store(t.Path().String(), struct{}{})
for _, dep := range t.Dependencies() {
@ -156,9 +161,9 @@ func (r *Runner) taskFunc(flowVal cue.Value) (cueflow.Runner, error) {
if strings.Contains(err.Error(), "context canceled") {
lg.Error().Dur("duration", time.Since(start)).Str("state", string(task.StateCanceled)).Msg(string(task.StateCanceled))
} else {
lg.Error().Dur("duration", time.Since(start)).Err(err).Str("state", string(task.StateFailed)).Msg(string(task.StateFailed))
lg.Error().Dur("duration", time.Since(start)).Err(compiler.Err(err)).Str("state", string(task.StateFailed)).Msg(string(task.StateFailed))
}
return fmt.Errorf("%s: %w", t.Path().String(), err)
return fmt.Errorf("%s: %w", t.Path().String(), compiler.Err(err))
}
lg.Info().Dur("duration", time.Since(start)).Str("state", string(task.StateCompleted)).Msg(string(task.StateCompleted))