Please clarify "pending" reporting at build.webkit.org/dashboard
[WebKit-https.git] / Tools / BuildSlaveSupport / build.webkit.org-config / public_html / dashboard / Scripts / BuildbotBuilderQueueView.js
1 /*
2  * Copyright (C) 2013 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 BuildbotBuilderQueueView = function(debugQueues, releaseQueues)
27 {
28     BuildbotQueueView.call(this, debugQueues, releaseQueues);
29
30     function filterQueuesByArchitecture(architecture, queue)
31     {
32         return queue.architecture === architecture;
33     }
34
35     this.universalReleaseQueues = this.releaseQueues.filter(filterQueuesByArchitecture.bind(this, Buildbot.BuildArchitecture.Universal));
36     this.sixtyFourBitReleaseQueues = this.releaseQueues.filter(filterQueuesByArchitecture.bind(this, Buildbot.BuildArchitecture.SixtyFourBit));
37     this.thirtyTwoBitReleaseQueues = this.releaseQueues.filter(filterQueuesByArchitecture.bind(this, Buildbot.BuildArchitecture.ThirtyTwoBit));
38
39     this.universalDebugQueues = this.debugQueues.filter(filterQueuesByArchitecture.bind(this, Buildbot.BuildArchitecture.Universal));
40     this.sixtyFourBitDebugQueues = this.debugQueues.filter(filterQueuesByArchitecture.bind(this, Buildbot.BuildArchitecture.SixtyFourBit));
41     this.thirtyTwoBitDebugQueues = this.debugQueues.filter(filterQueuesByArchitecture.bind(this, Buildbot.BuildArchitecture.ThirtyTwoBit));
42
43     this.hasMultipleReleaseBuilds = this.releaseQueues.length > 1;
44     this.hasMultipleDebugBuilds = this.debugQueues.length > 1;
45
46     this.update();
47 };
48
49 BaseObject.addConstructorFunctions(BuildbotBuilderQueueView);
50
51 BuildbotBuilderQueueView.prototype = {
52     constructor: BuildbotBuilderQueueView,
53     __proto__: BuildbotQueueView.prototype,
54
55     update: function()
56     {
57         BuildbotQueueView.prototype.update.call(this);
58
59         this.element.removeChildren();
60
61         function appendBuilderQueueStatus(queue)
62         {
63             this._appendPendingRevisionCount(queue)
64
65             var firstRecentFailedIteration = queue.firstRecentFailedIteration;
66             if (firstRecentFailedIteration && firstRecentFailedIteration.loaded) {
67                 var failureCount = queue.recentFailedIterationCount;
68                 var message = this.revisionLinksForIteration(firstRecentFailedIteration);
69                 var url = queue.buildbot.buildLogURLForIteration(firstRecentFailedIteration);
70                 var status = new StatusLineView(message, StatusLineView.Status.Bad, failureCount > 1 ? "failed builds since" : "failed build", failureCount > 1 ? failureCount : null, url);
71                 this.element.appendChild(status.element);
72             }
73
74             var mostRecentSuccessfulIteration = queue.mostRecentSuccessfulIteration;
75             if (mostRecentSuccessfulIteration && mostRecentSuccessfulIteration.loaded) {
76                 var message = this.revisionLinksForIteration(mostRecentSuccessfulIteration);
77                 var url = queue.buildbot.buildLogURLForIteration(mostRecentSuccessfulIteration);
78                 var status = new StatusLineView(message, StatusLineView.Status.Good, firstRecentFailedIteration ? "last successful build" : "latest build", null, url);
79                 this.element.appendChild(status.element);
80             } else {
81                 var status = new StatusLineView("unknown", StatusLineView.Status.Neutral, firstRecentFailedIteration ? "last successful build" : "latest build");            
82                 this.element.appendChild(status.element);
83
84                 if (firstRecentFailedIteration) {
85                     // We have a failed iteration but no successful. It might be further back in time.
86                     // Update all the iterations so we get more history.
87                     queue.iterations.forEach(function(iteration) { iteration.update(); });
88                 }
89             }
90         }
91
92         function appendBuildArchitecture(queues, label)
93         {
94             queues.forEach(function(queue) {
95                 var releaseLabel = document.createElement("a");
96                 releaseLabel.classList.add("queueLabel");
97                 releaseLabel.textContent = label;
98                 releaseLabel.href = queue.overviewURL;
99                 releaseLabel.target = "_blank";
100                 this.element.appendChild(releaseLabel);
101
102                 appendBuilderQueueStatus.call(this, queue);
103             }.bind(this));
104         }
105
106         appendBuildArchitecture.call(this, this.universalReleaseQueues, this.hasMultipleReleaseBuilds ? "Release (Universal)" : "Release");
107         appendBuildArchitecture.call(this, this.sixtyFourBitReleaseQueues, this.hasMultipleReleaseBuilds ? "Release (64-bit)" : "Release");
108         appendBuildArchitecture.call(this, this.thirtyTwoBitReleaseQueues, this.hasMultipleReleaseBuilds ? "Release (32-bit)" : "Release");
109
110         appendBuildArchitecture.call(this, this.universalDebugQueues, this.hasMultipleDebugBuilds ? "Debug (Universal)" : "Debug");
111         appendBuildArchitecture.call(this, this.sixtyFourBitDebugQueues, this.hasMultipleDebugBuilds ? "Debug (64-bit)" : "Debug");
112         appendBuildArchitecture.call(this, this.thirtyTwoBitDebugQueues, this.hasMultipleDebugBuilds ? "Debug (32-bit)" : "Debug");
113     }
114 };