[tools][perfmon]: Minor improvements

* Ignore changes on non-main branches
* Increase the timeout for git cloning the repo
* Improve the error message on git error

Change-Id: I22af2b8042c14c3c413f52d65dc5b89b7f5c3f11
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/132820
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
Ben Clayton 2023-05-18 00:01:53 +00:00 committed by Dawn LUCI CQ
parent 59f4cfb03f
commit f4cb783626
2 changed files with 11 additions and 2 deletions

View File

@ -863,6 +863,11 @@ func (e env) findGerritChangeToBenchmark() (*gerrit.ChangeInfo, error) {
}
canBenchmark := func() bool {
// Don't benchmark changes on non-main branches
if change.Branch != "main" {
return false
}
// Is the change from a Googler, reviewed by a Googler or is from a allow-listed external developer?
if !(strings.HasSuffix(current.Commit.Committer.Email, "@google.com") ||
strings.HasSuffix(change.Labels["Code-Review"].Approved.Email, "@google.com") ||
@ -1045,6 +1050,7 @@ func createOrOpenGitRepo(g *git.Git, filepath string, cfg GitConfig) (*git.Repos
repo, err = g.Clone(filepath, cfg.URL, &git.CloneOptions{
Branch: cfg.Branch,
Credentials: cfg.Credentials,
Timeout: time.Minute * 30,
})
}
if err != nil {

View File

@ -472,8 +472,11 @@ func (g Git) run(dir string, env []string, timeout time.Duration, args ...string
fmt.Println(string(out))
}
if err != nil {
return string(out), fmt.Errorf("%v> %v %v failed:\n %w\n%v",
dir, g.exe, strings.Join(args, " "), err, string(out))
msg := fmt.Sprintf("%v> %v %v failed:", dir, g.exe, strings.Join(args, " "))
if err := ctx.Err(); err != nil {
msg += "\n" + err.Error()
}
return string(out), fmt.Errorf("%s\n %w\n%v", msg, err, string(out))
}
return strings.TrimSpace(string(out)), nil
}