From 7b4356c746f6934fa91d349c0a19bd523ae1b74e Mon Sep 17 00:00:00 2001 From: silverwind Date: Mon, 24 Aug 2026 17:03:45 +0000 Subject: [PATCH] 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 Co-authored-by: silverwind --- act/runner/max_parallel_test.go | 18 ++++++++++++++++++ act/runner/runner.go | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/act/runner/max_parallel_test.go b/act/runner/max_parallel_test.go index b0578867..afa4b455 100644 --- a/act/runner/max_parallel_test.go +++ b/act/runner/max_parallel_test.go @@ -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:") +} diff --git a/act/runner/runner.go b/act/runner/runner.go index 08919d1e..e61f93d8 100644 --- a/act/runner/runner.go +++ b/act/runner/runner.go @@ -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)