Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
Add homu queue warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdm committed Oct 18, 2017
1 parent 9a27ebf commit 459b4a6
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
39 changes: 39 additions & 0 deletions homu.js
@@ -0,0 +1,39 @@
var request = require("request");

function checkHomuQueue(cb) {
// First check if any buildbot builders report an ongoing build.
retrieveBuildbotBuilders(function(builders) {
var allIdle = true;
for (var builder in data) {
var builderData = data[builder];
if ('currentBuilds' in builderData && builderData['currentBuilds'].length) {
return;
}
}
// Next see if homu thinks that any PRs are ready to be built.
retrieveHomuQueue(function(body) {
var numApproved = (body.match(/<td class="approved">/g) || []).length;
if (numApproved) {
cb(numApproved);
}
});
})
}

function retrieveHomuQueue(cb) {
request("http://servo-master.servo.org:54856/queue/servo", function(err, response, body) {
if (!err && response.statusCode >= 200 && response.statusCode < 300) {
cb(body);
}
});
}

function retrieveBuildbotBuilders(cb) {
request("http://build.servo.org/json/builders/", function(err, response, body) {
if (!err && response.statusCode >= 200 && response.statusCode < 300) {
cb(JSON.parse(body));
}
});
}

exports.checkHomuQueue = checkHomuQueue;
11 changes: 10 additions & 1 deletion server.js
Expand Up @@ -6,7 +6,8 @@ var irc = require("irc"),
newsflash = require("./newsflash"),
opsreport = require("./opsreport"),
graphs = require("./graphs"),
storage = require('node-persist');
storage = require('node-persist'),
homu = require("./homu");

function githubRequest(endpoint, callback) {
var reqParams = {
Expand Down Expand Up @@ -514,3 +515,11 @@ bot.addListener("message", handler);
bot.addListener("action", handler);
// Listener for the autopinger
bot.addListener("join", pingResponder);

const THIRTY_MINUTES = 30 * 60 * 1000;
setInterval(function() {
checkHomuQueue(function(queued) {
bot.say(config.channels[0],
"Warning! All builders are idle, but there are " + queued + "PRs in the queue.");
});
}, THIRTY_MINUTES);

0 comments on commit 459b4a6

Please sign in to comment.