fix: fail if no stages were found (#1970)
* fix: fail if no stages were found Adds a warning message if act is cannot find any stages to run with the filters provided. Reproduction: - run `act -j gibberish` Desired behavior: some indication I did something silly Actual behavior: no output, just exit with success. As a human who often makes spelling mistakes, it would be nice if act warned me what I was doing that was silly rather than exiting apparently doing nothing with no obvious indication I did something wrong. * Revert "fix: fail if no stages were found" This reverts commit 226adf1c15cf4c01d516a05dc923507e6999978d. * fix: fail if no stages were found Errors if no stages were found with the given filters. Prints out a helpful error message, pointing users in the right place for how to specify which stage to run. Reproduction: - run `act -j gibberish` Desired behavior: some indication I did something silly Actual behavior: no output, just exit with success. As a human who often makes spelling mistakes, it would be nice if act warned me what I was doing that was silly rather than exiting apparently doing nothing with no obvious indication I did something wrong.
This commit is contained in:
parent
f64c267dac
commit
7286b43b0e
2 changed files with 24 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue