From 05a09bb7e14d633aee221fcf39f2267807a3f091 Mon Sep 17 00:00:00 2001 From: TimHuynh Date: Mon, 20 Jan 2025 13:43:16 -0600 Subject: [PATCH] fields for buildkite and ymal --- compiler/types/yaml/buildkite/step.go | 2 ++ compiler/types/yaml/buildkite/step_test.go | 8 ++++---- compiler/types/yaml/buildkite/test_report.go | 12 +++++++++++- compiler/types/yaml/buildkite/testdata/step.yml | 7 +++++++ compiler/types/yaml/yaml/step.go | 2 +- compiler/types/yaml/yaml/step_test.go | 17 +++++++++++++++++ 6 files changed, 42 insertions(+), 6 deletions(-) diff --git a/compiler/types/yaml/buildkite/step.go b/compiler/types/yaml/buildkite/step.go index d03004928..88cde5fa7 100644 --- a/compiler/types/yaml/buildkite/step.go +++ b/compiler/types/yaml/buildkite/step.go @@ -61,6 +61,7 @@ func (s *StepSlice) ToPipeline() *pipeline.ContainerSlice { Pull: step.Pull, Ruleset: *step.Ruleset.ToPipeline(), Secrets: *step.Secrets.ToPipeline(), + TestReport: *step.TestReport.ToPipeline(), Ulimits: *step.Ulimits.ToPipeline(), Volumes: *step.Volumes.ToPipeline(), User: step.User, @@ -166,6 +167,7 @@ func (s *Step) ToYAML() *yaml.Step { Ruleset: *s.Ruleset.ToYAML(), Secrets: *s.Secrets.ToYAML(), Template: s.Template.ToYAML(), + TestReport: s.TestReport.ToYAML(), Ulimits: *s.Ulimits.ToYAML(), Volumes: *s.Volumes.ToYAML(), Parameters: s.Parameters, diff --git a/compiler/types/yaml/buildkite/step_test.go b/compiler/types/yaml/buildkite/step_test.go index cb3329dc0..18479c1b1 100644 --- a/compiler/types/yaml/buildkite/step_test.go +++ b/compiler/types/yaml/buildkite/step_test.go @@ -77,8 +77,8 @@ func TestYaml_StepSlice_ToPipeline(t *testing.T) { }, }, TestReport: TestReport{ - Results: []string{"test.txt"}, - Attachments: []string{"test.log"}, + Results: []string{"test-results/*.xml"}, + Attachments: []string{"screenshots/**/*.png", " video/*.mp4"}, }, }, }, @@ -139,8 +139,8 @@ func TestYaml_StepSlice_ToPipeline(t *testing.T) { }, }, TestReport: pipeline.TestReport{ - Results: []string{"test.txt"}, - Attachments: []string{"test.log"}, + Results: []string{"test-results/*.xml"}, + Attachments: []string{"screenshots/**/*.png", " video/*.mp4"}, }, }, }, diff --git a/compiler/types/yaml/buildkite/test_report.go b/compiler/types/yaml/buildkite/test_report.go index 7727e8475..0de529da0 100644 --- a/compiler/types/yaml/buildkite/test_report.go +++ b/compiler/types/yaml/buildkite/test_report.go @@ -1,6 +1,9 @@ package buildkite -import "github.com/go-vela/server/compiler/types/pipeline" +import ( + "github.com/go-vela/server/compiler/types/pipeline" + "github.com/go-vela/server/compiler/types/yaml/yaml" +) // TestReport represents the structure for test report configuration. type TestReport struct { @@ -38,3 +41,10 @@ func (t *TestReport) UnmarshalYAML(unmarshal func(interface{}) error) error { return nil } + +func (t *TestReport) ToYAML() yaml.TestReport { + return yaml.TestReport{ + Results: t.Results, + Attachments: t.Attachments, + } +} diff --git a/compiler/types/yaml/buildkite/testdata/step.yml b/compiler/types/yaml/buildkite/testdata/step.yml index 1d6d9cc93..1e15dd239 100644 --- a/compiler/types/yaml/buildkite/testdata/step.yml +++ b/compiler/types/yaml/buildkite/testdata/step.yml @@ -44,3 +44,10 @@ registry: index.docker.io repo: github/octocat tags: [ latest, dev ] + +- name: test-reports + image: golang:1.20 + pull: true + test_report: + results: ["test-results/*.xml"] + attachments: ["screenshots/**/*.png", " video/*.mp4"] \ No newline at end of file diff --git a/compiler/types/yaml/yaml/step.go b/compiler/types/yaml/yaml/step.go index 45e8bb800..8289520b3 100644 --- a/compiler/types/yaml/yaml/step.go +++ b/compiler/types/yaml/yaml/step.go @@ -60,12 +60,12 @@ func (s *StepSlice) ToPipeline() *pipeline.ContainerSlice { Pull: step.Pull, Ruleset: *step.Ruleset.ToPipeline(), Secrets: *step.Secrets.ToPipeline(), + TestReport: *step.TestReport.ToPipeline(), Ulimits: *step.Ulimits.ToPipeline(), Volumes: *step.Volumes.ToPipeline(), User: step.User, ReportAs: step.ReportAs, IDRequest: step.IDRequest, - TestReport: *step.TestReport.ToPipeline(), }) } diff --git a/compiler/types/yaml/yaml/step_test.go b/compiler/types/yaml/yaml/step_test.go index 343daf230..dabbc7c3f 100644 --- a/compiler/types/yaml/yaml/step_test.go +++ b/compiler/types/yaml/yaml/step_test.go @@ -76,6 +76,10 @@ func TestYaml_StepSlice_ToPipeline(t *testing.T) { AccessMode: "ro", }, }, + TestReport: TestReport{ + Results: []string{"test-results/*.xml"}, + Attachments: []string{"screenshots/**/*.png", " video/*.mp4"}, + }, }, }, want: &pipeline.ContainerSlice{ @@ -134,6 +138,10 @@ func TestYaml_StepSlice_ToPipeline(t *testing.T) { AccessMode: "ro", }, }, + TestReport: pipeline.TestReport{ + Results: []string{"test-results/*.xml"}, + Attachments: []string{"screenshots/**/*.png", " video/*.mp4"}, + }, }, }, }, @@ -213,6 +221,15 @@ func TestYaml_StepSlice_UnmarshalYAML(t *testing.T) { }, }, }, + { + Name: "test-reports", + Image: "golang:1.20", + Pull: "always", + TestReport: TestReport{ + Results: []string{"test-results/*.xml"}, + Attachments: []string{"screenshots/**/*.png", " video/*.mp4"}, + }, + }, }, }, {