Skip to content

Commit 08a489d

Browse files
committed
teamcity: add s390x-test-failure label for relevant unit test failures
Epic: CRDB-21133 Release note: None
1 parent 8987f66 commit 08a489d

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

build/teamcity/cockroach/ci/tests-ibm-cloud-linux-s390x/unit_tests_impl.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ TESTS=$(bazel query 'kind(go_test, pkg/...) except attr("tags", "[\[ ]integratio
2020

2121
set -x
2222

23-
$(bazel info bazel-bin)/pkg/cmd/bazci/bazci_/bazci -- test --config=ci --config=dev \
24-
$TESTS \
25-
--profile=/artifacts/profile.gz
23+
$(bazel info bazel-bin)/pkg/cmd/bazci/bazci_/bazci --extralabels=s390x-test-failure -- \
24+
test --config=ci --config=dev \
25+
$TESTS \
26+
--profile=/artifacts/profile.gz

pkg/cmd/bazci/bazci.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ var (
6161
port int
6262
artifactsDir string
6363
githubPostFormatterName string
64+
extraLabels []string
6465

6566
rootCmd = &cobra.Command{
6667
Use: "bazci",
@@ -286,6 +287,12 @@ func init() {
286287
8998,
287288
"port to run the bazci server on",
288289
)
290+
rootCmd.Flags().StringSliceVar(
291+
&extraLabels,
292+
"extralabels",
293+
[]string{},
294+
"comma-separated list of extra labels to add to any filed GitHub issues",
295+
)
289296
}
290297

291298
func getRunEnvForBeaverHub() string {
@@ -488,7 +495,7 @@ func processTestXmls(testXmls []string) error {
488495
postErrors = append(postErrors, fmt.Sprintf("Failed to parse test.xml file with the following error: %+v", err))
489496
continue
490497
}
491-
if err := githubpost.PostFromTestXMLWithFormatterName(githubPostFormatterName, testSuites); err != nil {
498+
if err := githubpost.PostFromTestXMLWithFormatterName(githubPostFormatterName, testSuites, extraLabels); err != nil {
492499
postErrors = append(postErrors, fmt.Sprintf("Failed to process %s with the following error: %+v", testXml, err))
493500
continue
494501
}

pkg/cmd/bazci/githubpost/githubpost.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,22 @@ func DefaultIssueFilerFromFormatter(
111111

112112
}
113113

114-
func getFailurePosterFromFormatterName(formatterName string) FailurePoster {
114+
func getFailurePosterFromFormatterName(formatterName string, extraLabels []string) FailurePoster {
115115
var reqFromFailure Formatter
116116
switch formatterName {
117117
case "pebble-metamorphic":
118118
reqFromFailure = formatPebbleMetamorphicIssue
119119
default:
120120
reqFromFailure = DefaultFormatter
121121
}
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+
}
122130
return DefaultIssueFilerFromFormatter(reqFromFailure)
123131
}
124132

@@ -129,7 +137,7 @@ func getFailurePosterFromFormatterName(formatterName string) FailurePoster {
129137
// GitHub.
130138
func PostFromJSON(formatterName string, in io.Reader) {
131139
ctx := context.Background()
132-
fileIssue := getFailurePosterFromFormatterName(formatterName)
140+
fileIssue := getFailurePosterFromFormatterName(formatterName, []string{})
133141
if err := listFailuresFromJSON(ctx, in, fileIssue); err != nil {
134142
log.Println(err) // keep going
135143
}
@@ -138,10 +146,13 @@ func PostFromJSON(formatterName string, in io.Reader) {
138146
// PostFromTestXMLWithFormatterName consumes a Bazel-style `test.xml` stream
139147
// and posts issues for any failed tests to GitHub. If there are no failed
140148
// 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 {
143154
ctx := context.Background()
144-
fileIssue := getFailurePosterFromFormatterName(formatterName)
155+
fileIssue := getFailurePosterFromFormatterName(formatterName, extraLabels)
145156
return PostFromTestXMLWithFailurePoster(ctx, fileIssue, testXml)
146157
}
147158

@@ -738,7 +749,7 @@ func formatPebbleMetamorphicIssue(
738749
// insight into what caused the build failure and can't properly assign owners,
739750
// so a general issue is filed against test-eng in this case.
740751
func PostGeneralFailure(formatterName, logs string) {
741-
fileIssue := getFailurePosterFromFormatterName(formatterName)
752+
fileIssue := getFailurePosterFromFormatterName(formatterName, []string{})
742753
postGeneralFailureImpl(logs, fileIssue)
743754
}
744755

0 commit comments

Comments
 (0)