1
1
mirror of https://github.com/nektos/act.git synced 2024-07-14 15:50:36 +03:00

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

* Initial commit

* Put the tests back

* Remove unnecessary checks

* Remove unneeded check and fix test code

---------

Co-authored-by: Jason Song <i@wolfogre.com>
This commit is contained in:
Andreas Taylor 2024-05-13 10:41:28 -05:00 committed by GitHub
parent 69ef192bc2
commit 657a3d768c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 11 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -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)
}