Skip to content

Commit

Permalink
Merge branch 'master' into pr/127
Browse files Browse the repository at this point in the history
  • Loading branch information
nickmerwin committed Sep 15, 2016
2 parents 9933322 + b92746c commit e8122ce
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 26 deletions.
1 change: 1 addition & 0 deletions .snyk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version: v1
11 changes: 7 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
language: node_js
node_js:
- stable
- 4.2
- 0.10
- 0.12
- "node"
- "iojs"
- "6.0"
- "5.0"
- "4.2"
- "0.12"
- "0.10"
script: make test-coveralls
sudo: false
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#node-coveralls

[![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Codeship Build Status][codeship-image]][codeship-url]
[![Known Vulnerabilities](https://snyk.io/test/github/nickmerwin/node-coveralls/badge.svg)](https://snyk.io/test/github/nickmerwin/node-coveralls)

[Coveralls.io](https://coveralls.io/) support for node.js. Get the great coverage reporting of coveralls.io and add a cool coverage button ( like the one above ) to your README.

Expand Down
14 changes: 13 additions & 1 deletion lib/getOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var getBaseOptions = function(cb){
var options = {};
var git_commit = process.env.COVERALLS_GIT_COMMIT;
var git_branch = process.env.COVERALLS_GIT_BRANCH;
var git_committer_name, git_committer_email, git_message;

var match = (process.env.CI_PULL_REQUEST || "").match(/(\d+)$/);

Expand Down Expand Up @@ -57,6 +58,9 @@ var getBaseOptions = function(cb){
options.service_job_id = process.env.CI_BUILD_NUMBER;
git_commit = process.env.CI_COMMIT_ID;
git_branch = process.env.CI_BRANCH;
git_committer_name = process.env.CI_COMMITTER_NAME;
git_committer_email = process.env.CI_COMMITTER_EMAIL;
git_message = process.env.CI_COMMIT_MESSAGE;
}

if (process.env.WERCKER){
Expand All @@ -80,6 +84,11 @@ var getBaseOptions = function(cb){
git_commit = process.env.APPVEYOR_REPO_COMMIT;
git_branch = process.env.APPVEYOR_REPO_BRANCH;
}
if(process.env.SURF_SHA1){
options.service_name = 'surf';
git_commit = process.env.SURF_SHA1;
git_branch = process.env.SURF_REF;
}
options.run_at = process.env.COVERALLS_RUN_AT || JSON.stringify(new Date()).slice(1, -1);
if (process.env.COVERALLS_SERVICE_NAME){
options.service_name = process.env.COVERALLS_SERVICE_NAME;
Expand Down Expand Up @@ -123,7 +132,10 @@ var getBaseOptions = function(cb){
if (git_commit){
fetchGitData({
head: {
id: git_commit
id: git_commit,
committer_name: git_committer_name,
committer_email: git_committer_email,
message: git_message
},
branch: git_branch
}, function(err, git){
Expand Down
28 changes: 15 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"url": "https://github.com/nickmerwin/node-coveralls/issues"
},
"scripts": {
"test": "make test"
"test": "snyk test && make test"
},
"bin": {
"coveralls": "./bin/coveralls.js"
Expand All @@ -26,22 +26,24 @@
"elliotcable <github@elliottcable.name> (http://elliottcable.name/)",
"Slotos <slotos@gmail.com> (http://slotos.net)",
"mattjmorrison <mattjmorrison@mattjmorrison.com> (http://mattjmorrison.com)",
"Arpad Borsos <arpad.borsos@googlemail.com> (http://swatinem.de/)"
"Arpad Borsos <arpad.borsos@googlemail.com> (http://swatinem.de/)",
"Adam Moss (https://github.com/adam-moss)"
],
"dependencies": {
"js-yaml": "3.0.1",
"lcov-parse": "0.0.6",
"log-driver": "1.2.4",
"request": "2.74.0",
"minimist": "1.2.0"
"js-yaml": "3.6.1",
"lcov-parse": "0.0.10",
"log-driver": "1.2.5",
"minimist": "1.2.0",
"request": "2.73.0"
},
"devDependencies": {
"sinon-restore": "1.0.0",
"mocha-lcov-reporter": "0.0.1",
"mocha": "1.8.1",
"should": "1.1.0",
"istanbul": "0.2.10",
"jshint": "2.1.3"
"istanbul": "0.4.4",
"jshint": "2.9.2",
"mocha": "2.5.3",
"mocha-lcov-reporter": "1.2.0",
"should": "9.0.2",
"sinon-restore": "1.0.1",
"snyk": "1.17.0"
},
"engines": {
"node": ">=0.8.6"
Expand Down
8 changes: 4 additions & 4 deletions test/fetchGitData.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ describe("fetchGitData", function(){
"covert": "to a string"
}
}, function(err, str){
str.branch.should.be.a("string");
str.branch.should.be.String();
fetchGitData({
"head": {
"id": "COMMIT_HASH"
},
"branch": ["convert", "to", "a", "string"]
}, function(err, str){
str.branch.should.be.a("string");
str.branch.should.be.String();
done();
});
});
Expand Down Expand Up @@ -168,11 +168,11 @@ describe("fetchGitData", function(){
process.env.COVERALLS_GIT_BRANCH = "master";
getOptions(function(err, options){
options = options.git;
options.head.should.be.a("object");
options.head.should.be.Object();
options.head.author_name.should.not.equal("Unknown Author");
options.head.committer_name.should.not.equal("Unknown Committer");
options.head.message.should.not.equal("Unknown Commit Message");
options.branch.should.be.a("string");
options.branch.should.be.String();
options.should.have.property("remotes");
options.remotes.should.be.instanceof(Array);
options.remotes.length.should.be.above(0);
Expand Down
34 changes: 30 additions & 4 deletions test/getOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ describe("getOptions", function(){
it ("should set service_name and service_job_id if it's running on Gitlab", function(done){
testGitlab(getOptions, done);
});
it ("should set service_name and service_job_id if it's running via Surf", function(done){
testSurf(getOptions, done);
});
it ("should override set options with user options", function(done){
var userOptions = {service_name: 'OVERRIDDEN_SERVICE_NAME'};
process.env.COVERALLS_SERVICE_NAME = "SERVICE_NAME";
Expand Down Expand Up @@ -203,7 +206,7 @@ var testGitBranchDetection = function(sut, done){
if (localGit.branch)
options.git.branch.should.equal(localGit.branch);
else
options.git.should.not.have.property('branch');
options.git.should.not.have.key('branch');
localGit.wrapUp();
done();
});
Expand Down Expand Up @@ -338,16 +341,19 @@ var testCodeship = function(sut, done) {
process.env.CI_BUILD_NUMBER = '1234';
process.env.CI_COMMIT_ID = "e3e3e3e3e3e3e3e3e";
process.env.CI_BRANCH = "master";
process.env.CI_COMMITTER_NAME = "John Doe";
process.env.CI_COMMITTER_EMAIL = "jd@example.com";
process.env.CI_COMMIT_MESSAGE = "adadadadadadadadadad";
sut(function(err, options){
options.service_name.should.equal("codeship");
options.service_job_id.should.equal("1234");
options.git.should.eql({ head:
{ id: 'e3e3e3e3e3e3e3e3e',
author_name: 'Unknown Author',
author_email: '',
committer_name: 'Unknown Committer',
committer_email: '',
message: 'Unknown Commit Message' },
committer_name: 'John Doe',
committer_email: 'jd@example.com',
message: 'adadadadadadadadadad' },
branch: 'master',
remotes: [] });
done();
Expand Down Expand Up @@ -418,6 +424,26 @@ var testGitlab = function(sut, done) {
});
};

var testSurf = function(sut, done) {
process.env.CI_NAME = 'surf';
process.env.SURF_SHA1 = "e3e3e3e3e3e3e3e3e";
process.env.SURF_REF = "feature";
sut(function(err, options){
options.service_name.should.equal("surf");
options.git.should.eql({ head:
{ id: 'e3e3e3e3e3e3e3e3e',
author_name: 'Unknown Author',
author_email: '',
committer_name: 'Unknown Committer',
committer_email: '',
message: 'Unknown Commit Message' },
branch: 'feature',
remotes: [] });
done();
});
};


function ensureLocalGitContext(options) {
var path = require('path');
var fs = require('fs');
Expand Down

0 comments on commit e8122ce

Please sign in to comment.