Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only mgmt return error in sdk automation #23989

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
38 changes: 37 additions & 1 deletion eng/tools/generator/cmd/v2/automation/automationCmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,30 @@ func execute(inputPath, outputPath, goVersion string) error {
}
}
if err != nil {
return err
// Temporary strategy: Only if the project is a management plane project, the generator will return an error.
if IsManagementPlaneProject(input) {
return err
}
fmt.Println(err)
}

return nil
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we enabled any tests for the go automation tooling?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have done some tests in local, and @jliusan also help test by using a swagger and a tspconfig cases.

func IsManagementPlaneProject(input *pipeline.GenerateInput) bool {
for _, tspProjectFolder := range input.RelatedTypeSpecProjectFolder {
if !strings.Contains(tspProjectFolder, ".Management") {
return false
}
}
for _, readme := range input.RelatedReadmeMdFiles {
if !strings.Contains(readme, "resource-manager") {
return false
}
}
return true
}

type automationContext struct {
sdkRoot string
specRoot string
Expand Down Expand Up @@ -144,7 +162,14 @@ func (ctx *automationContext) generate(input *pipeline.GenerateInput) (*pipeline
TspClientOptions: []string{"--debug"},
}, packageModuleRelativePath)
if err != nil {
// save the error package for monitoring
errorBuilder.add(err)
errorPackageResult := pipeline.PackageResult{
PackageName: packageModuleRelativePath,
HasExceptions: true,
TypespecProject: []string{tspProjectFolder},
}
results = append(results, errorPackageResult)
continue
} else {
content := namespaceResult.ChangelogMD
Expand Down Expand Up @@ -209,6 +234,17 @@ func (ctx *automationContext) generate(input *pipeline.GenerateInput) (*pipeline
namespaceResults, errors := generateCtx.GenerateForAutomation(readme, input.RepoHTTPSURL, ctx.goVersion)
if len(errors) != 0 {
errorBuilder.add(errors...)
for _, result := range namespaceResults {
if !result.HasError {
continue
}
errorPackageResult := pipeline.PackageResult{
PackageName: result.PackageName,
HasExceptions: true,
ReadmeMd: []string{readme},
}
results = append(results, errorPackageResult)
}
continue
}

Expand Down
1 change: 1 addition & 0 deletions eng/tools/generator/cmd/v2/automation/pipeline/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ type PackageResult struct {
APIViewArtifact string `json:"apiViewArtifact,omitempty"`
Language string `json:"language,omitempty"`
TypespecProject []string `json:"typespecProject,omitempty"`
HasExceptions bool `json:"hasExceptions,omitempty"`
}

// Changelog ...
Expand Down
2 changes: 2 additions & 0 deletions eng/tools/generator/cmd/v2/common/generation.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type GenerateResult struct {
Changelog Changelog
ChangelogMD string
PullRequestLabels string
HasError bool
}

type GenerateParam struct {
Expand Down Expand Up @@ -94,6 +95,7 @@ func (ctx *GenerateContext) GenerateForAutomation(readme, repo, goVersion string
})
if err != nil {
errors = append(errors, fmt.Errorf("failed to generate for rp: %s, namespace: %s: %+v", rpName, packageInfo.Name, err))
result = append(result, GenerateResult{PackageName: packageInfo.Name, HasError: true})
continue
}
result = append(result, *singleResult)
Expand Down
Loading