Skip to content
This repository has been archived by the owner on Sep 21, 2018. It is now read-only.

CodeCov #55

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "presets": ["es2015"] }
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,8 @@ config/worker/*
!config/worker/config.json.sample

# intellij Webstorm
.idea/
.idea/

# babel
*-compiled.js
*-compiled.js.map
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
language: node_js

node_js:
- 4
- 0.12

install:
- npm install codecov

script:
- node_modules/.bin/codecov
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Guerilla

[![Build Status](https://travis-ci.org/yahoo/guerilla.svg?branch=master)](https://travis-ci.org/yahoo/guerilla)
[![Join the chat at https://gitter.im/yahoo/guerilla](https://badges.gitter.im/yahoo/guerilla.svg)](https://gitter.im/yahoo/guerilla?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![codecov.io](https://img.shields.io/codecov/c/github/yahoo/guerilla.svg)](https://codecov.io/github/yahoo/guerilla?branch=master)

Guerilla is a distributed build/test server specialized for iOS and Android.

Expand Down
3 changes: 2 additions & 1 deletion lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* Sets up middleware, routers, and error handlers for the Express.js application.
*/

import utilities from './utilities';

var fs = require('fs-extra');
var path = require('path');
var morgan = require('morgan');
Expand All @@ -16,7 +18,6 @@ var express = require('express');
var less = require('less-middleware');
var browserify = require('browserify-middleware');
var config = require('./config');
var utilities = require('./utilities');

//setting up app
var app = express();
Expand Down
3 changes: 2 additions & 1 deletion lib/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
* Provides data and functionality to be used by tasks.
*/

import utilities from './utilities';

var path = require('path');
var callsite = require('callsite');
var Task = require('./task');
var utilities = require('./utilities');

