Skip to content

Commit f4c2dc4

Browse files
craig[bot]rickystewart
andcommitted
158623: team: delete duplicate `TEAMS.yaml` file r=rail a=rickystewart There's no reason for this to be checked into the repo twice; the copy in the repo root is sufficient. Release note: none Epic: none 158632: ci: ensure we correctly report owners for generated tests r=rail,srosenberg,herkolategan,williamchoe3 a=rickystewart To do so, generate code before any time where we would be filing issues to test owners. Closes: #107885 Release note: none Epic: CRDB-36213 Co-authored-by: Ricky Stewart <[email protected]>
3 parents 7d2d635 + 106ff56 + 7ce7a36 commit f4c2dc4

File tree

8 files changed

+88
-101
lines changed

8 files changed

+88
-101
lines changed

.github/workflows/github-actions-essential-ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,11 @@ jobs:
262262
- run: ./build/github/prepare-summarize-build.sh
263263
- name: run tests
264264
run: ./build/github/unit-tests.sh
265+
- name: generate code
266+
if: failure()
267+
# NB: To correctly report test owners, we'll have to make sure all Go
268+
# code is generated and hoisted into the workspace (#107885).
269+
run: ./build/github/generate-go-code.sh
265270
- name: upload test results
266271
run: ./build/github/summarize-build.sh bes.bin
267272
if: always()

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ build/variables.mk
5858
*.pb.gw.go
5959
pkg/ccl/kvccl/kvtenantccl/upgradeinterlockccl/generated_test.go
6060
pkg/backup/data_driven_generated_test.go
61+
pkg/internal/teams/TEAMS.yaml
6162
pkg/testutils/serverutils/*_generated.go
6263

6364
# Temporary directories during gomock generate

build/github/generate-go-code.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2025 The Cockroach Authors.
4+
#
5+
# Use of this software is governed by the CockroachDB Software License
6+
# included in the /LICENSE file.
7+
8+
set -euo pipefail
9+
10+
ENGFLOW_ARGS="--config crosslinux --jobs 50 $(./build/github/engflow-args.sh) --remote_download_minimal"
11+
12+
bazel run //pkg/gen:code $ENGFLOW_ARGS

pkg/build/util/util.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,18 @@ type XMLMessage struct {
6161
Contents string `xml:",chardata"`
6262
}
6363

64+
// AnyFailures returns true iff there are any errors/failures in the test.xml.
65+
func AnyFailures(suites TestSuites) bool {
66+
for _, suite := range suites.Suites {
67+
for _, testCase := range suite.TestCases {
68+
if testCase.Failure != nil || testCase.Error != nil {
69+
return true
70+
}
71+
}
72+
}
73+
return false
74+
}
75+
6476
// OutputOfBinaryRule returns the path of the binary produced by the
6577
// given build target, relative to bazel-bin. That is,
6678
//

pkg/build/util/util_test.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,48 @@ import (
1313
"github.com/stretchr/testify/require"
1414
)
1515

16+
func TestAnyFailures(t *testing.T) {
17+
xml1 := `<testsuites>
18+
<testsuite errors="0" failures="0" skipped="0" tests="1" time="0.000" name="github.com/cockroachdb/cockroach/pkg/build/util.TestMergeXml" timestamp="2025-12-02T20:59:24.432Z">
19+
<testcase classname="util" name="TestMergeXml" time="0.000"></testcase>
20+
</testsuite>
21+
<testsuite errors="0" failures="0" skipped="0" tests="1" time="0.000" name="github.com/cockroachdb/cockroach/pkg/build/util.TestMungeTestXML" timestamp="2025-12-02T20:59:24.433Z">
22+
<testcase classname="util" name="TestMungeTestXML" time="0.000"></testcase>
23+
</testsuite>
24+
<testsuite errors="0" failures="0" skipped="0" tests="1" time="0.000" name="github.com/cockroachdb/cockroach/pkg/build/util.TestOutputOfBinaryRule" timestamp="2025-12-02T20:59:24.432Z">
25+
<testcase classname="util" name="TestOutputOfBinaryRule" time="0.000"></testcase>
26+
</testsuite>
27+
<testsuite errors="0" failures="0" skipped="0" tests="1" time="0.000" name="github.com/cockroachdb/cockroach/pkg/build/util.TestOutputsOfGenrule" timestamp="2025-12-02T20:59:24.432Z">
28+
<testcase classname="util" name="TestOutputsOfGenrule" time="0.000"></testcase>
29+
</testsuite>
30+
</testsuites>`
31+
xml2 := `<testsuites>
32+
<testsuite errors="0" failures="1" skipped="0" tests="1" time="0.000" name="github.com/cockroachdb/cockroach/pkg/build/util.TestAnyFailures" timestamp="2025-12-02T21:01:33.393Z">
33+
<testcase classname="util" name="TestAnyFailures" time="0.000">
34+
<failure message="Failed" type="">=== RUN TestAnyFailures&#xA; util_test.go:33: &#xA; &#x9;Error Trace:&#x9;pkg/build/util/util_test.go:33&#xA; &#x9;Error: &#x9;An error is expected but got nil.&#xA; &#x9;Test: &#x9;TestAnyFailures&#xA;--- FAIL: TestAnyFailures (0.00s)&#xA;</failure>
35+
</testcase>
36+
</testsuite>
37+
<testsuite errors="0" failures="0" skipped="0" tests="1" time="0.000" name="github.com/cockroachdb/cockroach/pkg/build/util.TestMergeXml" timestamp="2025-12-02T21:01:33.393Z">
38+
<testcase classname="util" name="TestMergeXml" time="0.000"></testcase>
39+
</testsuite>
40+
<testsuite errors="0" failures="0" skipped="0" tests="1" time="0.000" name="github.com/cockroachdb/cockroach/pkg/build/util.TestMungeTestXML" timestamp="2025-12-02T21:01:33.393Z">
41+
<testcase classname="util" name="TestMungeTestXML" time="0.000"></testcase>
42+
</testsuite>
43+
<testsuite errors="0" failures="0" skipped="0" tests="1" time="0.000" name="github.com/cockroachdb/cockroach/pkg/build/util.TestOutputOfBinaryRule" timestamp="2025-12-02T21:01:33.393Z">
44+
<testcase classname="util" name="TestOutputOfBinaryRule" time="0.000"></testcase>
45+
</testsuite>
46+
<testsuite errors="0" failures="0" skipped="0" tests="1" time="0.000" name="github.com/cockroachdb/cockroach/pkg/build/util.TestOutputsOfGenrule" timestamp="2025-12-02T21:01:33.393Z">
47+
<testcase classname="util" name="TestOutputsOfGenrule" time="0.000"></testcase>
48+
</testsuite>
49+
</testsuites>`
50+
51+
var suite1, suite2 TestSuites
52+
require.NoError(t, xml.Unmarshal([]byte(xml1), &suite1))
53+
require.False(t, AnyFailures(suite1))
54+
require.NoError(t, xml.Unmarshal([]byte(xml2), &suite2))
55+
require.True(t, AnyFailures(suite2))
56+
}
57+
1658
func TestOutputOfBinaryRule(t *testing.T) {
1759
require.Equal(t, OutputOfBinaryRule("//pkg/cmd/cockroach-short", false),
1860
"pkg/cmd/cockroach-short/cockroach-short_/cockroach-short")

pkg/cmd/bazci/bazci.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,9 @@ func removeEmergencyBallasts() {
484484
}
485485

486486
func processTestXmls(testXmls []string) error {
487+
// If any tests failed, we'll have to make sure that all generated code
488+
// exists in the workspace (see #107885).
489+
var generateCode sync.Once
487490
if doPost() {
488491
var postErrors []string
489492
for _, testXml := range testXmls {
@@ -498,6 +501,17 @@ func processTestXmls(testXmls []string) error {
498501
postErrors = append(postErrors, fmt.Sprintf("Failed to parse test.xml file with the following error: %+v", err))
499502
continue
500503
}
504+
if bazelutil.AnyFailures(testSuites) {
505+
generateCode.Do(func() {
506+
genCmd := exec.Command("bazel", "run", "//pkg/gen:code")
507+
genCmd.Stdout = os.Stdout
508+
genCmd.Stderr = os.Stderr
509+
err := genCmd.Run()
510+
if err != nil {
511+
fmt.Printf("got error %+v from bazel run //pkg/gen:code; continuing", err)
512+
}
513+
})
514+
}
501515
if err := githubpost.PostFromTestXMLWithFormatterName(githubPostFormatterName, testSuites, extraLabels); err != nil {
502516
postErrors = append(postErrors, fmt.Sprintf("Failed to process %s with the following error: %+v", testXml, err))
503517
continue

pkg/internal/codeowners/codeowners.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -169,19 +169,8 @@ func (co *CodeOwners) GetTestOwner(
169169
panic("test-eng team could not be found in TEAMS.yaml")
170170
}
171171

172-
// Workaround for #107885.
173-
if strings.Contains(packageName, "backup") {
174-
dr := co.GetTeamForAlias("cockroachdb/disaster-recovery")
175-
if dr.Name() == "" {
176-
panic("disaster-recovery team could not be found in TEAMS.yaml")
177-
}
178-
179-
_logs = append(_logs, fmt.Sprintf("assigning %s.%s to 'disaster-recovery' due to #107885", packageName, testName))
180-
_teams = []team.Team{dr}
181-
} else {
182-
_logs = append(_logs, fmt.Sprintf("assigning %s.%s to 'test-eng' as catch-all", packageName, testName))
183-
_teams = []team.Team{testEng}
184-
}
172+
_logs = append(_logs, fmt.Sprintf("assigning %s.%s to 'test-eng' as catch-all", packageName, testName))
173+
_teams = []team.Team{testEng}
185174
}
186175
return
187176
}

pkg/internal/team/TEAMS.yaml

Lines changed: 0 additions & 88 deletions
This file was deleted.

0 commit comments

Comments
 (0)