From e91d385072ae9f21e65bfe0cff04f3e820a25c0c Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 2 Apr 2019 15:56:29 +0000 Subject: [PATCH] cmd/coordinator: fix trybots for the "dl" repo Don't assume that all repos have import path starting with "golang.org/x/". Add a new func instead. But in one place (finding GOPATH deps), just hard-code the old behavior of only looking for golang.org/x/ deps. That code will be deleted soonish anyway, so no point cleaning it up. Fixes golang/go#30852 Change-Id: Ic657549832da71d3915439875e456f323cf5ebdf Reviewed-on: https://go-review.googlesource.com/c/build/+/170417 Reviewed-by: Bryan C. Mills --- cmd/coordinator/coordinator.go | 25 +++++++++++++++++++------ cmd/coordinator/dash.go | 2 +- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/cmd/coordinator/coordinator.go b/cmd/coordinator/coordinator.go index 6d6816ba32..86d00142a9 100644 --- a/cmd/coordinator/coordinator.go +++ b/cmd/coordinator/coordinator.go @@ -67,8 +67,6 @@ import ( ) const ( - subrepoPrefix = "golang.org/x/" - // eventDone is a build event name meaning the build was // completed (either successfully or with remote errors). // Notably, it is NOT included for network/communication @@ -2347,7 +2345,7 @@ func (st *buildStatus) runSubrepoTests() (remoteErr, err error) { // findDeps uses 'go list' on the checked out repo to find its // dependencies, and adds any not-yet-fetched deps to toFetched. findDeps := func(repo string) (rErr, err error) { - repoPath := subrepoPrefix + repo + repoPath := importPathOfRepo(repo) var buf bytes.Buffer rErr, err = st.bc.Exec(path.Join("go", "bin", "go"), buildlet.ExecOpts{ Output: &buf, @@ -2363,10 +2361,10 @@ func (st *buildStatus) runSubrepoTests() (remoteErr, err error) { return rErr, nil } for _, p := range strings.Fields(buf.String()) { - if !strings.HasPrefix(p, subrepoPrefix) || strings.HasPrefix(p, repoPath) { + if !strings.HasPrefix(p, "golang.org/x/") || strings.HasPrefix(p, repoPath) { continue } - repo = strings.TrimPrefix(p, subrepoPrefix) + repo = strings.TrimPrefix(p, "golang.org/x/") if i := strings.Index(repo, "/"); i >= 0 { repo = repo[:i] } @@ -2428,7 +2426,7 @@ func (st *buildStatus) runSubrepoTests() (remoteErr, err error) { if st.conf.IsRace() { args = append(args, "-race") } - args = append(args, subrepoPrefix+st.SubName+"/...") + args = append(args, importPathOfRepo(st.SubName)+"/...") return st.bc.Exec(path.Join("go", "bin", "go"), buildlet.ExecOpts{ Debug: true, // make buildlet print extra debug in output for failures @@ -3353,3 +3351,18 @@ func randHex(n int) string { } return fmt.Sprintf("%x", buf)[:n] } + +// importPathOfRepo returns the Go import path corresponding to the +// root of the given repo (Gerrit project). Because it's a Go import +// path, it always has forward slashes and no trailing slash. +// +// For example: +// "net" -> "golang.org/x/net" +// "crypto" -> "golang.org/x/crypto" +// "dl" -> "golang.org/dl" +func importPathOfRepo(repo string) string { + if repo == "dl" { + return "golang.org/dl" + } + return "golang.org/x/" + repo +} diff --git a/cmd/coordinator/dash.go b/cmd/coordinator/dash.go index ba91a79267..b1555cc98c 100644 --- a/cmd/coordinator/dash.go +++ b/cmd/coordinator/dash.go @@ -105,7 +105,7 @@ func recordResult(br buildgo.BuilderRev, ok bool, buildLog string, runTime time. "RunTime": runTime, } if br.IsSubrepo() { - req["PackagePath"] = subrepoPrefix + br.SubName + req["PackagePath"] = importPathOfRepo(br.SubName) req["Hash"] = br.SubRev req["GoHash"] = br.Rev }