Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add metadata to Flakeguard report (#1473)
Browse files Browse the repository at this point in the history
lukaszcl authored and Tofel committed Dec 16, 2024

Partially verified

This commit is signed with the committer’s verified signature.
Tofel’s contribution has been verified via SSH key.
We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
1 parent 54cc588 commit f041164
Showing 2 changed files with 34 additions and 12 deletions.
30 changes: 24 additions & 6 deletions tools/flakeguard/cmd/aggregate_results.go
Original file line number Diff line number Diff line change
@@ -24,6 +24,10 @@ var AggregateResultsCmd = &cobra.Command{
maxPassRatio, _ := cmd.Flags().GetFloat64("max-pass-ratio")
codeOwnersPath, _ := cmd.Flags().GetString("codeowners-path")
repoPath, _ := cmd.Flags().GetString("repo-path")
repoURL, _ := cmd.Flags().GetString("repo-url")
headSHA, _ := cmd.Flags().GetString("head-sha")
baseSHA, _ := cmd.Flags().GetString("base-sha")
githubWorkflowName, _ := cmd.Flags().GetString("github-workflow-name")

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

// Aggregate the reports
aggregatedReport, err := reports.Aggregate(testReports...)

// Add metadata to the aggregated report
aggregatedReport.HeadSHA = headSHA
aggregatedReport.BaseSHA = baseSHA
aggregatedReport.RepoURL = repoURL
aggregatedReport.GitHubWorkflowName = githubWorkflowName

if err != nil {
s.Stop()
return fmt.Errorf("error aggregating test reports: %w", err)
@@ -98,12 +109,15 @@ var AggregateResultsCmd = &cobra.Command{

// Create a new report for failed tests with logs
failedReportWithLogs := &reports.TestReport{
GoProject: aggregatedReport.GoProject,
TestRunCount: aggregatedReport.TestRunCount,
RaceDetection: aggregatedReport.RaceDetection,
ExcludedTests: aggregatedReport.ExcludedTests,
SelectedTests: aggregatedReport.SelectedTests,
Results: failedTests,
GoProject: aggregatedReport.GoProject,
TestRunCount: aggregatedReport.TestRunCount,
RaceDetection: aggregatedReport.RaceDetection,
ExcludedTests: aggregatedReport.ExcludedTests,
SelectedTests: aggregatedReport.SelectedTests,
HeadSHA: aggregatedReport.HeadSHA,
BaseSHA: aggregatedReport.BaseSHA,
GitHubWorkflowName: aggregatedReport.GitHubWorkflowName,
Results: failedTests,
}

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

AggregateResultsCmd.MarkFlagRequired("results-path")
}
16 changes: 10 additions & 6 deletions tools/flakeguard/reports/data.go
Original file line number Diff line number Diff line change
@@ -11,12 +11,16 @@ import (
// Data Structures

type TestReport struct {
GoProject string
TestRunCount int
RaceDetection bool
ExcludedTests []string
SelectedTests []string
Results []TestResult
GoProject string
HeadSHA string
BaseSHA string
RepoURL string
GitHubWorkflowName string
TestRunCount int
RaceDetection bool
ExcludedTests []string
SelectedTests []string
Results []TestResult
}

type TestResult struct {

0 comments on commit f041164

Please sign in to comment.