diff --git a/cmd/root.go b/cmd/root.go index 44d8cddd..55f339c1 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -479,6 +479,11 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str log.Debugf("Planning jobs for event: %s", eventName) plan, plannerErr = planner.PlanEvent(eventName) } + if plan != nil { + if len(plan.Stages) == 0 { + plannerErr = fmt.Errorf("Could not find any stages to run. View the valid jobs with `act --list`. Use `act --help` to find how to filter by Job ID/Workflow/Event Name") + } + } if plan == nil && plannerErr != nil { return plannerErr } diff --git a/pkg/model/planner.go b/pkg/model/planner.go index 2d681456..7816b67c 100644 --- a/pkg/model/planner.go +++ b/pkg/model/planner.go @@ -389,10 +389,6 @@ func createStages(w *Workflow, jobIDs ...string) ([]*Stage, error) { stages = append(stages, stage) } - if len(stages) == 0 { - return nil, fmt.Errorf("Could not find any stages to run. View the valid jobs with `act --list`. Use `act --help` to find how to filter by Job ID/Workflow/Event Name") - } - return stages, nil } diff --git a/pkg/model/planner_test.go b/pkg/model/planner_test.go index e41f6690..2857c2c8 100644 --- a/pkg/model/planner_test.go +++ b/pkg/model/planner_test.go @@ -51,13 +51,8 @@ func TestWorkflow(t *testing.T) { }, } - // Check that an invalid job id returns error - result, err := createStages(&workflow, "invalid_job_id") - assert.NotNil(t, err) - assert.Nil(t, result) - - // Check that an valid job id returns non-error - result, err = createStages(&workflow, "valid_job") + // Check that a valid job id returns non-error + result, err := createStages(&workflow, "valid_job") assert.Nil(t, err) assert.NotNil(t, result) }