cmd/coordinator: fix formatting for x/ repo TryBots
This change also adds a test for the (*buildStatus).NameAndBranch
method. It also specifies which x/ repo TryBots ran for a given change.
Finally, it fixes the error of specifying which Go commit to run the x/
repos with.
Updates golang/go#34348
Change-Id: Ib63fa6948c3798a85174b382de38f2bc159b3347
Reviewed-on: https://go-review.googlesource.com/c/build/+/203917
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/cmd/coordinator/coordinator.go b/cmd/coordinator/coordinator.go
index 4afd624..70ff7b7 100644
--- a/cmd/coordinator/coordinator.go
+++ b/cmd/coordinator/coordinator.go
@@ -1057,6 +1057,7 @@
tryKey
tryID string // "T" + 9 random hex
slowBots []*dashboard.BuildConfig // any opt-in slower builders to run in a trybot run
+ xrepos []*buildStatus // any opt-in x/ repo builds to run in a trybot run
// wantedAsOf is guarded by statusMu and is used by
// findTryWork. It records the last time this tryKey was still
@@ -1232,7 +1233,7 @@
}
brev := buildgo.BuilderRev{
Name: linuxBuilder.Name,
- Rev: goRev,
+ Rev: work.Commit,
SubName: project,
SubRev: rev,
}
@@ -1241,7 +1242,7 @@
log.Printf("can't create build for %q: %v", rev, err)
continue
}
- bs.goBranch = branch
+ ts.xrepos = append(ts.xrepos, bs)
addBuilderToSet(bs, brev)
}
}
@@ -1449,6 +1450,12 @@
fmt.Fprintf(&buf, "* %s\n", c.Name)
}
}
+ if len(ts.xrepos) > 0 {
+ fmt.Fprintf(&buf, "Also tested the following repos:\n")
+ for _, st := range ts.xrepos {
+ fmt.Fprintf(&buf, st.NameAndBranch())
+ }
+ }
// TODO: provide a link in the final report that links to a permanent summary page
// of which builds ran, and for how long.
if len(benchResults) > 0 {
@@ -3364,6 +3371,11 @@
// special case:
return fmt.Sprintf("%s (go branch %s)", st.Name, st.goBranch)
}
+ // For an x repo running on a go CL, say
+ // "x/tools (linux-amd64)"
+ if st.SubName != "" {
+ return fmt.Sprintf("x/%s (%s)", st.SubName, st.Name)
+ }
return st.Name
}
diff --git a/cmd/coordinator/coordinator_test.go b/cmd/coordinator/coordinator_test.go
index 7a8c9f9..7eff854 100644
--- a/cmd/coordinator/coordinator_test.go
+++ b/cmd/coordinator/coordinator_test.go
@@ -271,3 +271,41 @@
t.Errorf("mismatch:\n got: %q\nwant: %q\n", got, want)
}
}
+
+func TestBuildStatusFormat(t *testing.T) {
+ for i, tt := range []struct {
+ st *buildStatus
+ want string
+ }{
+ {
+ st: &buildStatus{
+ BuilderRev: buildgo.BuilderRev{
+ Name: "linux-amd64",
+ SubName: "tools",
+ },
+ },
+ want: "x/tools (linux-amd64)",
+ },
+ {
+ st: &buildStatus{
+ BuilderRev: buildgo.BuilderRev{
+ Name: "darwin-amd64-10_14",
+ },
+ },
+ want: "darwin-amd64-10_14",
+ },
+ {
+ st: &buildStatus{
+ BuilderRev: buildgo.BuilderRev{
+ Name: "darwin-amd64-10_14",
+ },
+ goBranch: "release-branch.go1.15",
+ },
+ want: "darwin-amd64-10_14 (Go 1.15.x)",
+ },
+ } {
+ if got := tt.st.NameAndBranch(); got != tt.want {
+ t.Errorf("%d: NameAndBranch = %q; want %q", i, got, tt.want)
+ }
+ }
+}