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

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: Address comments 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
« no previous file with comments | « alertserver/go/alertserver/alertroutines.go ('k') | go/rietveld/rietveld.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/autoroll/autoroll.go
diff --git a/go/autoroll/autoroll.go b/go/autoroll/autoroll.go
new file mode 100644
index 0000000000000000000000000000000000000000..947394017033f89c8c0196a78792f1ba2f49a953
--- /dev/null
+++ b/go/autoroll/autoroll.go
@@ -0,0 +1,78 @@
+package autoroll
+
+/*
+ Convenience functions for retrieving AutoRoll CLs.
+*/
+
+import (
+ "time"
+
+ "go.skia.org/infra/go/rietveld"
+ "go.skia.org/infra/go/util"
+)
+
+const (
+ OWNER = "skia-deps-roller@chromium.org"
+ POLLER_ROLLS_LIMIT = 10
+ RECENT_ROLLS_LIMIT = 200
+ RIETVELD_URL = "https://codereview.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(RECENT_ROLLS_LIMIT, rietveld.SearchModifiedAfter(modifiedAfter))
+}
+
+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(POLLER_ROLLS_LIMIT)
+ if err != nil {
+ return err
+ }
+ *value.(*[]*AutoRollIssue) = res
+ return nil
+ }, 1*time.Minute)
+}
« no previous file with comments | « alertserver/go/alertserver/alertroutines.go ('k') | go/rietveld/rietveld.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698