mirror of
https://gitea.com/gitea/runner.git
synced 2026-08-30 15:57:44 +00:00
fix: fail the run when matrix expansion fails (#1187)
A `GetMatrixes` error was logged and discarded, leaving a nil matrix list. That collapsed `maxParallel` to zero, so no executor was built and the parallel executor returned nil for an empty list: the job reported success without running anything. It now fails the run. Every error it returns is a workflow validation failure that GitHub rejects too, so nothing that runs there starts failing here. Reviewed-on: https://gitea.com/gitea/runner/pulls/1187 Reviewed-by: bircni <bircni@icloud.com> Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
|||||||
|
|
||||||
"gitea.dev/actionslib/pkg/model"
|
"gitea.dev/actionslib/pkg/model"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
"go.yaml.in/yaml/v4"
|
"go.yaml.in/yaml/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -64,3 +65,20 @@ func TestMaxParallelStrategy(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNewPlanExecutorInvalidMatrix(t *testing.T) {
|
||||||
|
var rawMatrix yaml.Node
|
||||||
|
require.NoError(t, rawMatrix.Encode(map[string]any{
|
||||||
|
"config": map[string]any{"nested": "value"},
|
||||||
|
}))
|
||||||
|
|
||||||
|
plan := &model.Plan{Stages: []*model.Stage{{Runs: []*model.Run{{
|
||||||
|
Workflow: &model.Workflow{Jobs: map[string]*model.Job{
|
||||||
|
"test": {Strategy: &model.Strategy{RawMatrix: rawMatrix}},
|
||||||
|
}},
|
||||||
|
JobID: "test",
|
||||||
|
}}}}}
|
||||||
|
runner := &runnerImpl{config: &Config{}}
|
||||||
|
|
||||||
|
require.ErrorContains(t, runner.NewPlanExecutor(plan)(t.Context()), "could not get job matrix:")
|
||||||
|
}
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ func (runner *runnerImpl) NewPlanExecutor(plan *model.Plan) common.Executor {
|
|||||||
|
|
||||||
matrixes, err := job.GetMatrixes()
|
matrixes, err := job.GetMatrixes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Error while get job's matrix: %v", err)
|
return fmt.Errorf("could not get job matrix: %w", err)
|
||||||
}
|
}
|
||||||
log.Debugf("Job Matrices: %v", matrixes)
|
log.Debugf("Job Matrices: %v", matrixes)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user