Skip to content

Commit 0df6d65

Browse files
authored
feat: return without an error if all generations failed (#1979)
Fixes #1885
1 parent 80ec945 commit 0df6d65

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

internal/librarian/generate.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ func (r *generateRunner) run(ctx context.Context) error {
166166
}
167167
idToCommits[libraryID] = oldCommit
168168
} else {
169+
succeededGenerations := 0
169170
failedGenerations := 0
170171
for _, library := range r.state.Libraries {
171172
oldCommit, err := r.generateSingleLibrary(ctx, library.ID, outputDir)
@@ -177,9 +178,15 @@ func (r *generateRunner) run(ctx context.Context) error {
177178
// Only add the mapping if library generation is successful so that
178179
// failed library will not appear in generation PR body.
179180
idToCommits[library.ID] = oldCommit
181+
succeededGenerations++
180182
}
181183
}
182-
slog.Info("generation statistics", "all", len(r.state.Libraries), "failures", failedGenerations)
184+
185+
slog.Info(
186+
"generation statistics",
187+
"all", len(r.state.Libraries),
188+
"successes", succeededGenerations,
189+
"failures", failedGenerations)
183190
if failedGenerations > 0 && failedGenerations == len(r.state.Libraries) {
184191
return fmt.Errorf("all %d libraries failed to generate", failedGenerations)
185192
}
@@ -199,10 +206,8 @@ func (r *generateRunner) run(ctx context.Context) error {
199206
commitMessage: "chore: generate libraries",
200207
prType: generate,
201208
}
202-
if err := commitAndPush(ctx, commitInfo); err != nil {
203-
return err
204-
}
205-
return nil
209+
210+
return commitAndPush(ctx, commitInfo)
206211
}
207212

208213
// generateSingleLibrary manages the generation of a single client library.

0 commit comments

Comments
 (0)