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

Side by Side Diff: milo/appengine/buildbot/builder.go

Issue 2944633003: [milo] Add BuildSummary and common models. (Closed)
Patch Set: add comments Created 3 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 unified diff | Download patch
« no previous file with comments | « milo/appengine/buildbot/build.go ('k') | milo/appengine/buildbot/console.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package buildbot 5 package buildbot
6 6
7 import ( 7 import (
8 "crypto/sha1" 8 "crypto/sha1"
9 "encoding/base64" 9 "encoding/base64"
10 "errors" 10 "errors"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 case "failed steps", "exception steps": 62 case "failed steps", "exception steps":
63 result = result[1:] 63 result = result[1:]
64 } 64 }
65 } 65 }
66 return result 66 return result
67 } 67 }
68 68
69 func getBuildSummary(b *buildbotBuild) *resp.BuildSummary { 69 func getBuildSummary(b *buildbotBuild) *resp.BuildSummary {
70 started, finished, duration := parseTimes(nil, b.Times) 70 started, finished, duration := parseTimes(nil, b.Times)
71 return &resp.BuildSummary{ 71 return &resp.BuildSummary{
72 » » Link: &resp.Link{ 72 » » Link: resp.NewLink(fmt.Sprintf("#%d", b.Number), fmt.Sprintf(" %d", b.Number)),
73 » » » URL: fmt.Sprintf("%d", b.Number),
74 » » » Label: fmt.Sprintf("#%d", b.Number),
75 » » },
76 Status: b.toStatus(), 73 Status: b.toStatus(),
77 ExecutionTime: resp.Interval{ 74 ExecutionTime: resp.Interval{
78 Started: started, 75 Started: started,
79 Finished: finished, 76 Finished: finished,
80 Duration: duration, 77 Duration: duration,
81 }, 78 },
82 Text: mergeText(b.Text), 79 Text: mergeText(b.Text),
83 Blame: blame(b), 80 Blame: blame(b),
84 Revision: b.Sourcestamp.Revision, 81 Revision: b.Sourcestamp.Revision,
85 } 82 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 func summarizeSlavePool( 164 func summarizeSlavePool(
168 baseURL string, slaves []string, slaveMap map[string]*buildbotSlave) *re sp.MachinePool { 165 baseURL string, slaves []string, slaveMap map[string]*buildbotSlave) *re sp.MachinePool {
169 166
170 mp := &resp.MachinePool{ 167 mp := &resp.MachinePool{
171 Total: len(slaves), 168 Total: len(slaves),
172 Bots: make([]resp.Bot, 0, len(slaves)), 169 Bots: make([]resp.Bot, 0, len(slaves)),
173 } 170 }
174 for _, slaveName := range slaves { 171 for _, slaveName := range slaves {
175 slave, ok := slaveMap[slaveName] 172 slave, ok := slaveMap[slaveName]
176 bot := resp.Bot{ 173 bot := resp.Bot{
177 » » » Name: resp.Link{ 174 » » » Name: *resp.NewLink(
178 » » » » Label: slaveName, 175 » » » » slaveName,
179 » » » » URL: fmt.Sprintf("%s/buildslaves/%s", baseURL, slaveName), 176 » » » » fmt.Sprintf("%s/buildslaves/%s", baseURL, slaveN ame),
180 » » » }, 177 » » » ),
181 } 178 }
182 switch { 179 switch {
183 case !ok: 180 case !ok:
184 // This shouldn't happen 181 // This shouldn't happen
185 case !slave.Connected: 182 case !slave.Connected:
186 bot.Status = resp.Disconnected 183 bot.Status = resp.Disconnected
187 mp.Disconnected++ 184 mp.Disconnected++
188 case len(slave.RunningbuildsMap) > 0: 185 case len(slave.RunningbuildsMap) > 0:
189 bot.Status = resp.Busy 186 bot.Status = resp.Busy
190 mp.Busy++ 187 mp.Busy++
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 } 289 }
293 result.CurrentBuilds = currentBuilds 290 result.CurrentBuilds = currentBuilds
294 291
295 for _, fb := range finishedBuilds { 292 for _, fb := range finishedBuilds {
296 if fb != nil { 293 if fb != nil {
297 result.FinishedBuilds = append(result.FinishedBuilds, fb ) 294 result.FinishedBuilds = append(result.FinishedBuilds, fb )
298 } 295 }
299 } 296 }
300 return result, nil 297 return result, nil
301 } 298 }
OLDNEW
« no previous file with comments | « milo/appengine/buildbot/build.go ('k') | milo/appengine/buildbot/console.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698