Skip to content

Commit 1a4bcd6

Browse files
committed
cmd/coordinator: use corresponding Go for x repo release branch with suffix
When a golang.org/x repo release branch is being tested, the intention is to test it with the same Go version where it will be used, rather than the latest Go version in development plus prior releases of Go. The previous equality check was very strict and did not work for golang.org/x release branches with a dash-separated suffix. We have a need for such release branches occasionally and want them to work. Fixes golang/go#42127. Change-Id: I934b540f83a2b8c616e3d3a5477fb3c471aa595b Reviewed-on: https://go-review.googlesource.com/c/build/+/264203 Run-TryBot: Dmitri Shuralyov <[email protected]> TryBot-Result: Go Bot <[email protected]> Trust: Dmitri Shuralyov <[email protected]> Reviewed-by: Alexander Rakoczy <[email protected]>
1 parent 2476803 commit 1a4bcd6

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

cmd/coordinator/coordinator.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,8 +1216,11 @@ func newTrySet(work *apipb.GerritTryWorkItem) *trySet {
12161216
// By default, use the first GoCommit, which represents Go tip (master branch).
12171217
goRev = work.GoCommit[0]
12181218
}
1219-
for i, branch := range work.GoBranch {
1220-
if branch == work.Branch {
1219+
for i, goBranch := range work.GoBranch {
1220+
// There are two cases where we want to change goRev to work.GoCommit[i]:
1221+
// 1. CL branch is like "master" or "release-branch.go1.15" and matches the Go branch exactly.
1222+
// 2. CL branch is like "release-branch.go1.15-suffix" and its prefix matches.
1223+
if work.Branch == goBranch || strings.HasPrefix(work.Branch, goBranch+"-") {
12211224
goRev = work.GoCommit[i]
12221225
}
12231226
}

cmd/coordinator/coordinator_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,33 @@ func TestIssue28891(t *testing.T) {
180180
}
181181
}
182182

183+
// Test that trybot on release-branch.go1.N-{suffix} branch of a golang.org/x repo
184+
// uses the Go revision from Go repository's release-branch.go1.N branch.
185+
// See golang.org/issue/42127.
186+
func TestIssue42127(t *testing.T) {
187+
testingKnobSkipBuilds = true
188+
189+
work := &apipb.GerritTryWorkItem{ // Roughly based on https://go-review.googlesource.com/c/net/+/264058/1.
190+
Project: "net",
191+
Branch: "release-branch.go1.15-bundle",
192+
ChangeId: "I546597cedf3715e6617babcb3b62140bf1857a27",
193+
Commit: "286322bb8662ddff3686e42a01c33a1d47d25153",
194+
GoCommit: []string{"b2a8317b31d652b3ee293a313269b8290bcdf96c", "3b1f07fff774f86f13316f7bec6552566568fc10", "768b64711ae4292bd9a02c9cc8d44282f5fac66b"},
195+
GoBranch: []string{"master", "release-branch.go1.15", "release-branch.go1.14"},
196+
GoVersion: []*apipb.MajorMinor{{1, 16}, {1, 15}, {1, 14}},
197+
}
198+
ts := newTrySet(work)
199+
if len(ts.builds) == 0 {
200+
t.Fatal("no builders in try set, want at least 1")
201+
}
202+
for i, bs := range ts.builds {
203+
const go115Revision = "3b1f07fff774f86f13316f7bec6552566568fc10"
204+
if bs.BuilderRev.Rev != go115Revision {
205+
t.Errorf("build[%d]: %s: x/net on release-branch.go1.15-bundle branch should be tested with Go 1.15, but isn't", i, bs.NameAndBranch())
206+
}
207+
}
208+
}
209+
183210
// tests that we don't test Go 1.10 for the build repo
184211
func TestNewTrySetBuildRepoGo110(t *testing.T) {
185212
testingKnobSkipBuilds = true

0 commit comments

Comments
 (0)