Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Cleaning up; removed scripts.js

  • Loading branch information...
commit a2418638a100c7ae1b6fc0ffb3aa8bdca280be3a 1 parent 3b1b7c9
@arturadib arturadib authored
Showing with 54 additions and 100 deletions.
  1. +1 −1  config.json
  2. +1 −1  config_staging.json
  3. +0 −79 lib/scripts.js
  4. +52 −19 server.js
View
2  config.json
@@ -3,7 +3,7 @@
"botname": "@pdfjsbot",
"main_repo": "andreasgal/pdf.js",
"ref_repo": "arturadib/pdf.js-ref",
- "dest_path": "./tmp",
+ "tmp_path": "./tmp",
"server_port": 8989,
"process_timeout_mins": 60
}
View
2  config_staging.json
@@ -3,7 +3,7 @@
"botname": "@pdfjsbot",
"main_repo": "arturadib/pdf.js",
"ref_repo": "arturadib/pdf.js-ref",
- "dest_path": "./tmp",
+ "tmp_path": "./tmp",
"server_port": 8989,
"process_timeout_mins": 30
}
View
79 lib/scripts.js
@@ -1,79 +0,0 @@
-/**
- *
- *
- * Test script controls for bot
- *
- *
- **/
-
-var exec = require('child_process').exec;
-
-//
-// runTest(args, callback), where
-// args = {
-// pull_url: 'user/reponame',
-// pull_sha: 'fasdf8fs76d5f54',
-// ref_url: 'user/reponame',
-// dest_path: '/path/etc'
-// }
-// callback(stdout)
-//
-exports.runTest = function(args, callback){
- var outputFile = args.dest_path+'/'+args.pull_sha+'.txt'
- cmd = 'mkdir -p '+args.dest_path+'; ./run-test '+args.main_url+' '+args.pull_url+' '+args.pull_sha+' '+args.ref_url+' '+args.dest_path+' 2>&1 | tee '+outputFile;
-
- console.log((new Date())+': running '+cmd);
-
- //
- // Launch process
- //
- exec(cmd,
- {
- timeout: args.timeout || undefined
- },
- function(error, stdout, stderr){
- //
- // Test done
- //
- if (error && error.killed) {
- stdout += '\n\n***\nProcess killed (timeout).\n';
- }
- if (callback) callback(stdout+'\n\n_____________________________ stderr:\n\n'+stderr);
- }
- );
-}; // runTest()
-
-//
-// runMakeref(args, callback), where
-// args = {
-// pull_url: 'user/reponame',
-// pull_sha: 'fasdf8fs76d5f54',
-// ref_url: 'user/reponame',
-// dest_path: '/path/etc'
-// }
-// callback(stdout)
-//
-exports.runMakeref = function(args, callback){
- var outputFile = args.dest_path+'/'+args.pull_sha+'.txt',
- cmd = 'mkdir -p '+args.dest_path+'; ./run-makeref '+args.main_url+' '+args.pull_url+' '+args.pull_sha+' '+args.ref_url+' '+args.dest_path+' 2>&1 | tee '+outputFile;
-
- console.log((new Date())+': running '+cmd);
-
- //
- // Launch process
- //
- exec(cmd,
- {
- timeout: args.timeout || undefined
- },
- function(error, stdout, stderr){
- //
- // Test done
- //
- if (error && error.killed) {
- stdout += '\n\n***\nProcess killed (timeout).\n';
- }
- if (callback) callback(stdout+'\n\n_____________________________ stderr:\n\n'+stderr);
- }
- );
-}; // runMakeref()
View
71 server.js
@@ -15,9 +15,9 @@ var fs = require('fs'),
express = require('express'),
app = express.createServer(),
path = require('path'),
- request = require('request'),
+ request = require('request'),
+ exec = require('child_process').exec,
github = require('./lib/github'),
- scripts = require('./lib/scripts'),
queue = require('./lib/queue');
var config = {},
@@ -57,11 +57,13 @@ function setupServer(callback){
// HTTP server
app.use(express.bodyParser());
app.use(app.router);
- app.use(express.static(__dirname+'/'+config.dest_path));
+ app.use(express.static(__dirname+'/'+config.tmp_path));
app.listen(config.server_port);
- console.log((new Date())+': HTTP server listening on port '+config.server_port+', serving dir '+config.dest_path);
- getPublicIP(function(){
+ getPublicIP(function(){
+ config.server_url = 'http://'+config.server_host+':'+config.server_port;
+ console.log((new Date())+': Server listening at '+config.server_url+', serving dir '+config.tmp_path);
+
// Github-specific
github.setConfig(config);
github.buildWhitelist(function(){
@@ -78,8 +80,6 @@ function setupServer(callback){
function getPublicIP(callback){
request.get('http://ifconfig.me/ip', function(error, response, body){
config.server_host = body.replace(/\s|\n/g, '');
- console.log((new Date())+': using public IP '+config.server_host);
-
if (callback) callback();
});
};
@@ -91,11 +91,12 @@ function getPublicIP(callback){
function processNewCommands(){
// Loop over every new command in all monitored pull requests
github.forEachNewCommand(function(cmd){
- var t1 = new Date();
+ var t1 = new Date(),
+ liveOutputFile = cmd.id+'.txt';
console.log((new Date())+': processing new command "'+cmd.command+'" in Pull #'+cmd.pull_number+' from @'+cmd.user+' (id:'+cmd.id+'), queue size: '+queue.size());
github.postStartMessage(cmd, 'Processing command **'+(cmd.command||'(empty)')+'** by user _'+cmd.user+'_. Queue size: '+queue.size()+'\n\n'+
- 'Live script output is available at: '+'http://'+config.server_host+':'+config.server_port+'/'+cmd.pull_sha+'.txt');
+ 'Live script output is available at: '+config.server_url+'/'+liveOutputFile);
//
// Process each command in queue
@@ -109,14 +110,16 @@ function processNewCommands(){
// Process 'test' command
//
case 'test':
- scripts.runTest(
+ runScript(
{
+ script: cmd.command,
main_url: 'git://github.com/'+config.main_repo+'.git',
pull_url: cmd.pull_url,
pull_sha: cmd.pull_sha,
ref_url: 'git://github.com/'+config.ref_repo+'.git',
- dest_path: config.dest_path,
- timeout: config.process_timeout_mins*60*1000
+ tmp_path: config.tmp_path,
+ timeout: config.process_timeout_mins*60*1000,
+ output_file: liveOutputFile
},
function(output){
var msg = '';
@@ -140,12 +143,10 @@ function processNewCommands(){
msg = '**ERROR(s) found**';
- if (path.existsSync(config.dest_path+'/tests/'+cmd.pull_sha+'/eq.log')) {
-
- var url = 'http://'+config.server_host+':'+config.server_port+'/tests/'+cmd.pull_sha+'/reftest-analyzer.xhtml'+
+ if (path.existsSync(config.tmp_path+'/tests/'+cmd.pull_sha+'/eq.log')) {
+ var url = config.server_url+'/tests/'+cmd.pull_sha+'/reftest-analyzer.xhtml'+
'#web=/tests/'+cmd.pull_sha+'/eq.log';
msg += '\n\n**ATTENTION:** There was a _snapshot difference:_\n'+url;
-
}
} // if !tests passed
@@ -162,14 +163,16 @@ function processNewCommands(){
// Process 'makeref' command
//
case 'makeref':
- scripts.runMakeref(
+ runScript(
{
+ script: cmd.command,
main_url: 'git://github.com/'+config.main_repo+'.git',
pull_url: cmd.pull_url,
pull_sha: cmd.pull_sha,
ref_url: 'git://github.com/'+config.ref_repo+'.git',
- dest_path: config.dest_path,
- timeout: config.process_timeout_mins*60*1000
+ tmp_path: config.tmp_path,
+ timeout: config.process_timeout_mins*60*1000,
+ output_file: liveOutputFile
},
function(output){
var msg = '';
@@ -217,3 +220,33 @@ function processNewCommands(){
}); // forEachNewCommand
}; // checkNewMessages()
+//
+// runScript()
+//
+function runScript(args, callback){
+ var outputFile = args.tmp_path+'/'+args.output_file,
+ script = './run-'+args.script,
+ cmd = 'mkdir -p '+args.tmp_path+'; '+
+ script+' '+args.main_url+' '+args.pull_url+' '+args.pull_sha+' '+args.ref_url+' '+args.tmp_path+
+ ' 2>&1 | tee '+outputFile;
+
+ console.log((new Date())+': running: '+cmd);
+
+ //
+ // Launch process
+ //
+ exec(cmd,
+ {
+ timeout: args.timeout || undefined
+ },
+ function(error, stdout, stderr){
+ //
+ // Script done
+ //
+ if (error && error.killed) {
+ stdout += '\n\n***\nProcess killed (timeout).\n';
+ }
+ if (callback) callback(stdout+'\n\n_____________________________ stderr:\n\n'+stderr);
+ }
+ );
+}; // runScript()
Please sign in to comment.
Something went wrong with that request. Please try again.