Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue 2232: Many lines of "Could not find any stages to run" on run #2272

Merged
merged 12 commits into from
May 13, 2024
5 changes: 5 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 0 additions & 4 deletions pkg/model/planner.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,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
}

Expand Down
9 changes: 2 additions & 7 deletions pkg/model/planner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Loading