Skip to content

Commit 3612d23

Browse files
committed
Adds branch name to Flakeguard reports
1 parent 45f933c commit 3612d23

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

tools/flakeguard/cmd/aggregate_results.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var AggregateResultsCmd = &cobra.Command{
2727
codeOwnersPath, _ := cmd.Flags().GetString("codeowners-path")
2828
repoPath, _ := cmd.Flags().GetString("repo-path")
2929
repoURL, _ := cmd.Flags().GetString("repo-url")
30+
branchName, _ := cmd.Flags().GetString("branch-name")
3031
headSHA, _ := cmd.Flags().GetString("head-sha")
3132
baseSHA, _ := cmd.Flags().GetString("base-sha")
3233
githubWorkflowName, _ := cmd.Flags().GetString("github-workflow-name")
@@ -52,6 +53,7 @@ var AggregateResultsCmd = &cobra.Command{
5253
resultsPath,
5354
reports.WithReportID(reportID),
5455
reports.WithSplunk(splunkURL, splunkToken, splunkEvent),
56+
reports.WithBranchName(branchName),
5557
reports.WithBaseSha(baseSHA),
5658
reports.WithHeadSha(headSHA),
5759
reports.WithRepoURL(repoURL),
@@ -199,6 +201,7 @@ func init() {
199201
AggregateResultsCmd.Flags().StringP("codeowners-path", "", "", "Path to the CODEOWNERS file")
200202
AggregateResultsCmd.Flags().StringP("repo-path", "", ".", "The path to the root of the repository/project")
201203
AggregateResultsCmd.Flags().String("repo-url", "", "The repository URL")
204+
AggregateResultsCmd.Flags().String("branch-name", "", "Branch name for the test report")
202205
AggregateResultsCmd.Flags().String("head-sha", "", "Head commit SHA for the test report")
203206
AggregateResultsCmd.Flags().String("base-sha", "", "Base commit SHA for the test report")
204207
AggregateResultsCmd.Flags().String("github-workflow-name", "", "GitHub workflow name for the test report")

tools/flakeguard/reports/data.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
type TestReport struct {
1212
ID string `json:"id"`
1313
GoProject string `json:"go_project"`
14+
BranchName string `json:"branch_name,omitempty"`
1415
HeadSHA string `json:"head_sha,omitempty"`
1516
BaseSHA string `json:"base_sha,omitempty"`
1617
RepoURL string `json:"repo_url,omitempty"`

tools/flakeguard/reports/io.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type aggregateOptions struct {
4343
splunkURL string
4444
splunkToken string
4545
splunkEvent string
46+
branchName string
4647
baseSha string
4748
headSha string
4849
repoURL string
@@ -69,6 +70,12 @@ func WithSplunk(url, token string, event string) AggregateOption {
6970
}
7071
}
7172

73+
func WithBranchName(branchName string) AggregateOption {
74+
return func(opts *aggregateOptions) {
75+
opts.branchName = branchName
76+
}
77+
}
78+
7279
// WithHeadSha sets the head SHA for the aggregated report.
7380
func WithHeadSha(headSha string) AggregateOption {
7481
return func(opts *aggregateOptions) {
@@ -208,6 +215,10 @@ func decodeField(decoder *json.Decoder, report *TestReport) error {
208215
if err := decoder.Decode(&report.GoProject); err != nil {
209216
return fmt.Errorf("error decoding GoProject: %w", err)
210217
}
218+
case "branch_name":
219+
if err := decoder.Decode(&report.BranchName); err != nil {
220+
return fmt.Errorf("error decoding BranchName: %w", err)
221+
}
211222
case "head_sha":
212223
if err := decoder.Decode(&report.HeadSHA); err != nil {
213224
return fmt.Errorf("error decoding HeadSHA: %w", err)
@@ -361,6 +372,7 @@ func aggregate(reportChan <-chan *TestReport, errChan <-chan error, opts *aggreg
361372
var (
362373
fullReport = &TestReport{
363374
ID: opts.reportID,
375+
BranchName: opts.branchName,
364376
BaseSHA: opts.baseSha,
365377
HeadSHA: opts.headSha,
366378
RepoURL: opts.repoURL,

0 commit comments

Comments
 (0)