@@ -125,7 +125,7 @@ func (r *ConsoleReporter) BuildStarted(pkg *Package, status map[*Package]Package
125
125
tw .Flush ()
126
126
}
127
127
128
- // BuildFinished is called when the build of a package whcih was started by the user has finished.
128
+ // BuildFinished is called when the build of a package which was started by the user has finished.
129
129
func (r * ConsoleReporter ) BuildFinished (pkg * Package , err error ) {
130
130
if err != nil {
131
131
color .Printf ("<red>build failed</>\n <white>Reason:</> %s\n " , err )
@@ -238,6 +238,7 @@ type PackageReport struct {
238
238
start time.Time
239
239
duration time.Duration
240
240
status PackageBuildStatus
241
+ results []string
241
242
err error
242
243
}
243
244
@@ -261,18 +262,30 @@ func (r *PackageReport) StatusIcon() string {
261
262
}
262
263
}
263
264
264
- func (r * PackageReport ) HasError () bool {
265
- return r .err != nil
266
- }
267
-
268
265
func (r * PackageReport ) DurationInSeconds () string {
269
266
return fmt .Sprintf ("%.2fs" , r .duration .Seconds ())
270
267
}
271
268
269
+ func (r * PackageReport ) HasLogs () bool {
270
+ return r .logs .Len () > 0
271
+ }
272
+
272
273
func (r * PackageReport ) Logs () string {
273
274
return strings .TrimSpace (r .logs .String ())
274
275
}
275
276
277
+ func (r * PackageReport ) HasResults () bool {
278
+ return len (r .results ) > 0
279
+ }
280
+
281
+ func (r * PackageReport ) Results () []string {
282
+ return r .results
283
+ }
284
+
285
+ func (r * PackageReport ) HasError () bool {
286
+ return r .err != nil
287
+ }
288
+
276
289
func (r * PackageReport ) Error () string {
277
290
return fmt .Sprintf ("%s" , r .err )
278
291
}
@@ -345,6 +358,10 @@ func (r *HTMLReporter) PackageBuildFinished(pkg *Package, err error) {
345
358
rep .duration = time .Since (rep .start )
346
359
rep .status = PackageBuilt
347
360
rep .err = err
361
+
362
+ if cfg , ok := pkg .Config .(DockerPkgConfig ); ok && pkg .Type == DockerPackage {
363
+ rep .results = cfg .Image
364
+ }
348
365
}
349
366
350
367
func (r * HTMLReporter ) Report () {
@@ -354,22 +371,56 @@ func (r *HTMLReporter) Report() {
354
371
vars ["RootPackage" ] = r .rootPackage
355
372
356
373
tmplString := `
357
- <h1> Leeway build for <code>{{ .RootPackage.FullName }}</code></h1>
358
- {{ range $pkg, $report := .Packages }}
359
- <details{{ if $report.HasError }} open{{ end }}><summary> {{ $report.StatusIcon }} <b>{{ $pkg }}</b> - {{ $report.DurationInSeconds }}</summary>
360
-
361
- {{ if $report.HasError }}
362
- <pre>
363
- {{ $report.Error }}
364
- </pre>
365
- {{ end }}
366
-
367
- <pre>
368
- {{ $report.Logs }}
369
- </pre>
370
-
374
+ <h1>{{ .RootPackage.FullName }}</h1>
375
+ <p>Leeway built the following packages</p>
376
+ <table>
377
+ <thead>
378
+ <tr>
379
+ <td>🚦 Status</td>
380
+ <td>📦 Package</td>
381
+ <td>⏰ Duration</td>
382
+ <td>🔬 Details</td>
383
+ </tr>
384
+ </thread>
385
+ <tbody>
386
+ {{- range $pkg, $report := .Packages }}
387
+ <tr>
388
+ <td>{{ $report.StatusIcon }}</td>
389
+ <td>{{ $pkg }}</td>
390
+ <td>{{ $report.DurationInSeconds -}}</td>
391
+ <td><a href="#{{ $pkg }}">See below</td>
392
+ </tr>
393
+ {{- end }}
394
+ </tbody>
395
+ <table>
396
+ <p>For details around each package, see below<p>
397
+ {{- range $pkg, $report := .Packages }}
398
+ <h2 id="{{ $pkg }}">{{ $pkg }}</h2>
399
+ {{ if $report.HasError -}}
400
+ <details open>
401
+ <summary>Error message</summary>
402
+ <pre><code>{{ $report.Error }}</code></pre>
403
+ </details>
404
+ {{ end -}}
405
+ {{ if $report.HasResults -}}
406
+ <details>
407
+ <summary>Results</summary>
408
+ <ul>
409
+ {{- range $result := $report.Results }}
410
+ <li><code>{{ $result }}</code></li>
411
+ {{ end -}}
412
+ </ul>
413
+ </details>
414
+ {{ end -}}
415
+ <details>
416
+ <summary>Logs</summary>
417
+ {{ if $report.HasLogs -}}
418
+ <pre><code>{{ $report.Logs }}</code></pre>
419
+ {{- else -}}
420
+ <pre>No logs</pre>
421
+ {{- end }}
371
422
</details>
372
- {{ end }}
423
+ {{- end - }}
373
424
`
374
425
tmpl , _ := template .New ("Report" ).Parse (strings .ReplaceAll (tmplString , "'" , "`" ))
375
426
0 commit comments