@@ -111,14 +111,22 @@ func DefaultIssueFilerFromFormatter(
111
111
112
112
}
113
113
114
- func getFailurePosterFromFormatterName (formatterName string ) FailurePoster {
114
+ func getFailurePosterFromFormatterName (formatterName string , extraLabels [] string ) FailurePoster {
115
115
var reqFromFailure Formatter
116
116
switch formatterName {
117
117
case "pebble-metamorphic" :
118
118
reqFromFailure = formatPebbleMetamorphicIssue
119
119
default :
120
120
reqFromFailure = DefaultFormatter
121
121
}
122
+ if len (extraLabels ) > 0 {
123
+ reqFromFailure2 := func (ctx context.Context , f Failure ) (issues.IssueFormatter , issues.PostRequest ) {
124
+ i , r := reqFromFailure (ctx , f )
125
+ r .Labels = append (r .Labels , extraLabels ... )
126
+ return i , r
127
+ }
128
+ reqFromFailure = reqFromFailure2
129
+ }
122
130
return DefaultIssueFilerFromFormatter (reqFromFailure )
123
131
}
124
132
@@ -129,7 +137,7 @@ func getFailurePosterFromFormatterName(formatterName string) FailurePoster {
129
137
// GitHub.
130
138
func PostFromJSON (formatterName string , in io.Reader ) {
131
139
ctx := context .Background ()
132
- fileIssue := getFailurePosterFromFormatterName (formatterName )
140
+ fileIssue := getFailurePosterFromFormatterName (formatterName , [] string {} )
133
141
if err := listFailuresFromJSON (ctx , in , fileIssue ); err != nil {
134
142
log .Println (err ) // keep going
135
143
}
@@ -138,10 +146,13 @@ func PostFromJSON(formatterName string, in io.Reader) {
138
146
// PostFromTestXMLWithFormatterName consumes a Bazel-style `test.xml` stream
139
147
// and posts issues for any failed tests to GitHub. If there are no failed
140
148
// tests, it does nothing. Unlike PostFromTestXMLWithFailurePoster, it takes a
141
- // formatter name.
142
- func PostFromTestXMLWithFormatterName (formatterName string , testXml buildutil.TestSuites ) error {
149
+ // formatter name. extraLabels is a list of extra labels to apply to the
150
+ // created GitHub issue.
151
+ func PostFromTestXMLWithFormatterName (
152
+ formatterName string , testXml buildutil.TestSuites , extraLabels []string ,
153
+ ) error {
143
154
ctx := context .Background ()
144
- fileIssue := getFailurePosterFromFormatterName (formatterName )
155
+ fileIssue := getFailurePosterFromFormatterName (formatterName , extraLabels )
145
156
return PostFromTestXMLWithFailurePoster (ctx , fileIssue , testXml )
146
157
}
147
158
@@ -738,7 +749,7 @@ func formatPebbleMetamorphicIssue(
738
749
// insight into what caused the build failure and can't properly assign owners,
739
750
// so a general issue is filed against test-eng in this case.
740
751
func PostGeneralFailure (formatterName , logs string ) {
741
- fileIssue := getFailurePosterFromFormatterName (formatterName )
752
+ fileIssue := getFailurePosterFromFormatterName (formatterName , [] string {} )
742
753
postGeneralFailureImpl (logs , fileIssue )
743
754
}
744
755
0 commit comments