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

Unified Diff: go/autoroll/autoroll.go

Issue 1171823005: Add autoroll package, alerts for failed rolls, recent rolls on Status (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: tweaks Created 5 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
Index: go/autoroll/autoroll.go
diff --git a/go/autoroll/autoroll.go b/go/autoroll/autoroll.go
new file mode 100644
index 0000000000000000000000000000000000000000..ef42e40b4b0fbb88d052efd5f7633df405893846
--- /dev/null
+++ b/go/autoroll/autoroll.go
@@ -0,0 +1,76 @@
+package autoroll
+
+/*
+ Convenience functions for retrieving AutoRoll CLs.
+*/
+
+import (
+ "time"
+
+ "go.skia.org/infra/go/rietveld"
+ "go.skia.org/infra/go/util"
+)
+
+const (
+ RIETVELD_URL = "https://codereview.chromium.org"
+ OWNER = "skia-deps-roller@chromium.org"
+)
+
+var r = rietveld.Rietveld{
+ Url: RIETVELD_URL,
+}
+
+// AutoRollIssue is a trimmed-down rietveld.Issue containing just the
+// fields we care about for AutoRoll CLs.
+type AutoRollIssue struct {
+ Closed bool
+ Committed bool
+ Issue int
+ Modified time.Time
+}
+
+func search(limit int, terms ...*rietveld.SearchTerm) ([]*AutoRollIssue, error) {
+ terms = append(terms, rietveld.SearchOwner(OWNER))
+ res, err := r.Search(limit, terms...)
+ if err != nil {
+ return nil, err
+ }
+ rv := make([]*AutoRollIssue, 0, len(res))
+ for _, i := range res {
+ rv = append(rv, &AutoRollIssue{
+ Closed: i.Closed,
+ Committed: i.Committed,
+ Issue: i.Issue,
+ Modified: i.Modified,
+ })
+ }
+ return rv, nil
+}
+
+// GetRecentRolls returns
+func GetRecentRolls(modifiedAfter time.Time) ([]*AutoRollIssue, error) {
+ return search(1000, rietveld.SearchModifiedAfter(modifiedAfter))
rmistry 2015/06/10 20:20:54 Make 1000 a const? speaking of which isnt 1000 a l
borenet 2015/06/11 11:40:10 It was just an arbitrarily high number, since my a
+}
+
+func GetLastNRolls(n int) ([]*AutoRollIssue, error) {
+ issues, err := search(n)
+ if err != nil {
+ return nil, err
+ }
+ if len(issues) <= n {
+ return issues, nil
+ }
+ return issues[:n], nil
+}
+
+func AutoRollStatusPoller() (*util.PollingStatus, error) {
+ var v []*AutoRollIssue
+ return util.NewPollingStatus(&v, func(value interface{}) error {
+ res, err := GetLastNRolls(10)
+ if err != nil {
+ return err
+ }
+ *value.(*[]*AutoRollIssue) = res
+ return nil
+ }, 1*time.Minute)
+}

Powered by Google App Engine
This is Rietveld 408576698