Files
act_runner/act/runner/max_parallel_test.go
Lunny Xiao a9d47fb5ed refactor: move act/model and act/exprparser to actions-proto-go
Gitea needs the workflow model and the expression evaluator to parse
workflows and to build the task payload this runner consumes, so it had
to depend on gitea.com/gitea/runner for it. Both packages now live in
gitea.dev/actions-proto-go, the module both sides already share, and this
repository consumes them from there.

The GithubContext helpers that need a git checkout on disk (SetRef,
SetSha and SetRepositoryAndOwner) are not moved: they are runner only and
would drag a git client and the act context logger into the shared
module. They become functions of the new act/ghcontext package, together
with their tests.

act/common.CartesianProduct moved to the shared model package as well,
act/model was its only user. act/model/testdata/container-volumes is now
act/runner/testdata/container-volumes, its only user is runner_test.go.

The x-runner-uuid and x-runner-token header names come from
actions-proto-go too, so the runner and Gitea cannot drift apart.

Signed-off-by: Lunny Xiao <xiaolunwen@gmail.com>
2026-08-03 17:53:08 -07:00

67 lines
1.5 KiB
Go

// Copyright 2026 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package runner
import (
"testing"
"gitea.dev/actions-proto-go/pkg/model"
"github.com/stretchr/testify/assert"
"go.yaml.in/yaml/v4"
)
func TestMaxParallelStrategy(t *testing.T) {
tests := []struct {
name string
maxParallelString string
expectedMaxParallel int
}{
{
name: "max-parallel-1",
maxParallelString: "1",
expectedMaxParallel: 1,
},
{
name: "max-parallel-2",
maxParallelString: "2",
expectedMaxParallel: 2,
},
{
name: "max-parallel-default",
maxParallelString: "",
expectedMaxParallel: 4,
},
{
name: "max-parallel-10",
maxParallelString: "10",
expectedMaxParallel: 10,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
matrix := map[string][]any{
"version": {1, 2, 3, 4, 5},
}
var rawMatrix yaml.Node
err := rawMatrix.Encode(matrix)
assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act
job := &model.Job{
Strategy: &model.Strategy{
MaxParallelString: tt.maxParallelString,
RawMatrix: rawMatrix,
},
}
matrixes, err := job.GetMatrixes()
assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act
assert.NotNil(t, matrixes)
assert.Len(t, matrixes, 5)
assert.Equal(t, tt.expectedMaxParallel, job.Strategy.MaxParallel)
})
}
}