mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-03-03 02:10:18 +00:00
support yaml anchors (#65)
This commit is contained in:
@@ -238,6 +238,9 @@ func (s *Node) UnmarshalYAML(node *yaml.Node) error {
|
||||
if node != nil && node.Kind == yaml.DocumentNode {
|
||||
return s.UnmarshalYAML(node.Content[0])
|
||||
}
|
||||
if node.Kind == yaml.AliasNode {
|
||||
node = node.Alias
|
||||
}
|
||||
def := s.Schema.GetDefinition(s.Definition)
|
||||
if s.Context == nil {
|
||||
s.Context = def.Context
|
||||
|
||||
@@ -90,3 +90,30 @@ jobs:
|
||||
}).UnmarshalYAML(&node)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestYAMLAnchors(t *testing.T) {
|
||||
var node yaml.Node
|
||||
err := yaml.Unmarshal([]byte(`
|
||||
on: push
|
||||
jobs:
|
||||
job-with-condition:
|
||||
runs-on: &label
|
||||
self-hosted
|
||||
if: success() || success('joba', 'jobb') || failure() || failure('joba', 'jobb') || always() || cancelled()
|
||||
steps: &steps
|
||||
- run: exit 0
|
||||
then:
|
||||
runs-on: *label
|
||||
steps:
|
||||
- run: exit 0
|
||||
|
||||
`), &node)
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
err = (&Node{
|
||||
Definition: "workflow-root-strict",
|
||||
Schema: GetWorkflowSchema(),
|
||||
}).UnmarshalYAML(&node)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user