Skip to content

Commit

Permalink
cmd/coordinator: fix trybots for the "dl" repo
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
bradfitz committed Apr 2, 2019
1 parent 49a6a61 commit e91d385
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
25 changes: 19 additions & 6 deletions cmd/coordinator/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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]
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion cmd/coordinator/dash.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit e91d385

Please sign in to comment.