Skip to content

Commit 74be200

Browse files
committed
Add head-sha, base-sha and github-workflow-name to flakeguard report
1 parent 634ce9d commit 74be200

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

tools/flakeguard/cmd/aggregate_results.go

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ var AggregateResultsCmd = &cobra.Command{
2424
maxPassRatio, _ := cmd.Flags().GetFloat64("max-pass-ratio")
2525
codeOwnersPath, _ := cmd.Flags().GetString("codeowners-path")
2626
repoPath, _ := cmd.Flags().GetString("repo-path")
27+
headSHA, _ := cmd.Flags().GetString("head-sha")
28+
baseSHA, _ := cmd.Flags().GetString("base-sha")
29+
githubWorkflowName, _ := cmd.Flags().GetString("github-workflow-name")
2730

2831
// Ensure the output directory exists
2932
if err := fs.MkdirAll(outputDir, 0755); err != nil {
@@ -51,6 +54,10 @@ var AggregateResultsCmd = &cobra.Command{
5154

5255
// Aggregate the reports
5356
aggregatedReport, err := reports.Aggregate(testReports...)
57+
aggregatedReport.HeadSHA = headSHA
58+
aggregatedReport.BaseSHA = baseSHA
59+
aggregatedReport.GitHubWorkflowName = githubWorkflowName
60+
5461
if err != nil {
5562
s.Stop()
5663
return fmt.Errorf("error aggregating test reports: %w", err)
@@ -98,12 +105,15 @@ var AggregateResultsCmd = &cobra.Command{
98105

99106
// Create a new report for failed tests with logs
100107
failedReportWithLogs := &reports.TestReport{
101-
GoProject: aggregatedReport.GoProject,
102-
TestRunCount: aggregatedReport.TestRunCount,
103-
RaceDetection: aggregatedReport.RaceDetection,
104-
ExcludedTests: aggregatedReport.ExcludedTests,
105-
SelectedTests: aggregatedReport.SelectedTests,
106-
Results: failedTests,
108+
GoProject: aggregatedReport.GoProject,
109+
TestRunCount: aggregatedReport.TestRunCount,
110+
RaceDetection: aggregatedReport.RaceDetection,
111+
ExcludedTests: aggregatedReport.ExcludedTests,
112+
SelectedTests: aggregatedReport.SelectedTests,
113+
HeadSHA: aggregatedReport.HeadSHA,
114+
BaseSHA: aggregatedReport.BaseSHA,
115+
GitHubWorkflowName: aggregatedReport.GitHubWorkflowName,
116+
Results: failedTests,
107117
}
108118

109119
// Save the failed tests report with logs
@@ -171,6 +181,9 @@ func init() {
171181
AggregateResultsCmd.Flags().Float64P("max-pass-ratio", "", 1.0, "The maximum pass ratio threshold for a test to be considered flaky")
172182
AggregateResultsCmd.Flags().StringP("codeowners-path", "", "", "Path to the CODEOWNERS file")
173183
AggregateResultsCmd.Flags().StringP("repo-path", "", ".", "The path to the root of the repository/project")
184+
AggregateResultsCmd.Flags().String("head-sha", "", "Head commit SHA for the test report")
185+
AggregateResultsCmd.Flags().String("base-sha", "", "Base commit SHA for the test report")
186+
AggregateResultsCmd.Flags().String("github-workflow-name", "", "GitHub workflow name for the test report")
174187

175188
AggregateResultsCmd.MarkFlagRequired("results-path")
176189
}

tools/flakeguard/reports/data.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ import (
1111
// Data Structures
1212

1313
type TestReport struct {
14-
GoProject string
15-
TestRunCount int
16-
RaceDetection bool
17-
ExcludedTests []string
18-
SelectedTests []string
19-
Results []TestResult
14+
GoProject string
15+
TestRunCount int
16+
RaceDetection bool
17+
ExcludedTests []string
18+
SelectedTests []string
19+
Results []TestResult
20+
HeadSHA string
21+
BaseSHA string
22+
GitHubWorkflowName string
2023
}
2124

2225
type TestResult struct {

0 commit comments

Comments
 (0)