Skip to content

Commit

Permalink
Fix YAML structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
blakerouse committed Sep 13, 2024
1 parent ad8e658 commit 8296324
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 29 deletions.
10 changes: 9 additions & 1 deletion pkg/testing/buildkite/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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"`
}
56 changes: 28 additions & 28 deletions pkg/testing/runner/buildkite.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand All @@ -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)
}
Expand Down

0 comments on commit 8296324

Please sign in to comment.