Skip to content

Commit 7de18c7

Browse files
committed
Add support for rerun report ID in test report generation
1 parent bcdff42 commit 7de18c7

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

tools/flakeguard/cmd/generate_test_report.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ var GenerateTestReportCmd = &cobra.Command{
3434
githubWorkflowName, _ := cmd.Flags().GetString("github-workflow-name")
3535
githubWorkflowRunURL, _ := cmd.Flags().GetString("github-workflow-run-url")
3636
reportID, _ := cmd.Flags().GetString("report-id")
37+
rerunOfReportID, _ := cmd.Flags().GetString("rerun-of-report-id")
3738
genReportID, _ := cmd.Flags().GetBool("gen-report-id")
3839

3940
goProject, err := utils.GetGoProjectName(projectPath)
@@ -89,6 +90,7 @@ var GenerateTestReportCmd = &cobra.Command{
8990
reports.WithProjectPath(projectPath),
9091
reports.WithRepoPath(repoPath),
9192
reports.WithCodeOwnersPath(codeOwnersPath),
93+
reports.WithRerunOfReportID(rerunOfReportID),
9294
reports.WithReportID(reportID),
9395
reports.WithGeneratedReportID(genReportID),
9496
reports.WithGoRaceDetection(useRace),
@@ -142,6 +144,7 @@ var GenerateTestReportCmd = &cobra.Command{
142144
reports.WithProjectPath(projectPath),
143145
reports.WithRepoPath(repoPath),
144146
reports.WithCodeOwnersPath(codeOwnersPath),
147+
reports.WithRerunOfReportID(rerunOfReportID),
145148
reports.WithReportID(reportID),
146149
reports.WithGeneratedReportID(genReportID),
147150
reports.WithGoRaceDetection(useRace),
@@ -190,6 +193,7 @@ func init() {
190193
GenerateTestReportCmd.Flags().String("github-workflow-run-url", "", "GitHub workflow run URL for the test report")
191194
GenerateTestReportCmd.Flags().String("report-id", "", "Optional identifier for the test report. Will be generated if not provided")
192195
GenerateTestReportCmd.Flags().Bool("gen-report-id", false, "Generate a random report ID")
196+
GenerateTestReportCmd.Flags().String("rerun-of-report-id", "", "Optional identifier for the report this is a rerun of")
193197
GenerateTestReportCmd.Flags().Bool("race", false, "Enable the race detector")
194198

195199
if err := GenerateTestReportCmd.MarkFlagRequired("test-results-dir"); err != nil {

tools/flakeguard/reports/test_report.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
type reportOptions struct {
1717
maxPassRatio float64
1818
reportID string
19+
rerunOfReportID string
1920
projectPath string
2021
goProjectName string
2122
raceDetection bool
@@ -52,6 +53,12 @@ func WithReportID(reportID string) TestReportOption {
5253
}
5354
}
5455

56+
func WithRerunOfReportID(rerunOfReportID string) TestReportOption {
57+
return func(opts *reportOptions) {
58+
opts.rerunOfReportID = rerunOfReportID
59+
}
60+
}
61+
5562
func WithGeneratedReportID(genReportID bool) TestReportOption {
5663
return func(opts *reportOptions) {
5764
if !genReportID {
@@ -169,6 +176,7 @@ func NewTestReport(results []TestResult, opts ...TestReportOption) (TestReport,
169176

170177
r := TestReport{
171178
ID: defaultOpts.reportID,
179+
RerunOfReportID: defaultOpts.rerunOfReportID,
172180
ProjectPath: defaultOpts.projectPath,
173181
GoProject: defaultOpts.goProjectName,
174182
BranchName: defaultOpts.branchName,
@@ -212,6 +220,7 @@ func NewTestReport(results []TestResult, opts ...TestReportOption) (TestReport,
212220
// TestReport reports on the parameters and results of one to many test runs
213221
type TestReport struct {
214222
ID string `json:"id,omitempty"`
223+
RerunOfReportID string `json:"rerun_of_report_id,omitempty"` // references the ID of the original/base report from which this re-run was created.
215224
ProjectPath string `json:"project_path"`
216225
GoProject string `json:"go_project"`
217226
BranchName string `json:"branch_name,omitempty"`

0 commit comments

Comments
 (0)