Skip to content

Commit b098053

Browse files
committed
Uses proper JSON for flakeguard
1 parent 3dded98 commit b098053

File tree

2 files changed

+35
-34
lines changed

2 files changed

+35
-34
lines changed

tools/flakeguard/reports/data.go

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,44 @@ import (
88
"time"
99
)
1010

11-
// Data Structures
12-
11+
// TestReport reports on the parameters and results of one to many test runs
1312
type TestReport struct {
14-
GoProject string
15-
HeadSHA string
16-
BaseSHA string
17-
RepoURL string
18-
GitHubWorkflowName string
19-
TestRunCount int
20-
RaceDetection bool
21-
ExcludedTests []string
22-
SelectedTests []string
23-
Results []TestResult
13+
GoProject string `json:"go_project"`
14+
HeadSHA string `json:"head_sha"`
15+
BaseSHA string `json:"base_sha"`
16+
RepoURL string `json:"repo_url"`
17+
GitHubWorkflowName string `json:"github_workflow_name"`
18+
TestRunCount int `json:"test_run_count"`
19+
RaceDetection bool `json:"race_detection"`
20+
ExcludedTests []string `json:"excluded_tests"`
21+
SelectedTests []string `json:"selected_tests"`
22+
Results []TestResult `json:"results"`
2423
}
2524

25+
// TestResult contains the results and outputs of a single test
2626
type TestResult struct {
27-
TestName string
28-
TestPackage string
29-
PackagePanic bool
30-
Panic bool
31-
Timeout bool
32-
Race bool
33-
Skipped bool
34-
PassRatio float64
35-
Runs int
36-
Failures int
37-
Successes int
38-
Skips int
39-
Outputs map[string][]string `json:"-"` // Temporary storage for outputs during test run
40-
PassedOutputs map[string][]string // Outputs for passed runs
41-
FailedOutputs map[string][]string // Outputs for failed runs
42-
Durations []time.Duration
43-
PackageOutputs []string
44-
TestPath string
45-
CodeOwners []string
27+
TestName string `json:"test_name"`
28+
TestPackage string `json:"test_package"`
29+
PackagePanic bool `json:"package_panic"`
30+
Panic bool `json:"panic"`
31+
Timeout bool `json:"timeout"`
32+
Race bool `json:"race"`
33+
Skipped bool `json:"skipped"`
34+
PassRatio float64 `json:"pass_ratio"`
35+
Runs int `json:"runs"`
36+
Failures int `json:"failures"`
37+
Successes int `json:"successes"`
38+
Skips int `json:"skips"`
39+
Outputs map[string][]string `json:"-"` // Temporary storage for outputs during test run
40+
PassedOutputs map[string][]string `json:"passed_outputs"` // Outputs for passed runs
41+
FailedOutputs map[string][]string `json:"failed_outputs"` // Outputs for failed runs
42+
Durations []time.Duration `json:"durations"`
43+
PackageOutputs []string `json:"package_outputs"`
44+
TestPath string `json:"test_path"`
45+
CodeOwners []string `json:"code_owners"`
4646
}
4747

48+
// SummaryData contains aggregated data from a set of test results
4849
type SummaryData struct {
4950
TotalTests int `json:"total_tests"`
5051
PanickedTests int `json:"panicked_tests"`

tools/flakeguard/reports/presentation.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func GeneratePRCommentMarkdown(w io.Writer, testReport *TestReport, maxPassRatio
146146
}
147147

148148
resultsTable := GenerateFlakyTestsTable(testReport.Results, maxPassRatio, true)
149-
renderTestResultsTable(w, resultsTable, true)
149+
renderTestResultsTable(w, resultsTable)
150150

151151
if artifactLink != "" {
152152
renderArtifactSection(w, artifactName, artifactLink)
@@ -179,7 +179,7 @@ func RenderResults(
179179
resultsTable := GenerateFlakyTestsTable(tests, maxPassRatio, markdown)
180180
summary := GenerateSummaryData(tests, maxPassRatio)
181181
renderSummaryTable(w, summary, markdown)
182-
renderTestResultsTable(w, resultsTable, markdown)
182+
renderTestResultsTable(w, resultsTable)
183183
}
184184

185185
func renderSummaryTable(w io.Writer, summary SummaryData, markdown bool) {
@@ -209,7 +209,7 @@ func renderSummaryTable(w io.Writer, summary SummaryData, markdown bool) {
209209
fmt.Fprintln(w)
210210
}
211211

212-
func renderTestResultsTable(w io.Writer, table [][]string, markdown bool) {
212+
func renderTestResultsTable(w io.Writer, table [][]string) {
213213
if len(table) <= 1 {
214214
fmt.Fprintln(w, "No tests found under the specified pass ratio threshold.")
215215
return

0 commit comments

Comments
 (0)