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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 package autoroll
2
3 /*
4 Convenience functions for retrieving AutoRoll CLs.
5 */
6
7 import (
8 "time"
9
10 "go.skia.org/infra/go/rietveld"
11 "go.skia.org/infra/go/util"
12 )
13
14 const (
15 RIETVELD_URL = "https://codereview.chromium.org"
16 OWNER = "skia-deps-roller@chromium.org"
17 )
18
19 var r = rietveld.Rietveld{
20 Url: RIETVELD_URL,
21 }
22
23 // AutoRollIssue is a trimmed-down rietveld.Issue containing just the
24 // fields we care about for AutoRoll CLs.
25 type AutoRollIssue struct {
26 Closed bool
27 Committed bool
28 Issue int
29 Modified time.Time
30 }
31
32 func search(limit int, terms ...*rietveld.SearchTerm) ([]*AutoRollIssue, error) {
33 terms = append(terms, rietveld.SearchOwner(OWNER))
34 res, err := r.Search(limit, terms...)
35 if err != nil {
36 return nil, err
37 }
38 rv := make([]*AutoRollIssue, 0, len(res))
39 for _, i := range res {
40 rv = append(rv, &AutoRollIssue{
41 Closed: i.Closed,
42 Committed: i.Committed,
43 Issue: i.Issue,
44 Modified: i.Modified,
45 })
46 }
47 return rv, nil
48 }
49
50 // GetRecentRolls returns
51 func GetRecentRolls(modifiedAfter time.Time) ([]*AutoRollIssue, error) {
52 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
53 }
54
55 func GetLastNRolls(n int) ([]*AutoRollIssue, error) {
56 issues, err := search(n)
57 if err != nil {
58 return nil, err
59 }
60 if len(issues) <= n {
61 return issues, nil
62 }
63 return issues[:n], nil
64 }
65
66 func AutoRollStatusPoller() (*util.PollingStatus, error) {
67 var v []*AutoRollIssue
68 return util.NewPollingStatus(&v, func(value interface{}) error {
69 res, err := GetLastNRolls(10)
70 if err != nil {
71 return err
72 }
73 *value.(*[]*AutoRollIssue) = res
74 return nil
75 }, 1*time.Minute)
76 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698