-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchart.go
83 lines (64 loc) · 1.67 KB
/
chart.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package main
import (
"fmt"
"log/slog"
"strings"
"time"
)
func generateCharts(pr ParseResult) []PlotlyChart {
var charts []PlotlyChart
testNames := pr.TestNamesOrderedByStart()
for _, tn := range testNames {
ch := PlotlyChart{
Type: "bar",
Orientation: "h",
Hoverinfo: "text",
Textposition: "inside",
}
pause, hasPause := pr.TestPauses.ByTestName(tn)
run, hasRun := pr.TestRuns.ByTestName(tn)
if !hasRun {
slog.Debug("Test was not executed", "test", tn)
continue
}
packageNameParts := strings.Split(tn.Package, "/")
var packageName string
if len(packageNameParts) != 0 {
packageName = packageNameParts[len(packageNameParts)-1]
} else {
slog.Warn("Package name is empty", "test", tn.Package)
}
packageNameFull := fmt.Sprintf("%s.%s", packageName, tn.TestName)
y := packageNameFull
if !run.Passed {
y += " (failed)"
}
if hasPause {
startAfter := pause.Start.Sub(pr.Start)
duration := pause.Duration()
slog.Debug("Test was paused", "startAfter", startAfter, "duration", duration, "test", tn)
ch.Add(
fmt.Sprintf("%s PAUSE (%s)", packageNameFull, duration.Round(time.Millisecond).String()),
y,
startAfter,
duration,
"rgba(108,122,137,1)",
)
}
{
startAfter := run.Start.Sub(pr.Start)
duration := run.Duration()
slog.Debug("Test was executed", "startAfter", startAfter, "duration", duration, "test", tn)
ch.Add(
fmt.Sprintf("%s RUN (%s)", packageNameFull, duration.Round(time.Millisecond)),
y,
startAfter,
duration,
durationToRgb(run, pr.MaxDuration),
)
}
slog.Debug("PlotlyChart", "chart", ch)
charts = append(charts, ch)
}
return charts
}