mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-26 06:33:42 +09:00
Updates actionslib to https://gitea.com/gitea/actionslib/releases/tag/v1.2.1, moves workflow parsing into it and aligns behaviour with GitHub. 1. `uses:` supports `self:` (Gitea-only feature) and `$/` paths. 1. `strategy`, `matrix`, `max-parallel` and `fail-fast` accept expressions, including over `needs`. A job whose `name`, `runs-on` or `continue-on-error` reads `needs` is resolved once they finish. 1. A job `if:` may only read `github`, `needs`, `vars` and `inputs` and is decided before the matrix, as on github.com. 1. Matrix `fail-fast` cancels the other combinations, and `always()` jobs keep running when a run is cancelled. 1. Invalid workflow files, including a malformed `on:` and unknown or cyclic `needs`, show up on push as failed runs with the error. 1. A job whose `if:` or `concurrency:` fails to evaluate is skipped or failed with the error, instead of staying blocked. 1. Reusable workflows: a missing and an unreadable repository fail alike, public callers cannot use private workflows, nested jobs cannot exceed the caller's token permissions. 1. Runner labels match case-insensitively, and `runs-on` accepts an array from an expression. Runner PR: https://gitea.com/gitea/runner/pulls/1247 Docs PR: https://gitea.com/gitea/docs/pulls/553 Fixes: https://github.com/go-gitea/gitea/issues/38990 Fixes: https://github.com/go-gitea/gitea/issues/39382 Fixes: https://github.com/go-gitea/gitea/issues/32364 Fixes: https://github.com/go-gitea/gitea/issues/36077 Fixes: https://github.com/go-gitea/gitea/issues/23277 Fixes: https://github.com/go-gitea/gitea/issues/29020 Co-authored-by: Claude (Opus 5) <noreply@anthropic.com> Co-authored-by: Zettat123 <zettat123@gmail.com>
75 lines
1.8 KiB
Go
75 lines
1.8 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package jobparser
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestParseResolvesAliasesAndTimestamps(t *testing.T) {
|
|
got, err := Parse([]byte(`on: push
|
|
env: &common_env
|
|
SHARED: "1"
|
|
DATE: 2026-03-15
|
|
jobs:
|
|
a:
|
|
runs-on: linux
|
|
env: *common_env
|
|
steps: &common_steps [{run: echo hi}]
|
|
b:
|
|
runs-on: linux
|
|
env: *common_env
|
|
steps: *common_steps
|
|
`))
|
|
require.NoError(t, err)
|
|
require.Len(t, got, 2)
|
|
|
|
for _, workflow := range got {
|
|
_, job := workflow.Job()
|
|
var env map[string]string
|
|
require.NoError(t, job.Env.Decode(&env))
|
|
assert.Equal(t, map[string]string{"SHARED": "1", "DATE": "2026-03-15"}, env)
|
|
require.Len(t, job.Steps, 1)
|
|
|
|
payload, err := workflow.Marshal()
|
|
require.NoError(t, err)
|
|
assert.NotContains(t, string(payload), "common_")
|
|
}
|
|
}
|
|
|
|
func TestParseRejectsAliases(t *testing.T) {
|
|
job := func(body string) []byte {
|
|
return []byte("on: push\njobs:\n a:\n runs-on: linux\n" + body)
|
|
}
|
|
|
|
for _, tt := range []struct {
|
|
name, wantErr string
|
|
content []byte
|
|
}{
|
|
{
|
|
name: "anchor aliased from inside itself",
|
|
content: job(" steps: &s [{run: echo}, *s]\n"),
|
|
wantErr: "maximum YAML nodes exceeded",
|
|
},
|
|
{
|
|
name: "merge key",
|
|
content: job(" env: &e {X: \"1\"}\n container:\n image: alpine\n env:\n <<: *e\n"),
|
|
wantErr: "merge keys (`<<`) are not supported",
|
|
},
|
|
{
|
|
name: "alias before its anchor",
|
|
content: job(" env: *e\n container: {image: alpine, env: &e {X: \"1\"}}\n"),
|
|
wantErr: "unknown anchor 'e' referenced",
|
|
},
|
|
} {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
_, err := Parse(tt.content)
|
|
require.ErrorContains(t, err, tt.wantErr)
|
|
})
|
|
}
|
|
}
|