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

Unified Diff: milo/appengine/common/model/status.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « milo/appengine/common/model/patch_info.go ('k') | milo/appengine/common/model/status_string.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: milo/appengine/common/model/status.go
diff --git a/milo/appengine/common/model/status.go b/milo/appengine/common/model/status.go
new file mode 100644
index 0000000000000000000000000000000000000000..7a99fbc9c8b03c3d1d776daa1640c95d3af1007d
--- /dev/null
+++ b/milo/appengine/common/model/status.go
@@ -0,0 +1,63 @@
+// Copyright 2017 The LUCI Authors. All rights reserved.
+// Use of this source code is governed under the Apache License, Version 2.0
+// that can be found in the LICENSE file.
+
+//go:generate stringer -type=Status
+
+package model
+
+import "encoding/json"
+
+// Status is a discrete status for the purpose of colorizing a component.
+// These are based off the Material Design Bootstrap color palettes.
+type Status int
+
+const (
+ // NotRun if the component has not yet been run.
+ NotRun Status = iota // 100 Gray
+
+ // Running if the component is currently running.
+ Running // 100 Teal
+
+ // Success if the component has finished executing and is not noteworthy.
+ Success // A200 Green
+
+ // Failure if the component has finished executing and contains a failure.
+ Failure // A200 Red
+
+ // Warning just like from the buildbot days.
+ Warning // 200 Yellow
+
+ // InfraFailure if the component has finished incompletely due to a failure in infra.
+ InfraFailure // A100 Purple
+
+ // Exception if the component has finished incompletely and unexpectedly. This
+ // is used for buildbot builds.
+ Exception // A100 Purple
+
+ // Expired if the component was never scheduled due to resource exhaustion.
+ Expired // A200 Purple
+
+ // DependencyFailure if the component has finished incompletely due to a failure in a
+ // dependency.
+ DependencyFailure // 100 Amber
+
+ // WaitingDependency if the component has finished or paused execution due to an
+ // incomplete dep.
+ WaitingDependency // 100 Brown
+)
+
+// Terminal returns true if the step status won't change.
+func (s Status) Terminal() bool {
+ switch s {
+ case Success, Failure, InfraFailure, Warning, DependencyFailure, Expired:
+ return true
+ default:
+ return false
+ }
+}
+
+// MarshalJSON renders enums into String rather than an int when marshalling.
+func (s Status) MarshalJSON() ([]byte, error) {
+ return json.Marshal(s.String())
+}
« no previous file with comments | « milo/appengine/common/model/patch_info.go ('k') | milo/appengine/common/model/status_string.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698