Fix workflow serialize to omit skip_clone if false (#6319)

This commit is contained in:
6543
2026-03-24 19:27:29 +01:00
committed by GitHub
parent f842ce2cc2
commit 280d2e902a
2 changed files with 11 additions and 12 deletions

View File

@@ -48,8 +48,7 @@ func TestParse(t *testing.T) {
assert.Equal(t, "build", out.Labels["com.example.type"])
assert.Equal(t, "lint", out.DependsOn[0])
assert.Equal(t, "test", out.DependsOn[1])
assert.Equal(t, ("success"), out.RunsOn[0]) //nolint:staticcheck
assert.Equal(t, ("failure"), out.RunsOn[1]) //nolint:staticcheck
assert.EqualValues(t, []string{"success", "failure"}, out.When.Constraints[0].Status)
assert.False(t, out.SkipClone)
})
@@ -171,8 +170,10 @@ when:
- event:
- tester
- tester2
status: [ success, failure ]
- branch:
- tester
status: [ success, failure ]
workspace:
path: src/github.com/octocat/hello-world
base: /go
@@ -204,9 +205,6 @@ labels:
depends_on:
- lint
- test
runs_on:
- success
- failure
`
var simpleYamlAnchors = `
@@ -278,7 +276,6 @@ func TestReSerialize(t *testing.T) {
environment:
DRIVER: next
PLATFORM: linux
skip_clone: false
`, string(work1Bin))
work2, err := ParseString(sampleYaml)
@@ -289,10 +286,16 @@ skip_clone: false
// TODO: fix "steps.[1].depends_on: []" to be re-serialized!
assert.EqualValues(t, `when:
- event:
- status:
- success
- failure
event:
- tester
- tester2
- branch: tester
status:
- success
- failure
workspace:
base: /go
path: src/github.com/octocat/hello-world
@@ -322,10 +325,6 @@ labels:
depends_on:
- lint
- test
skip_clone: false
runs_on:
- success
- failure
`, string(workBin2))
}

View File

@@ -28,7 +28,7 @@ type (
Services ContainerList `yaml:"services,omitempty"`
Labels map[string]string `yaml:"labels,omitempty"`
DependsOn []string `yaml:"depends_on,omitempty"`
SkipClone bool `yaml:"skip_clone"`
SkipClone bool `yaml:"skip_clone,omitempty"`
// Deprecated: use when.status. TODO remove in next major.
RunsOn []string `yaml:"runs_on,omitempty"`
}