aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-07-28 19:55:41 +0200
committerDmitry Vyukov <dvyukov@google.com>2017-07-28 20:14:24 +0200
commit032fb6f70ae1f26d2febedb6c566e341aaa5e039 (patch)
treed253590997e28bb09c64d3bd4fe6f27782e5d7fc
parentc579f3e6127a770c69716abec1c94c5033a073e7 (diff)
syz-ci: send commits to dashboard
Dashboard needs to know when bug fixing commits reach builders in order to fully close bugs. Send commits that dashboard is interested in to dashboard.
-rw-r--r--pkg/git/git.go19
-rw-r--r--syz-ci/manager.go31
2 files changed, 46 insertions, 4 deletions
diff --git a/pkg/git/git.go b/pkg/git/git.go
index a3bdcec00..a239453f8 100644
--- a/pkg/git/git.go
+++ b/pkg/git/git.go
@@ -68,18 +68,29 @@ func clone(dir, repo, branch string) error {
// HeadCommit returns hash of the HEAD commit of the current branch of git repository in dir.
func HeadCommit(dir string) (string, error) {
- output, err := osutil.RunCmd(timeout, dir, "git", "log", "--pretty=format:'%H'", "-n", "1")
+ output, err := osutil.RunCmd(timeout, dir, "git", "log", "--pretty=format:%H", "-n", "1")
if err != nil {
return "", err
}
if len(output) != 0 && output[len(output)-1] == '\n' {
output = output[:len(output)-1]
}
- if len(output) != 0 && output[0] == '\'' && output[len(output)-1] == '\'' {
- output = output[1 : len(output)-1]
- }
if len(output) != 40 {
return "", fmt.Errorf("unexpected git log output, want commit hash: %q", output)
}
return string(output), nil
}
+
+// ListRecentCommits returns list of commit titles for the last year starting from baseCommit.
+func ListRecentCommits(dir, baseCommit string) ([]string, error) {
+ since := time.Now().Add(-time.Hour * 24 * 365).Format("01-02-2006")
+ // On upstream kernel this produces 3.5MB of output.
+ // Somewhat inefficient to collect whole output in a slice
+ // and then convert to string, but should be bearable.
+ output, err := osutil.RunCmd(timeout, dir, "git", "log",
+ "--pretty=format:%s", "--no-merges", "--since", since, baseCommit)
+ if err != nil {
+ return nil, err
+ }
+ return strings.Split(string(output), "\n"), nil
+}
diff --git a/syz-ci/manager.go b/syz-ci/manager.go
index b530a4813..c4f5b9d59 100644
--- a/syz-ci/manager.go
+++ b/syz-ci/manager.go
@@ -363,6 +363,11 @@ func (mgr *Manager) uploadBuild(info *BuildInfo) error {
if err != nil {
return fmt.Errorf("failed to read kernel.config: %v", err)
}
+ commits, err := mgr.pollCommits(info.KernelCommit)
+ if err != nil {
+ // This is not critical for operation.
+ Logf(0, "%v: failed to poll commits: %v", mgr.name, err)
+ }
build := &dashapi.Build{
Manager: mgr.name,
ID: info.Tag,
@@ -372,6 +377,32 @@ func (mgr *Manager) uploadBuild(info *BuildInfo) error {
KernelBranch: info.KernelBranch,
KernelCommit: info.KernelCommit,
KernelConfig: kernelConfig,
+ Commits: commits,
}
return mgr.dash.UploadBuild(build)
}
+
+// pollCommits asks dashboard what commits it is interested in (i.e. fixes for
+// open bugs) and returns subset of these commits that are present in a build
+// on commit buildCommit.
+func (mgr *Manager) pollCommits(buildCommit string) ([]string, error) {
+ resp, err := mgr.dash.BuilderPoll(mgr.name)
+ if err != nil || len(resp.PendingCommits) == 0 {
+ return nil, err
+ }
+ commits, err := git.ListRecentCommits(mgr.kernelDir, buildCommit)
+ if err != nil {
+ return nil, err
+ }
+ m := make(map[string]bool, len(commits))
+ for _, com := range commits {
+ m[com] = true
+ }
+ var present []string
+ for _, com := range resp.PendingCommits {
+ if m[com] {
+ present = append(present, com)
+ }
+ }
+ return present, nil
+}