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

Side by Side Diff: milo/api/resp/build.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 | « no previous file | milo/api/resp/builder.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 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 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 //go:generate stringer -type=Status,ComponentType,Verbosity 5 //go:generate stringer -type=Verbosity
6 //go:generate stringer -type=ComponentType
6 7
7 package resp 8 package resp
8 9
9 import ( 10 import (
10 "encoding/json" 11 "encoding/json"
11 "time" 12 "time"
13
14 "github.com/luci/luci-go/milo/appengine/common/model"
12 ) 15 )
13 16
14 // MiloBuild denotes a full renderable Milo build page. 17 // MiloBuild denotes a full renderable Milo build page.
15 type MiloBuild struct { 18 type MiloBuild struct {
16 // Summary is a top level summary of the page. 19 // Summary is a top level summary of the page.
17 Summary BuildComponent 20 Summary BuildComponent
18 21
19 // SourceStamp gives information about how the build came about. 22 // SourceStamp gives information about how the build came about.
20 SourceStamp *SourceStamp 23 SourceStamp *SourceStamp
21 24
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 // disable the tooltip. 105 // disable the tooltip.
103 total uint64 106 total uint64
104 107
105 // The number of entries completed. Shows up as <progress> / <total>. 108 // The number of entries completed. Shows up as <progress> / <total>.
106 progress uint64 109 progress uint64
107 110
108 // A number between 0 to 100 denoting the percentage completed. 111 // A number between 0 to 100 denoting the percentage completed.
109 percent uint32 112 percent uint32
110 } 113 }
111 114
112 // Status is a discrete status for the purpose of colorizing a component.
113 // These are based off the Material Design Bootstrap color palettes.
114 type Status int
115
116 const (
117 // NotRun if the component has not yet been run.
118 NotRun Status = iota // 100 Gray
119
120 // Running if the component is currently running.
121 Running // 100 Teal
122
123 // Success if the component has finished executing and is not noteworthy .
124 Success // A200 Green
125
126 // Failure if the component has finished executing and contains a failur e.
127 Failure // A200 Red
128
129 // Warning just like from the buildbot days.
130 Warning // 200 Yellow
131
132 // InfraFailure if the component has finished incompletely due to a fail ure in infra.
133 InfraFailure // A100 Purple
134
135 // Exception if the component has finished incompletely and unexpectedly . This
136 // is used for buildbot builds.
137 Exception // A100 Purple
138
139 // Expired if the component was never scheduled due to resource exhausti on.
140 Expired // A200 Purple
141
142 // DependencyFailure if the component has finished incompletely due to a failure in a
143 // dependency.
144 DependencyFailure // 100 Amber
145
146 // WaitingDependency if the component has finished or paused execution d ue to an
147 // incomplete dep.
148 WaitingDependency // 100 Brown
149 )
150
151 // Terminal returns true if the step status won't change.
152 func (s Status) Terminal() bool {
153 switch s {
154 case Success, Failure, InfraFailure, Warning, DependencyFailure, Expired :
155 return true
156 default:
157 return false
158 }
159 }
160
161 // MarshalJSON renders enums into String rather than an int when marshalling.
162 func (s Status) MarshalJSON() ([]byte, error) {
163 return json.Marshal(s.String())
164 }
165
166 // ComponentType is the type of build component. 115 // ComponentType is the type of build component.
167 type ComponentType int 116 type ComponentType int
168 117
169 const ( 118 const (
170 // Recipe corresponds to a full recipe run. Dependencies are recipes. 119 // Recipe corresponds to a full recipe run. Dependencies are recipes.
171 Recipe ComponentType = iota 120 Recipe ComponentType = iota
172 121
173 // Step is a single step of a recipe. 122 // Step is a single step of a recipe.
174 Step 123 Step
175 124
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 // BuildComponent represents a single Step, subsetup, attempt, or recipe. 157 // BuildComponent represents a single Step, subsetup, attempt, or recipe.
209 type BuildComponent struct { 158 type BuildComponent struct {
210 // The parent of this component. For buildbot and swarmbucket builds, t his 159 // The parent of this component. For buildbot and swarmbucket builds, t his
211 // refers to the builder. For DM, this refers to whatever triggered the Quest. 160 // refers to the builder. For DM, this refers to whatever triggered the Quest.
212 ParentLabel *Link `json:",omitempty"` 161 ParentLabel *Link `json:",omitempty"`
213 162
214 // The main label for the component. 163 // The main label for the component.
215 Label string 164 Label string
216 165
217 // Status of the build. 166 // Status of the build.
218 » Status Status 167 » Status model.Status
219 168
220 // Banner is a banner of logos that define the OS and devices this 169 // Banner is a banner of logos that define the OS and devices this
221 // component is associated with. 170 // component is associated with.
222 Banner *LogoBanner `json:",omitempty"` 171 Banner *LogoBanner `json:",omitempty"`
223 172
224 // Bot is the machine or execution instance that this component ran on. 173 // Bot is the machine or execution instance that this component ran on.
225 Bot *Link `json:",omitempty"` 174 Bot *Link `json:",omitempty"`
226 175
227 // Recipe is a link to the recipe this component is based on. 176 // Recipe is a link to the recipe this component is based on.
228 Recipe *Link `json:",omitempty"` 177 Recipe *Link `json:",omitempty"`
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 } 234 }
286 235
287 // LinkSet is an ordered collection of Link objects that will be rendered on the 236 // LinkSet is an ordered collection of Link objects that will be rendered on the
288 // same line. 237 // same line.
289 type LinkSet []*Link 238 type LinkSet []*Link
290 239
291 // Link denotes a single labeled link. 240 // Link denotes a single labeled link.
292 // 241 //
293 // JSON tags here are for test expectations. 242 // JSON tags here are for test expectations.
294 type Link struct { 243 type Link struct {
295 » // Title of the link. Shows up as the main label. 244 » model.Link
296 » Label string
297
298 » // The destination for the link, stuck in a <a href> tag.
299 » URL string
300 245
301 // An icon for the link. Not compatible with label. Rendered as <img> 246 // An icon for the link. Not compatible with label. Rendered as <img>
302 Img string `json:",omitempty"` 247 Img string `json:",omitempty"`
303 248
304 // Alt text for the image, only supported with img. 249 // Alt text for the image, only supported with img.
305 Alt string `json:",omitempty"` 250 Alt string `json:",omitempty"`
306 251
307 // Alias, if true, means that this link is an [alias link]. 252 // Alias, if true, means that this link is an [alias link].
308 Alias bool `json:",omitempty"` 253 Alias bool `json:",omitempty"`
309 } 254 }
255
256 // NewLink does just about what you'd expect.
257 func NewLink(label, url string) *Link {
258 return &Link{Link: model.Link{Label: label, URL: url}}
259 }
OLDNEW
« no previous file with comments | « no previous file | milo/api/resp/builder.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698