~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to misc/dashboard/app/build/notify.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-20 14:06:23 UTC
  • mfrom: (14.1.23 saucy-proposed)
  • Revision ID: package-import@ubuntu.com-20130820140623-b414jfxi3m0qkmrq
Tags: 2:1.1.2-2ubuntu1
* Merge from Debian unstable (LP: #1211749, #1202027). Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - d/control,control.cross: Update Breaks/Replaces for Ubuntu
    versions to ensure smooth upgrades, regenerate control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
        domain     = "build.golang.org"
22
22
)
23
23
 
 
24
// failIgnore is a set of builders that we don't email about because
 
25
// they're too flaky.
 
26
var failIgnore = map[string]bool{
 
27
        "netbsd-386-bsiegert":   true,
 
28
        "netbsd-amd64-bsiegert": true,
 
29
}
 
30
 
24
31
// notifyOnFailure checks whether the supplied Commit or the subsequent
25
32
// Commit (if present) breaks the build for this builder.
26
33
// If either of those commits break the build an email notification is sent
30
37
// This must be run in a datastore transaction, and the provided *Commit must
31
38
// have been retrieved from the datastore within that transaction.
32
39
func notifyOnFailure(c appengine.Context, com *Commit, builder string) error {
 
40
        if failIgnore[builder] {
 
41
                return nil
 
42
        }
 
43
 
33
44
        // TODO(adg): implement notifications for packages
34
45
        if com.PackagePath != "" {
35
46
                return nil
37
48
 
38
49
        p := &Package{Path: com.PackagePath}
39
50
        var broken *Commit
40
 
        ok, present := com.OK(builder, "")
41
 
        if !present {
 
51
        cr := com.Result(builder, "")
 
52
        if cr == nil {
42
53
                return fmt.Errorf("no result for %s/%s", com.Hash, builder)
43
54
        }
44
55
        q := datastore.NewQuery("Commit").Ancestor(p.Key(c))
45
 
        if ok {
 
56
        if cr.OK {
46
57
                // This commit is OK. Notify if next Commit is broken.
47
58
                next := new(Commit)
48
 
                q.Filter("ParentHash=", com.Hash)
 
59
                q = q.Filter("ParentHash=", com.Hash)
49
60
                if err := firstMatch(c, q, next); err != nil {
50
61
                        if err == datastore.ErrNoSuchEntity {
51
62
                                // OK at tip, no notification necessary.
53
64
                        }
54
65
                        return err
55
66
                }
56
 
                if ok, present := next.OK(builder, ""); present && !ok {
 
67
                if nr := next.Result(builder, ""); nr != nil && !nr.OK {
 
68
                        c.Debugf("commit ok: %#v\nresult: %#v", com, cr)
 
69
                        c.Debugf("next commit broken: %#v\nnext result:%#v", next, nr)
57
70
                        broken = next
58
71
                }
59
72
        } else {
60
73
                // This commit is broken. Notify if the previous Commit is OK.
61
74
                prev := new(Commit)
62
 
                q.Filter("Hash=", com.ParentHash)
 
75
                q = q.Filter("Hash=", com.ParentHash)
63
76
                if err := firstMatch(c, q, prev); err != nil {
64
77
                        if err == datastore.ErrNoSuchEntity {
65
78
                                // No previous result, let the backfill of
68
81
                        }
69
82
                        return err
70
83
                }
71
 
                if ok, present := prev.OK(builder, ""); present && ok {
 
84
                if pr := prev.Result(builder, ""); pr != nil && pr.OK {
 
85
                        c.Debugf("commit broken: %#v\nresult: %#v", com, cr)
 
86
                        c.Debugf("previous commit ok: %#v\nprevious result:%#v", prev, pr)
72
87
                        broken = com
73
88
                }
74
89
        }