1
0

feat: show only the last step that was successful/failed

This commit is contained in:
dump_stack() 2023-05-25 13:29:11 +00:00
parent b24008ad3f
commit aceaf96448
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC

51
log.go
View File

@ -207,6 +207,20 @@ func (cmd *LogMarkdownCmd) Run(g *Globals) (err error) {
return return
} }
func center(s string, w int) string {
return fmt.Sprintf("%[1]*s", -w, fmt.Sprintf("%[1]*s", (w+len(s))/2, s))
}
func genOkFailCentered(name string, ok bool) (aurv aurora.Value) {
name = center(name, 10)
if ok {
aurv = aurora.BgGreen(aurora.Black(name))
} else {
aurv = aurora.BgRed(aurora.White(aurora.Bold(name)))
}
return
}
func logLogEntry(l logEntry) { func logLogEntry(l logEntry) {
distroInfo := fmt.Sprintf("%s-%s {%s}", l.Distro.ID, distroInfo := fmt.Sprintf("%s-%s {%s}", l.Distro.ID,
l.Distro.Release, l.KernelRelease) l.Distro.Release, l.KernelRelease)
@ -215,22 +229,25 @@ func logLogEntry(l logEntry) {
timestamp := l.Timestamp.Format("2006-01-02 15:04") timestamp := l.Timestamp.Format("2006-01-02 15:04")
colored := "" var status aurora.Value
if l.InternalErrorString != "" { if l.InternalErrorString != "" {
colored = aurora.Sprintf("[%4d %4s] [%s] %20s %-70s: %s", status = genOkFailCentered("INTERNAL", false)
l.ID, l.Tag, timestamp, artifactInfo, distroInfo,
genOkFail("", false))
} else if l.Type == config.KernelExploit { } else if l.Type == config.KernelExploit {
colored = aurora.Sprintf("[%4d %4s] [%s] %20s %-70s: %s %s", if l.Build.Ok {
l.ID, l.Tag, timestamp, artifactInfo, distroInfo, status = genOkFailCentered("LPE", l.Test.Ok)
genOkFail("BUILD", l.Build.Ok),
genOkFail("LPE", l.Test.Ok))
} else { } else {
colored = aurora.Sprintf("[%4d %4s] [%s] %20s %-70s: %s %s %s", status = genOkFailCentered("BUILD", l.Build.Ok)
l.ID, l.Tag, timestamp, artifactInfo, distroInfo, }
genOkFail("BUILD", l.Build.Ok), } else {
genOkFail("INSMOD", l.Run.Ok), if l.Build.Ok {
genOkFail("TEST", l.Test.Ok)) if l.Run.Ok {
status = genOkFailCentered("TEST", l.Test.Ok)
} else {
status = genOkFailCentered("INSMOD", l.Run.Ok)
}
} else {
status = genOkFailCentered("BUILD", l.Build.Ok)
}
} }
additional := "" additional := ""
@ -240,11 +257,11 @@ func logLogEntry(l logEntry) {
additional = "(timeout)" additional = "(timeout)"
} }
if additional != "" { colored := aurora.Sprintf("[%4d %4s] [%s] %-40s %-70s: %s %s",
fmt.Println(colored, additional) l.ID, l.Tag, timestamp, artifactInfo, distroInfo, status,
} else { additional)
fmt.Println(colored) fmt.Println(colored)
}
} }
type runstat struct { type runstat struct {