From 3fe4f4fb7fa491854bbdcdd786b8d5cae32f2f0c Mon Sep 17 00:00:00 2001 From: achyrva Date: Wed, 2 Jul 2025 13:53:35 +0000 Subject: [PATCH] [RDNF #16] Fix for issue 2232: Many lines of "Could not find any stages to run" on run (#2272) (#157) https://github.com/nektos/act/pull/2272 * Initial commit * Put the tests back * Remove unnecessary checks * Remove unneeded check and fix test code --------- Co-authored-by: Jason Song Co-authored-by: Andreas Taylor Reviewed-on: https://code.forgejo.org/forgejo/act/pulls/157 Reviewed-by: earl-warren Co-authored-by: achyrva Co-committed-by: achyrva --- act/model/planner.go | 4 ---- act/model/planner_test.go | 9 ++------- cmd/root.go | 5 +++++ 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/act/model/planner.go b/act/model/planner.go index ce0e2bba..71d0ea36 100644 --- a/act/model/planner.go +++ b/act/model/planner.go @@ -387,10 +387,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/act/model/planner_test.go b/act/model/planner_test.go index e41f6690..2857c2c8 100644 --- a/act/model/planner_test.go +++ b/act/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) } diff --git a/cmd/root.go b/cmd/root.go index b135bb56..505d1e7a 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -534,6 +534,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 }