Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Unified Diff: appengine/cmd/milo/buildbot/build.go

Issue 2102903002: Milo: Extract the rietveld information from buildbot. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: comment Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | appengine/cmd/milo/buildbot/expectations/CrWinGoma.30608.build.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/cmd/milo/buildbot/build.go
diff --git a/appengine/cmd/milo/buildbot/build.go b/appengine/cmd/milo/buildbot/build.go
index 772075574d632ba24656e48420e8d9507de46da7..141a11943c79a1a4596caaa8270aaf02555321c0 100644
--- a/appengine/cmd/milo/buildbot/build.go
+++ b/appengine/cmd/milo/buildbot/build.go
@@ -341,6 +341,53 @@ func blame(b *buildbotBuild) (result []*resp.Commit) {
return
}
+// sourcestamp extracts the source stamp from various parts of a buildbot build,
+// including the properties.
+func sourcestamp(c context.Context, b *buildbotBuild) *resp.SourceStamp {
+ ss := &resp.SourceStamp{}
+ rietveld := ""
+ issue := int64(-1)
+ // TODO(hinoka): Gerrit URLs.
+ for _, prop := range b.Properties {
+ key := prop[0].(string)
+ value := prop[1]
+ switch key {
+ case "rietveld":
+ if v, ok := value.(string); ok {
+ rietveld = v
+ } else {
+ log.Warningf(c, "Field rietveld is not a string: %#v", value)
+ }
+ case "issue":
+ if v, ok := value.(float64); ok {
+ issue = int64(v)
+ } else {
+ log.Warningf(c, "Field issue is not a float: %#v", value)
+ }
+
+ case "got_revision":
+ if v, ok := value.(string); ok {
+ ss.Revision = v
+ } else {
+ log.Warningf(c, "Field got_revision is not a string: %#v", value)
+ }
+
+ }
+ }
+ if issue != -1 {
+ if rietveld != "" {
+ rietveld = strings.TrimRight(rietveld, "/")
+ ss.Changelist = &resp.Link{
+ Label: fmt.Sprintf("Issue %d", issue),
+ URL: fmt.Sprintf("%s/%d", rietveld, issue),
+ }
+ } else {
+ log.Warningf(c, "Found issue but not rietveld property.")
+ }
+ }
+ return ss
+}
+
func getDebugBuild(c context.Context, builder, buildNum string) (*buildbotBuild, error) {
fname := fmt.Sprintf("%s.%s.json", builder, buildNum)
path := filepath.Join("testdata", "buildbot", fname)
@@ -365,7 +412,9 @@ func build(c context.Context, master, builder, buildNum string) (*resp.MiloBuild
return nil, err
}
+ // TODO(hinoka): Do all fields concurrently.
return &resp.MiloBuild{
+ SourceStamp: sourcestamp(c, b),
Summary: summary(b),
Components: components(b),
PropertyGroup: properties(b),
« no previous file with comments | « no previous file | appengine/cmd/milo/buildbot/expectations/CrWinGoma.30608.build.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698