Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion tools/generator/cmd/automation/automationCmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,28 @@ func (ctx *automationContext) generate(input *pipeline.GenerateInput) (*pipeline
}

return &pipeline.GenerateOutput{
Packages: results,
Packages: squashResults(results),
}, errorBuilder.build()
}

// squashResults squashes the package results by appending all of the `path`s in the following items to the first item
// By doing this, the SDK automation pipeline will only create one PR that contains all of the generation results
// instead of creating one PR for each generation result.
// This is to reduce the resource cost on GitHub
func squashResults(packages []pipeline.PackageResult) []pipeline.PackageResult {
if len(packages) == 0 {
return packages
}
for i := 1; i < len(packages); i++ {
// append the path of the i-th item to the first
packages[0].Path = append(packages[0].Path, packages[i].Path...)
// erase the path on the i-th item
packages[i].Path = make([]string, 0)
}

return packages
}

func (ctx *automationContext) readRepoContent() error {
ctx.repoContent = make(map[string]exports.Content)
pkgs, err := track1.List(filepath.Join(ctx.sdkRoot, "services"))
Expand Down
4 changes: 2 additions & 2 deletions tools/generator/cmd/automation/pipeline/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ func (o GenerateOutput) WriteTo(writer io.Writer) (int64, error) {
type PackageResult struct {
Version string `json:"version,omitempty"`
PackageName string `json:"packageName,omitempty"`
Path []string `json:"path,omitempty"`
ReadmeMd []string `json:"readmeMd,omitempty"`
Path []string `json:"path"`
ReadmeMd []string `json:"readmeMd"`
Changelog *Changelog `json:"changelog,omitempty"`
Artifacts []string `json:"artifacts,omitempty"`
InstallInstructions *InstallInstructionScriptOutput `json:"installInstructions,omitempty"`
Expand Down