Skip to content

Commit 82671ab

Browse files
committed
maintner/maintnerd/maintapi: adjust heuristic for tip version
The vast majority of the time, when Go 1.X (or Go 1.X.Y) is the latest supported Go release, non-release branches are used for developing the next Go 1.(X+1) version and not the same Go 1.X version. Adjust the imperfect heuristic used to determine the Go version from the branch name by taking this into account. Make the output from the TestFindTryWork test easier to read, as it's expensive to add test coverage for this change elsewhere. For golang/go#42341. Fixes golang/go#42377. Updates golang/go#42376. Change-Id: I70b21662f2a4c853d14a0928f8bd7361fc6aafd6 Reviewed-on: https://go-review.googlesource.com/c/build/+/267677 Run-TryBot: Dmitri Shuralyov <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Carlos Amedee <[email protected]> Reviewed-by: Alexander Rakoczy <[email protected]> Trust: Dmitri Shuralyov <[email protected]>
1 parent 4c544cb commit 82671ab

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

maintner/maintnerd/maintapi/api.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,11 @@ func goFindTryWork(ctx context.Context, gerritc *gerrit.Client, maintc *maintner
249249
if err != nil {
250250
return nil, err
251251
}
252+
// If Go X.Y is the latest supported release, the version in development is likely Go X.(Y+1).
253+
develVersion := &apipb.MajorMinor{
254+
Major: supportedReleases[0].Major,
255+
Minor: supportedReleases[0].Minor + 1,
256+
}
252257

253258
res := new(apipb.GoFindTryWorkResponse)
254259
for _, ci := range cis {
@@ -264,26 +269,23 @@ func goFindTryWork(ctx context.Context, gerritc *gerrit.Client, maintc *maintner
264269
work := tryWorkItem(cl, ci, comments)
265270
if work.Project == "go" {
266271
// Trybot on Go repo. Set the GoVersion field based on branch name.
267-
if work.Branch == "master" {
268-
latest := supportedReleases[0]
269-
work.GoVersion = []*apipb.MajorMinor{{latest.Major, latest.Minor}}
270-
} else if major, minor, ok := parseReleaseBranchVersion(work.Branch); ok {
272+
if major, minor, ok := parseReleaseBranchVersion(work.Branch); ok {
271273
// A release branch like release-branch.goX.Y.
272274
// Use the major-minor Go version determined from the branch name.
273275
work.GoVersion = []*apipb.MajorMinor{{major, minor}}
274276
} else {
275-
// A branch that is neither master nor release-branch.goX.Y.
276-
// I don't see a straightforward way to compute its version,
277-
// so use the latest Go release until we need to do more.
278-
latest := supportedReleases[0]
279-
work.GoVersion = []*apipb.MajorMinor{{latest.Major, latest.Minor}}
277+
// A branch that is not release-branch.goX.Y: maybe
278+
// "master" or a development branch like "dev.link".
279+
// There isn't a way to determine the version from its name,
280+
// so use the development Go version until we need to do more.
281+
// TODO(golang.org/issue/42376): This can be made more precise.
282+
work.GoVersion = []*apipb.MajorMinor{develVersion}
280283
}
281284
} else {
282285
// Trybot on a subrepo. Set the Go fields to master and the supported releases.
283286
work.GoCommit = []string{goProj.Ref("refs/heads/master").String()}
284287
work.GoBranch = []string{"master"}
285-
latest := supportedReleases[0]
286-
work.GoVersion = []*apipb.MajorMinor{{latest.Major, latest.Minor}}
288+
work.GoVersion = []*apipb.MajorMinor{develVersion}
287289
for _, r := range supportedReleases {
288290
work.GoCommit = append(work.GoCommit, r.BranchCommit)
289291
work.GoBranch = append(work.GoBranch, r.BranchName)

maintner/maintnerd/maintapi/api_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"testing"
1515
"time"
1616

17+
"github.com/golang/protobuf/proto"
1718
"github.com/google/go-cmp/cmp"
1819
"golang.org/x/build/gerrit"
1920
"golang.org/x/build/maintner"
@@ -61,7 +62,7 @@ var hitGerrit = flag.Bool("hit_gerrit", false, "query production Gerrit in TestF
6162

6263
func TestFindTryWork(t *testing.T) {
6364
if !*hitGerrit {
64-
t.Skip("skipping without flag --hit_gerrit")
65+
t.Skip("skipping without flag -hit_gerrit")
6566
}
6667
c := getGoData(t)
6768
s := apiService{c}
@@ -75,13 +76,13 @@ func TestFindTryWork(t *testing.T) {
7576

7677
// Just for interactive debugging. This is using live data.
7778
// The stable tests are in TestTryWorkItem and TestTryBotStatus.
78-
t.Logf("Current: %v", res)
79+
t.Logf("Current:\n%v", proto.MarshalTextString(res))
7980

8081
t1 := time.Now()
81-
res, err = s.GoFindTryWork(context.Background(), req)
82+
res2, err := s.GoFindTryWork(context.Background(), req)
8283
d1 := time.Since(t1)
8384
t.Logf("Latency: %v, then %v", d0, d1)
84-
t.Logf("Cached: %v, %v", res, err)
85+
t.Logf("Cached: equal=%v, err=%v", proto.Equal(res, res2), err)
8586
}
8687

8788
func TestTryBotStatus(t *testing.T) {

0 commit comments

Comments
 (0)