From 829632485e74154da5c93c119946c86e7373edca Mon Sep 17 00:00:00 2001 From: Blake Rouse Date: Fri, 13 Sep 2024 15:43:59 -0400 Subject: [PATCH] Fix YAML structure. --- pkg/testing/buildkite/steps.go | 10 +++++- pkg/testing/runner/buildkite.go | 56 ++++++++++++++++----------------- 2 files changed, 37 insertions(+), 29 deletions(-) diff --git a/pkg/testing/buildkite/steps.go b/pkg/testing/buildkite/steps.go index 95e3447694a..4e55fb9b3a4 100644 --- a/pkg/testing/buildkite/steps.go +++ b/pkg/testing/buildkite/steps.go @@ -14,7 +14,6 @@ type StepAgent struct { type Step struct { Key string `yaml:"key,omitempty"` Label string `yaml:"label,omitempty"` - Group string `yaml:"group,omitempty"` Command string `yaml:"command,omitempty"` Env map[string]string `yaml:"env,omitempty"` ArtifactPaths []string `yaml:"artifact_paths,omitempty"` @@ -23,3 +22,12 @@ type Step struct { AllowDependencyFailure bool `yaml:"allow_dependency_failure,omitempty"` Steps []Step `yaml:"steps,omitempty"` } + +type GroupEntry struct { + Name string `yaml:"name,omitempty"` + Steps []Step `yaml:"steps,omitempty"` +} + +type Group struct { + Group GroupEntry `yaml:"group,omitempty"` +} diff --git a/pkg/testing/runner/buildkite.go b/pkg/testing/runner/buildkite.go index ac28365cf64..82dabbd2e32 100644 --- a/pkg/testing/runner/buildkite.go +++ b/pkg/testing/runner/buildkite.go @@ -60,42 +60,42 @@ func (r *Runner) Buildkite() (string, error) { return "", fmt.Errorf("unable to get machine and image: %w", err) } if len(lb.Batch.Tests) > 0 { - var group buildkite.Step - group.Group = fmt.Sprintf("Integration Test (non-sudo): %s", lb.ID) - group.Key = fmt.Sprintf("integration-non-sudo-%s", lb.ID) + var step buildkite.Step + step.Label = fmt.Sprintf("Integration Test (non-sudo): %s", lb.ID) + step.Key = fmt.Sprintf("integration-non-sudo-%s", lb.ID) if lb.Batch.Stack != nil { stackKey := fmt.Sprintf("integration-stack-%s", lb.Batch.Stack.Version) - group.DependsOn = append(group.DependsOn, stackKey) - stackDepends[stackKey] = append(stackDepends[stackKey], group.Key) + step.DependsOn = append(step.DependsOn, stackKey) + stackDepends[stackKey] = append(stackDepends[stackKey], step.Key) } - group.ArtifactPaths = []string{"build/**"} - group.Agents = agentStep - group.Command = "mage integration:testOnRemote" - group.Env = map[string]string{ + step.ArtifactPaths = []string{"build/**"} + step.Agents = agentStep + step.Command = "mage integration:testOnRemote" + step.Env = map[string]string{ "AGENT_VERSION": r.cfg.AgentVersion, - "TEST_DEFINE_PREFIX": group.Key, + "TEST_DEFINE_PREFIX": step.Key, "TEST_DEFINE_TESTS": strings.Join(getTestNames(lb.Batch.Tests), ","), } - steps = append(steps, group) + steps = append(steps, step) } if len(lb.Batch.SudoTests) > 0 { - var group buildkite.Step - group.Group = fmt.Sprintf("Integration Test (sudo): %s", lb.ID) - group.Key = fmt.Sprintf("integration-sudo-%s", lb.ID) + var step buildkite.Step + step.Label = fmt.Sprintf("Integration Test (sudo): %s", lb.ID) + step.Key = fmt.Sprintf("integration-sudo-%s", lb.ID) if lb.Batch.Stack != nil { stackKey := fmt.Sprintf("integration-stack-%s", lb.Batch.Stack.Version) - group.DependsOn = append(group.DependsOn, stackKey) - stackDepends[stackKey] = append(stackDepends[stackKey], group.Key) + step.DependsOn = append(step.DependsOn, stackKey) + stackDepends[stackKey] = append(stackDepends[stackKey], step.Key) } - group.ArtifactPaths = []string{"build/**"} - group.Agents = agentStep - group.Command = "mage integration:testOnRemote" - group.Env = map[string]string{ + step.ArtifactPaths = []string{"build/**"} + step.Agents = agentStep + step.Command = "mage integration:testOnRemote" + step.Env = map[string]string{ "AGENT_VERSION": r.cfg.AgentVersion, - "TEST_DEFINE_PREFIX": group.Key, + "TEST_DEFINE_PREFIX": step.Key, "TEST_DEFINE_TESTS": strings.Join(getTestNames(lb.Batch.SudoTests), ","), } - steps = append(steps, group) + steps = append(steps, step) } } @@ -111,12 +111,12 @@ func (r *Runner) Buildkite() (string, error) { }) } - yamlOutput, err := yaml.Marshal(buildkite.Step{ - Group: "Integration Tests", - Key: "integration-tests", - DependsOn: []string{"package-it"}, - Steps: steps, - }) + yamlOutput, err := yaml.Marshal([]buildkite.Group{{ + Group: buildkite.GroupEntry{ + Name: "Integration Tests", + Steps: steps, + }, + }}) if err != nil { return "", fmt.Errorf("unable to marshal yaml: %w", err) }