Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds branch name to Flakeguard reports #1618

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tools/flakeguard/cmd/aggregate_results.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var AggregateResultsCmd = &cobra.Command{
codeOwnersPath, _ := cmd.Flags().GetString("codeowners-path")
repoPath, _ := cmd.Flags().GetString("repo-path")
repoURL, _ := cmd.Flags().GetString("repo-url")
branchName, _ := cmd.Flags().GetString("branch-name")
headSHA, _ := cmd.Flags().GetString("head-sha")
baseSHA, _ := cmd.Flags().GetString("base-sha")
githubWorkflowName, _ := cmd.Flags().GetString("github-workflow-name")
Expand All @@ -52,6 +53,7 @@ var AggregateResultsCmd = &cobra.Command{
resultsPath,
reports.WithReportID(reportID),
reports.WithSplunk(splunkURL, splunkToken, splunkEvent),
reports.WithBranchName(branchName),
reports.WithBaseSha(baseSHA),
reports.WithHeadSha(headSHA),
reports.WithRepoURL(repoURL),
Expand Down Expand Up @@ -199,6 +201,7 @@ func init() {
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("branch-name", "", "Branch name for the test report")
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")
Expand Down
1 change: 1 addition & 0 deletions tools/flakeguard/reports/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
type TestReport struct {
ID string `json:"id"`
GoProject string `json:"go_project"`
BranchName string `json:"branch_name,omitempty"`
HeadSHA string `json:"head_sha,omitempty"`
BaseSHA string `json:"base_sha,omitempty"`
RepoURL string `json:"repo_url,omitempty"`
Expand Down
12 changes: 12 additions & 0 deletions tools/flakeguard/reports/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type aggregateOptions struct {
splunkURL string
splunkToken string
splunkEvent string
branchName string
baseSha string
headSha string
repoURL string
Expand All @@ -69,6 +70,12 @@ func WithSplunk(url, token string, event string) AggregateOption {
}
}

func WithBranchName(branchName string) AggregateOption {
return func(opts *aggregateOptions) {
opts.branchName = branchName
}
}

// WithHeadSha sets the head SHA for the aggregated report.
func WithHeadSha(headSha string) AggregateOption {
return func(opts *aggregateOptions) {
Expand Down Expand Up @@ -208,6 +215,10 @@ func decodeField(decoder *json.Decoder, report *TestReport) error {
if err := decoder.Decode(&report.GoProject); err != nil {
return fmt.Errorf("error decoding GoProject: %w", err)
}
case "branch_name":
if err := decoder.Decode(&report.BranchName); err != nil {
return fmt.Errorf("error decoding BranchName: %w", err)
}
case "head_sha":
if err := decoder.Decode(&report.HeadSHA); err != nil {
return fmt.Errorf("error decoding HeadSHA: %w", err)
Expand Down Expand Up @@ -361,6 +372,7 @@ func aggregate(reportChan <-chan *TestReport, errChan <-chan error, opts *aggreg
var (
fullReport = &TestReport{
ID: opts.reportID,
BranchName: opts.branchName,
BaseSHA: opts.baseSha,
HeadSHA: opts.headSha,
RepoURL: opts.repoURL,
Expand Down
Loading