go.temporal.io/server/tools/testrunner/summary.go

127 LOC · 71 covered · 56 uncovered · 23 ranges · 21 concepts · 12 introducers · 16 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the filesummary.go ×1 · 2 introduced LOCsummary.go ×1TestRenderSummaryFromReports_JSON · 0 introduced LOCTestRenderSummaryFromRep…TestNewSummaryFromReports_KeepsFailureAndAlertRows · 0 introduced LOCTestNewSummaryFromReport…testrunner.go ×5 · 7 introduced LOCtestrunner.go ×5TestRenderSummaryFromReports_Markdown_RendersTrimmedFailureBody · 0 introduced LOCTestRenderSummaryFromRep…TestNewSummaryFromReports_RendersAssertionFailureRow · 0 introduced LOCTestNewSummaryFromReport…TestNewSummaryFromReports_RendersTrimmedFailureBodyRow · 0 introduced LOCTestNewSummaryFromReport…testrunner.go ×1 · 3 introduced LOCtestrunner.go ×1testrunner.go ×8 · 18 introduced LOCtestrunner.go ×8TestRenderSummaryFromReports_Markdown_RendersAlertRow · 0 introduced LOCTestRenderSummaryFromRep…summary.go ×1 · 3 introduced LOCsummary.go ×1summary.go ×1 · 2 introduced LOCsummary.go ×1summary.go ×1 · 3 introduced LOCsummary.go ×1summary.go ×2 · 3 introduced LOCsummary.go ×2summary.go ×1 · 3 introduced LOCsummary.go ×1summary.go ×1 · 2 introduced LOCsummary.go ×1summary.go ×7 · 28 introduced LOCsummary.go ×7summary.go ×4 · 11 introduced LOCsummary.go ×4summary.go ×1 · 4 introduced LOCsummary.go ×1summary.go ×2 · 8 introduced LOCsummary.go ×2summary.go ×1 · 2 introduced LOCsummary.go ×1TestNewSummaryFromReports_EmptyWhenNoFailures · introduced test · go.temporal.io/server/tools/testrunner/TestNewSummaryFromReports_EmptyWhenNoFailuresTestNewSummaryFromReport…TestNewSummaryFromReports_KeepsFailureAndAlertRows · introduced test · go.temporal.io/server/tools/testrunner/TestNewSummaryFromReports_KeepsFailureAndAlertRowsTestNewSummaryFromReport…TestNewSummaryFromReports_MergesMultipleReports · introduced test · go.temporal.io/server/tools/testrunner/TestNewSummaryFromReports_MergesMultipleReportsTestNewSummaryFromReport…TestNewSummaryFromReports_RendersAlertRow · introduced test · go.temporal.io/server/tools/testrunner/TestNewSummaryFromReports_RendersAlertRowTestNewSummaryFromReport…TestNewSummaryFromReports_RendersAssertionFailureRow · introduced test · go.temporal.io/server/tools/testrunner/TestNewSummaryFromReports_RendersAssertionFailureRowTestNewSummaryFromReport…TestNewSummaryFromReports_RendersTrimmedFailureBodyRow · introduced test · go.temporal.io/server/tools/testrunner/TestNewSummaryFromReports_RendersTrimmedFailureBodyRowTestNewSummaryFromReport…TestNewSummaryRow_TruncatesOversizedDetail · introduced test · go.temporal.io/server/tools/testrunner/TestNewSummaryRow_TruncatesOversizedDetailTestNewSummaryRow_Trunca…TestRenderSummaryFromReports_JSON · introduced test · go.temporal.io/server/tools/testrunner/TestRenderSummaryFromReports_JSONTestRenderSummaryFromRep…TestRenderSummaryFromReports_Markdown_EmptyWhenNoFailures · introduced test · go.temporal.io/server/tools/testrunner/TestRenderSummaryFromReports_Markdown_EmptyWhenNoFailuresTestRenderSummaryFromRep…TestRenderSummaryFromReports_Markdown_OmitsRowsWhenBudgetExceeded · introduced test · go.temporal.io/server/tools/testrunner/TestRenderSummaryFromReports_Markdown_OmitsRowsWhenBudgetExceededTestRenderSummaryFromRep…TestRenderSummaryFromReports_Markdown_RendersAlertRow · introduced test · go.temporal.io/server/tools/testrunner/TestRenderSummaryFromReports_Markdown_RendersAlertRowTestRenderSummaryFromRep…TestRenderSummaryFromReports_Markdown_RendersFailureRows · introduced test · go.temporal.io/server/tools/testrunner/TestRenderSummaryFromReports_Markdown_RendersFailureRowsTestRenderSummaryFromRep…TestRenderSummaryFromReports_Markdown_RendersTrimmedFailureBody · introduced test · go.temporal.io/server/tools/testrunner/TestRenderSummaryFromReports_Markdown_RendersTrimmedFailureBodyTestRenderSummaryFromRep…TestRenderSummaryFromReports_Markdown_ShowsTruncatedDetail · introduced test · go.temporal.io/server/tools/testrunner/TestRenderSummaryFromReports_Markdown_ShowsTruncatedDetailTestRenderSummaryFromRep…TestRunnerPrintSummary · introduced test · go.temporal.io/server/tools/testrunner/TestRunnerPrintSummaryTestRunnerPrintSummaryTestRunnerPrintSummarySkipsEmptySummary · introduced test · go.temporal.io/server/tools/testrunner/TestRunnerPrintSummarySkipsEmptySummaryTestRunnerPrintSummarySk…Focused file · go.temporal.io/server/tools/testrunner/summary.go · 127 LOCtestrunner/summary.go

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 package testrunner
2
3 import (
4 "encoding/json"
5 "fmt"
6 "html"
7 "slices"
8 "strings"
9 )
10
11 const summaryMaxDetailBytes = 4 * 1024
12 const summaryMarkdownMaxBytes = 1000 * 1024
13 const summaryTruncatedMarker = "\n… (truncated - see full output in job logs)\n"
14
15 type summary struct {
16 Rows []summaryRow `json:"rows"`
17 }
18
19 > func newSummaryFromReports(reports []*junitReport) summary { summary.go ×4
20 > return summary{
21 > Rows: newSummaryRowsFromReports(reports),
22 > }
23 > }
24
25 // Markdown renders the GitHub step summary HTML and enforces both the total
26 // summary budget and per-row detail truncation.
27 > func (s summary) Markdown() string { summary.go ×1
28 > if len(s.Rows) == 0 {
29 > return "" summary.go ×1
30 > }
31
32 > var sb strings.Builder summary.go ×7
33 > sb.WriteString("<table>\n<tr><th>Kind</th><th>Test</th></tr>\n")
34 >
35 > // Reserve bytes for the closing tag so we can always finish the table.
36 > const tableClose = "</table>\n"
37 > budget := summaryMarkdownMaxBytes - sb.Len() - len(tableClose)
38 >
39 > written := 0
40 > for _, row := range s.Rows {
41 > rendered := row.Markdown()
42 > if len(rendered) > budget {
43 > omitted := len(s.Rows) - written summary.go ×1
44 > fmt.Fprintf(&sb, "<tr><td colspan=\"2\">… %d failure(s) not shown — see full output in job logs</td></tr>\n", omitted)
45 > break
46 }
47 > sb.WriteString(rendered) summary.go ×7
48 > budget -= len(rendered)
49 > written++
50 }
51
52 > sb.WriteString(tableClose) summary.go ×7
53 > return sb.String()
54 }
55
56 > func (s summary) JSON() ([]byte, error) { summary.go ×1
57 > return json.MarshalIndent(s, "", " ")
58 > }
59
60 // summaryRow is a single failure entry rendered in both Markdown and JSON summaries.
61 type summaryRow struct {
62 Kind failureType `json:"kind"`
63 Name string `json:"name"` // test or alert name
64 Details string `json:"details,omitempty"` // failure body
65 Final bool `json:"final,omitempty"`
66 }
67
68 > func newSummaryRowsFromReports(reports []*junitReport) []summaryRow { summary.go ×4
69 > var rows []summaryRow
70 > for _, report := range reports {
71 > for _, suite := range report.Suites {
72 > for _, tc := range suite.Testcases { summary.go ×2
73 > if tc.Failure == nil {
74 continue
75 }
76 > rows = append(rows, newSummaryRow(failureType(tc.Failure.Type), tc.Name, tc.Failure.Data)) summary.go ×2
77 }
78 }
79 }
80 > slices.SortFunc(rows, func(a, b summaryRow) int { summary.go ×4
81 > if byName := strings.Compare(a.Name, b.Name); byName != 0 { summary.go ×1
82 > return byName
83 > }
84 if byKind := strings.Compare(string(a.Kind), string(b.Kind)); byKind != 0 {
85 return byKind
86 }
87 return strings.Compare(a.Details, b.Details)
88 })
89 > return rows summary.go ×4
90 }
91
92 > func newSummaryRow(kind failureType, name string, details string) summaryRow { summary.go ×2
93 > if len(details) > summaryMaxDetailBytes {
94 > headBytes := (summaryMaxDetailBytes - len(summaryTruncatedMarker)) / 2 summary.go ×1
95 > tailBytes := summaryMaxDetailBytes - len(summaryTruncatedMarker) - headBytes
96 > details = details[:headBytes] + summaryTruncatedMarker + details[len(details)-tailBytes:]
97 > }
98 > return summaryRow{ summary.go ×2
99 > Kind: kind,
100 > Name: name,
101 > Details: details,
102 > Final: strings.Contains(name, "(final)"),
103 > }
104 }
105
106 // Markdown renders one summary table row.
107 > func (row summaryRow) Markdown() string { summary.go ×7
108 > kind := string(row.Kind)
109 > if row.Final {
110 > kind = "❌ " + kind summary.go ×1
111 > }
112
113 > var sb strings.Builder summary.go ×7
114 > fmt.Fprintf(&sb, "<tr><td>%s</td><td>", html.EscapeString(kind))
115 > if row.Details != "" {
116 > escaped := html.EscapeString(row.Details)
117 > if strings.Contains(row.Details, summaryTruncatedMarker) {
118 > escaped += "\n… (truncated — see full output in job logs)" summary.go ×1
119 > }
120 > fmt.Fprintf(&sb, "<details><summary>%s</summary><pre>%s</pre></details>", summary.go ×7
121 > html.EscapeString(row.Name), escaped)
122 } else {
123 sb.WriteString(html.EscapeString(row.Name))
124 }
125 > sb.WriteString("</td></tr>\n") summary.go ×7
126 > return sb.String()
127 }