cylon/examples/travis/travis.js

50 lines
1.1 KiB
JavaScript
Raw Normal View History

2014-12-14 08:19:25 +08:00
"use strict";
2013-10-29 12:43:27 +08:00
2014-12-14 08:19:25 +08:00
var Cylon = require("../.."),
Travis = require("travis-ci");
var travis = new Travis({version: "2.0.0"});
2013-10-29 12:43:27 +08:00
Cylon.robot({
2014-11-26 08:01:31 +08:00
connections: {
2014-12-14 08:19:25 +08:00
sphero: { adaptor: "sphero", port: "/dev/rfcomm0" }
2014-11-26 08:01:31 +08:00
},
devices: {
2014-12-14 08:19:25 +08:00
sphero: { driver: "sphero" }
2014-11-26 08:01:31 +08:00
},
work: function(my) {
var user = "hybridgroup",
name = "cylon";
var checkTravis = function() {
console.log("Checking repo " + user + "/" + name);
2014-12-14 08:19:25 +08:00
my.sphero.setColor("blue", true);
travis.repos({ owner_name: user, name: name }, function(err, res) {
2015-04-15 12:49:12 +08:00
if (err) {
console.log(err);
}
2014-12-14 08:19:25 +08:00
if (res.repo === undefined) { my.sphero.setColor("blue", true); }
switch (res.repo.last_build_state) {
2014-12-14 08:19:25 +08:00
case "passed":
my.sphero.setColor("green", true);
break;
2014-12-14 08:19:25 +08:00
case "failed":
my.sphero.setColor("red", true);
break;
default:
2014-12-14 08:19:25 +08:00
my.sphero.setColor("blue", true);
}
});
2014-12-14 08:19:25 +08:00
};
2013-10-29 12:43:27 +08:00
checkTravis();
2013-10-29 12:43:27 +08:00
every((10).seconds(), checkTravis);
2013-10-29 12:43:27 +08:00
}
}).start();