Skip to content

Commit ccfb436

Browse files
authored
[SumDB] Fail with non-zero code if any version fails (#57)
This makes it easier to hook up into script automation. Also added some verbose logging to provide info when milestones are reached. I had a quick look at making the version reports parallel, but found race conditions.
1 parent 3955617 commit ccfb436

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

vindex/cmd/sumdbverify/client.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ func run(ctx context.Context) error {
142142
if _, err := fmt.Fprintln(tw, "VERSION\tINDEX\tFOUND\tgo.mod\tzip\t"); err != nil {
143143
return fmt.Errorf("failed to output report: %v", err)
144144
}
145+
reportErrors := make([]error, 0)
146+
if reportErr != nil {
147+
reportErrors = append(reportErrors, reportErr)
148+
}
145149
for _, v := range report.versions {
146150
var sumIndex string
147151
if v.sumFound {
@@ -159,14 +163,15 @@ func run(ctx context.Context) error {
159163
if v.gitCommitHash == nil || len(v.gitModHash) == 0 {
160164
goMod = "⚠️"
161165
} else if v.gitModHash != v.sumModHash {
166+
reportErrors = append(reportErrors, fmt.Errorf("failed to reproduce go.mod hash for version %q", v.version))
162167
goMod = "❌"
163168
}
164169

165170
goZip := "✅"
166171
if v.gitCommitHash == nil || len(v.gitModHash) == 0 {
167172
goZip = "⚠️"
168173
} else if v.gitZipHash != v.sumZipHash {
169-
klog.Warningf("zip: git != sum: %s != %s", v.gitZipHash, v.sumZipHash)
174+
reportErrors = append(reportErrors, fmt.Errorf("failed to reproduce zip hash for version %q", v.version))
170175
goZip = "❌"
171176
}
172177
if _, err := fmt.Fprintf(tw, "%s\t%s\t%s\t%s\t%s\t\n", v.version, sumIndex, gitHash, goMod, goZip); err != nil {
@@ -177,7 +182,7 @@ func run(ctx context.Context) error {
177182
return fmt.Errorf("failed to flush report to stdout: %v", err)
178183
}
179184

180-
return reportErr
185+
return errors.Join(reportErrors...)
181186
}
182187

183188
func findGoMod(modRoot string) (string, error) {
@@ -235,6 +240,7 @@ func getReport(ctx context.Context, modRoot string, sumFetcher func(context.Cont
235240
var versions map[string]modData
236241
var tags map[string]struct{}
237242

243+
klog.V(1).Info("Fetching tag and SumDB info")
238244
eg.Go(func() error {
239245
var err error
240246
versions, err = sumFetcher(egctx, modName)
@@ -261,6 +267,7 @@ func getReport(ctx context.Context, modRoot string, sumFetcher func(context.Cont
261267
if err := eg.Wait(); err != nil {
262268
return report, err
263269
}
270+
klog.V(1).Infof("Fetched %d tags and %d SumDB versions", len(tags), len(versions))
264271

265272
// Create a sorted slice of versions
266273
sv := make([]string, 0, len(versions))
@@ -287,6 +294,7 @@ func getReport(ctx context.Context, modRoot string, sumFetcher func(context.Cont
287294
delete(tags, v)
288295
}
289296
}
297+
klog.V(1).Info("Finished compiling report")
290298

291299
// TODO(mhutchinson): Include information on tags in git that aren't in SumDB
292300
// if len(tags) > 0 {

0 commit comments

Comments
 (0)