mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-11-23 20:33:23 +08:00
Closes many small gaps between how workflows run on GitHub and on the runner, each checked against GitHub's runner and live runs. - `action.yml` expressions are checked against the contexts GitHub allows per field, and input defaults are evaluated with those contexts only - Reusable workflows take inputs from `workflow_call` only, evaluate outputs once after all called jobs finish, stop at 10 nested workflows and resolve relative `./` paths in remote workflows against that workflow's repository - A called job failing under `continue-on-error` no longer fails the caller, and same-repository calls use their own clone cache - Job timeouts cancel the job with GitHub's message, step timeouts fail the step with GitHub's message, and invalid `timeout-minutes` values behave like on GitHub - `runner.timeout` expiry names the setting and server cancellation is logged - Matrix and strategy evaluation errors fail the job - `exec` records skipped jobs and sets `github.run_attempt`, `workflow_ref` and `workflow_sha` - `runs-on` expressions keep their types - Step summaries upload as each step ends - Docker actions join the job network, and the job container no longer gets a network alias from the job name - Container, network and volume names are unique per job invocation - Cached images are matched against the daemon's platform and Dockerfile actions build for the requested platform - `runner.arch` maps 32-bit ARM and x86 names like GitHub - Pinned action SHAs are verified and git replace objects are ignored - `hashFiles` uses GitHub's current bundle - Registration trims labels and writes `.runner` as `0600` - The container entrypoint quotes its arguments and reads the registration token from the environment or a file - The systemd example uses `KillMode=mixed` so running jobs can finish on stop - The cache server releases its database between eviction batches - Shared rules come from actionslib v1.7.0, added in https://gitea.com/gitea/actionslib/pulls/34 _Written by Claude (Opus 5.5)._ Reviewed-on: https://gitea.com/gitea/runner/pulls/1421 Reviewed-by: bircni <bircni@icloud.com> Co-authored-by: silverwind <me@silverwind.io>
59 lines
2.2 KiB
Go
59 lines
2.2 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package runner
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"gitea.dev/actionslib/pkg/model"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestMaxParallelStrategy(t *testing.T) {
|
|
for limit, want := range map[string]int{"1": 1, "": 4, "10": 5, "tow": 4} {
|
|
assert.Equal(t, want, maxParallelFor(&model.Strategy{MaxParallelString: limit}, 5), limit)
|
|
}
|
|
|
|
t.Run("deferred strategy", func(t *testing.T) {
|
|
workflow, err := model.ReadWorkflow(strings.NewReader(`
|
|
jobs:
|
|
test:
|
|
if: false
|
|
strategy: ${{ fromJSON('{"max-parallel":2,"fail-fast":false,"matrix":{"os":["ubuntu","windows"]}}') }}
|
|
`))
|
|
require.NoError(t, err)
|
|
job := workflow.Jobs["test"]
|
|
rawStrategy := model.CloneYamlNode(job.RawStrategy)
|
|
require.NoError(t, (&runnerImpl{config: &Config{Env: testCheckoutEnv()}}).NewPlanExecutor(&model.Plan{Stages: []*model.Stage{{Runs: []*model.Run{{Workflow: workflow, JobID: "test"}}}}})(t.Context()))
|
|
require.NotNil(t, job.Strategy)
|
|
assert.False(t, job.Strategy.GetFailFast())
|
|
assert.Equal(t, 2, maxParallelFor(job.Strategy, 5))
|
|
matrixes, err := job.GetMatrixes()
|
|
require.NoError(t, err)
|
|
assert.Equal(t, []map[string]any{{"os": "ubuntu"}, {"os": "windows"}}, matrixes)
|
|
assert.Equal(t, rawStrategy, job.RawStrategy)
|
|
})
|
|
}
|
|
|
|
func TestNewPlanExecutorInvalidMatrix(t *testing.T) {
|
|
runner := &runnerImpl{config: &Config{Env: testCheckoutEnv()}}
|
|
for strategy, want := range map[string]string{
|
|
`{matrix: {config: {nested: value}}}`: "could not get job matrix:",
|
|
`${{ fromJSON('invalid') }}`: "job strategy",
|
|
`${{ '${{ inputs.unresolved }}' }}`: "job strategy",
|
|
`{matrix: {x: [a, "${{ fromJSON('not json') }}"]}}`: "Error when evaluating 'strategy' for job 'job1'.",
|
|
} {
|
|
t.Run(strategy, func(t *testing.T) {
|
|
workflow, err := model.ReadWorkflow(strings.NewReader("jobs:\n job1:\n strategy: " + strategy))
|
|
require.NoError(t, err)
|
|
plan, err := model.CombineWorkflowPlanner(workflow).PlanAll()
|
|
require.NoError(t, err)
|
|
require.ErrorContains(t, runner.NewPlanExecutor(plan)(t.Context()), want)
|
|
assert.Equal(t, "failure", workflow.Jobs["job1"].Result)
|
|
})
|
|
}
|
|
}
|