function Context (executor, job, result, device) {
var self = this;
Expand Down
3 changes: 2 additions & 1 deletion lib/job-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
* Entry point for a new forked node process to execute a job.
*/

import utilities from './utilities';

require('./globals');

var path = require('path');
var async = require('async');
var argv = require('yargs').argv;

var config = require('./config');
var utilities = require('./utilities');
var db = require('./db');

var result;
Expand Down
3 changes: 2 additions & 1 deletion lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
* A logger class.
*/

import utilities from './utilities';

var colors = require('colors');
var util = require('util');
var utilities = require('./utilities');
var argv = require('yargs').argv;

function Logger () {
Expand Down
3 changes: 2 additions & 1 deletion lib/mailer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
* Sends emails for job result status changes.
*/

import utilities from './utilities';

var nodemailer = require('nodemailer');
var fs = require('fs-extra');
var path = require('path');
var ejs = require('ejs');
var utilities = require('./utilities');
var config = require('./config');

function Mailer () {
Expand Down
1 change: 0 additions & 1 deletion lib/scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ function isValidCronTime (cronTime) {
try {
var c = new CronJob(cronTime, function () {
c.stop();
delete c;
});
}
catch (ex) {
Expand Down
3 changes: 2 additions & 1 deletion lib/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
* An abstraction of a task.
*/

import utilities from './utilities';

var path = require('path');
var async = require('async');
var utilities = require('./utilities');

function Task (params) {
this.errors = [];
Expand Down
71 changes: 34 additions & 37 deletions lib/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,37 @@
* Utility and helper functions used across the application.
*/

var path = require('path');
var util = require('util');

function Utilities () {
}

Utilities.prototype.formatMilliseconds = function (ms) {
var secNum = parseInt(ms / 1000, 10);
var hours = Math.floor(secNum / 3600);
var minutes = Math.floor((secNum - (hours * 3600)) / 60);
var seconds = secNum - (hours * 3600) - (minutes * 60);

if (minutes < 10)
minutes = '0' + minutes;
if (seconds < 10)
seconds = '0' + seconds;

var time = hours + ':' + minutes + ':' + seconds;
return time;
}

Utilities.prototype.isDictionary = function (obj) {
return !(!obj || Array.isArray(obj) || obj.constructor != Object);
}

Utilities.prototype.exists = function (v) {
return !(typeof v == 'undefined' || v == null);
}

Utilities.prototype.stringify = function (obj) {
if (typeof obj === 'object')
return util.inspect(obj, { showHidden: true, depth: null });
else
return obj;
}

module.exports = new Utilities();
import * as util from 'util';

export default class Utilities {

static formatMilliseconds(ms) {
var secNum = parseInt(ms / 1000, 10);
var hours = Math.floor(secNum / 3600);
var minutes = Math.floor((secNum - (hours * 3600)) / 60);
var seconds = secNum - (hours * 3600) - (minutes * 60);
if (minutes < 10) {
minutes = '0' + minutes;
}
if (seconds < 10) {
seconds = '0' + seconds;
}
return hours + ':' + minutes + ':' + seconds;
}

static isDictionary(obj) {
return !(!obj || Array.isArray(obj) || obj.constructor != Object);
}

static exists(v) {
return !(v === undefined || v === null);
}

static stringify(obj) {
if (typeof obj === 'object') {
return util.inspect(obj, {showHidden: true, depth: null});
} else {
return obj;
}
}
}
3 changes: 2 additions & 1 deletion models/Job.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
* Models a configured job.
*/

import utilities from '../lib/utilities';

var async = require('async');
var path = require('path');
var childProcess = require('child_process');
var config = require(path.join(__rootdir, 'lib', 'config'));
var Report = require(path.join(__rootdir, 'lib', 'report'));
var utilities = require(path.join(__rootdir, 'lib', 'utilities'));

var Job;

Expand Down
3 changes: 2 additions & 1 deletion models/Project.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
* Models a collection of jobs.
*/

import utilities from '../lib/utilities';

var async = require('async');
var path = require('path');
var utilities = require(path.join(__rootdir, 'lib', 'utilities'));

var Project;

Expand Down
3 changes: 2 additions & 1 deletion models/Result.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
* Models the results from an individual job run.
*/

import utilities from '../lib/utilities';

var moment = require('moment');
var path = require('path');
var util = require('util');
var async = require('async');
var fs = require('fs-extra');
var utilities = require(path.join(__rootdir, 'lib', 'utilities'));

var Result;

Expand Down
16 changes: 14 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
"url": "http://github.com/yahoo/guerilla/issues"
},
"scripts": {
"test": "TEST=1 ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- $(find tests -name '*.test.js')",
"lint": "./node_modules/.bin/jshint tests"
"redis": "redis-server",
"master": "node_modules/.bin/babel-node server.js --master",
"worker": "node_modules/.bin/babel-node server.js --worker",
"test": "node_modules/.bin/istanbul cover node_modules/.bin/_mocha --report lcovonly --compilers js:babel-core/register -- $(find tests -name '*.test.js')",
"lint": "node_modules/.bin/jshint tests"
},
"dependencies": {
"async": "^1.0.0",
Expand Down Expand Up @@ -62,6 +65,15 @@
"node": ">=0.12"
},
"devDependencies": {
"babel-cli": "^6.6.5",
"babel-eslint": "^5.0.0-beta6",
"babel-loader": "^6.2.1",
"babel-plugin-react-transform": "^2.0.0",
"babel-polyfill": "^6.3.14",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"babel-preset-react-hmre": "^1.1.0",
"babel-register": "^6.4.3",
"chai": "^3.5.0",
"debug": "^2.2.0",
"glob": "^7.0.0",
Expand Down
2 changes: 1 addition & 1 deletion routes/master/jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
var router = require('express').Router();
var path = require('path');
var models = require(path.join(__rootdir, 'lib', 'db')).models();
var utilities = require(path.join(__rootdir, 'lib', 'utilities'));

var Job = models.Job;
var ConfigLocation = models.ConfigLocation;

Expand Down
2 changes: 2 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
*/

var git = require('git-rev');
var logger = require('./lib/logger');

git.long(function (str) {

require('./lib/globals');
Expand Down
22 changes: 18 additions & 4 deletions wiki/Launching.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

Navigate to the Guerilla project directory and start the redis server:

`redis-server`
```sh
npm run redis
# or the following legacy way
# redis-server
```

### Install NPM Packages

Expand Down Expand Up @@ -41,6 +45,16 @@ temporary directory.

#### Starting syntax

Master: `node server.js --master [--config configFilePath] {--saveTempFiles}`

Worker: `node server.js --worker [--config configFilePath] {--saveTempFiles}`
Master:
```sh
npm run master
# or the following legacy way
# node server.js --master [--config configFilePath] {--saveTempFiles}`
```

Worker:
```sh
npm run worker
# or the following legacy way
# node server.js --worker [--config configFilePath] {--saveTempFiles}
```