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:
silverwind
2026-08-24 17:03:45 +00:00
committed by silverwind
parent e78123cee3
commit 7b4356c746
2 changed files with 19 additions and 1 deletions
+18
View File
@@ -8,6 +8,7 @@ import (
"gitea.dev/actionslib/pkg/model"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"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:")
}
+1 -1
View File
@@ -207,7 +207,7 @@ func (runner *runnerImpl) NewPlanExecutor(plan *model.Plan) common.Executor {
matrixes, err := job.GetMatrixes()
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)