diff --git a/plan/plan.go b/plan/plan.go index 6090554c..662ec07c 100644 --- a/plan/plan.go +++ b/plan/plan.go @@ -175,17 +175,19 @@ func (p *Plan) fillAction() { noOpRunner, ) - actions := p.source.LookupPath(cue.MakePath(ActionSelector)) - actionsComment := "" - for _, cg := range actions.Doc() { - actionsComment += cg.Text() - } p.action = &Action{ - ActionSelector.String(), - false, - actions.Path(), - actionsComment, - []*Action{}, + Name: ActionSelector.String(), + Hidden: false, + Path: cue.MakePath(ActionSelector), + Children: []*Action{}, + } + + actions := p.source.LookupPath(cue.MakePath(ActionSelector)) + if actions.Exists() { + return + } + for _, cg := range actions.Doc() { + p.action.Comment += cg.Text() } tasks := flow.Tasks() @@ -205,11 +207,11 @@ func (p *Plan) fillAction() { } a = &Action{ - s.String(), - s.PkgPath() != "", - path, - childComment, - []*Action{}, + Name: s.String(), + Hidden: s.PkgPath() != "", + Path: path, + Comment: childComment, + Children: []*Action{}, } prevAction.AddChild(a) } diff --git a/plan/runner.go b/plan/runner.go index 928a0b2d..71308851 100644 --- a/plan/runner.go +++ b/plan/runner.go @@ -38,6 +38,10 @@ func NewRunner(pctx *plancontext.Context, target cue.Path, s solver.Solver) *Run } func (r *Runner) Run(ctx context.Context, src *compiler.Value) error { + if !src.LookupPath(r.target).Exists() { + return fmt.Errorf("%s not found", r.target.String()) + } + if err := r.update(cue.MakePath(), src); err != nil { return err } diff --git a/tests/plan.bats b/tests/plan.bats index 72e9efb5..bc5d5e04 100644 --- a/tests/plan.bats +++ b/tests/plan.bats @@ -4,7 +4,13 @@ setup() { common_setup } -@test "plan/do dynamic tasks - fails to find tasks" { +@test "plan/do: action sanity checks" { + run "$DAGGER" "do" -p ./plan/do/actions.cue not exist + assert_failure + assert_output --partial "not found" +} + +@test "plan/do: dynamic tasks - fails to find tasks" { # Europa loader handles the cwd differently, therefore we need to CD into the tree at or below the parent of cue.mod cd "$TESTDIR" run "$DAGGER" "do" -p ./plan/do/dynamic_tasks.cue test b @@ -12,12 +18,12 @@ setup() { refute_output --partial "actions.test.b" } -@test "plan/do dynamic tasks - fails to run tasks" { +@test "plan/do: dynamic tasks - fails to run tasks" { run "$DAGGER" "do" -p ./plan/do/dynamic_tasks.cue "test" refute_output --partial 'actions.test.b.y' } -@test "plan/do don't run unspecified tasks" { +@test "plan/do: don't run unspecified tasks" { run "$DAGGER" "do" -p ./plan/do/do_not_run_unspecified_tasks.cue test assert_output --partial "actions.test.one.script" assert_output --partial "actions.test.three.script" @@ -32,7 +38,6 @@ setup() { refute_output --partial 'client.filesystem."./dependent_do".write' } - @test "plan/hello" { # Europa loader handles the cwd differently, therefore we need to CD into the tree at or below the parent of cue.mod cd "$TESTDIR"