diff --git a/pkg/model/planner.go b/pkg/model/planner.go index 1769b732..089d67d9 100644 --- a/pkg/model/planner.go +++ b/pkg/model/planner.go @@ -328,8 +328,6 @@ func createStages(w *Workflow, jobIDs ...string) ([]*Stage, error) { jobIDs = newJobIDs } - var err error - // next, build an execution graph stages := make([]*Stage, 0) for len(jobDependencies) > 0 { @@ -350,8 +348,8 @@ func createStages(w *Workflow, jobIDs ...string) ([]*Stage, error) { stages = append(stages, stage) } - if len(stages) == 0 && err != nil { - return nil, err + 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 551b7b37..e41f6690 100644 --- a/pkg/model/planner_test.go +++ b/pkg/model/planner_test.go @@ -39,3 +39,25 @@ func TestPlanner(t *testing.T) { } } } + +func TestWorkflow(t *testing.T) { + log.SetLevel(log.DebugLevel) + + workflow := Workflow{ + Jobs: map[string]*Job{ + "valid_job": { + Name: "valid_job", + }, + }, + } + + // 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") + assert.Nil(t, err) + assert.NotNil(t, result) +}