Skip to content

Commit

Permalink
Add buildkite support (#177)
Browse files Browse the repository at this point in the history
* Add buildkite support

* Add committer name, email, commit message and pull request number

* Add buildkite to support CIs in README.md
  • Loading branch information
Tristan Davey authored and nickmerwin committed May 1, 2018
1 parent aa8c257 commit 9cfb496
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[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.

Supported CI services: [travis-ci](https://travis-ci.org/), [codeship](https://www.codeship.io/), [circleci](https://circleci.com/), [jenkins](http://jenkins-ci.org/), [Gitlab CI](http://gitlab.com/), [AppVeyor](http://appveyor.com/)
Supported CI services: [travis-ci](https://travis-ci.org/), [codeship](https://www.codeship.io/), [circleci](https://circleci.com/), [jenkins](http://jenkins-ci.org/), [Gitlab CI](http://gitlab.com/), [AppVeyor](http://appveyor.com/), [Buildkite](https://buildkite.com/)

## Installation:
Add the latest version of `coveralls` to your package.json:
Expand Down
15 changes: 14 additions & 1 deletion lib/getOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ var getBaseOptions = function(cb){
git_branch = process.env.TRAVIS_BRANCH;
}


if (process.env.DRONE){
options.service_name = 'drone';
options.service_job_id = process.env.DRONE_BUILD_NUMBER;
Expand Down Expand Up @@ -93,12 +92,26 @@ var getBaseOptions = function(cb){
git_commit = process.env.SURF_SHA1;
git_branch = process.env.SURF_REF;
}

if(process.env.BUILDKITE){
options.service_name = 'buildkite';
options.service_job_number = process.env.BUILDKITE_BUILD_NUMBER;
options.service_job_id = process.env.BUILDKITE_BUILD_ID;
options.service_pull_request = process.env.BUILDKITE_PULL_REQUEST;
git_commit = process.env.BUILDKITE_COMMIT;
git_branch = process.env.BUILDKITE_BRANCH;
git_committer_name = process.env.BUILDKITE_BUILD_CREATOR;
git_committer_email = process.env.BUILDKITE_BUILD_CREATOR_EMAIL;
git_message = process.env.BUILDKITE_MESSAGE;
}

if(process.env.SEMAPHORE){
options.service_name = 'semaphore';
options.service_job_id = process.env.SEMAPHORE_BUILD_NUMBER;
git_commit = process.env.REVISION;
git_branch = process.env.BRANCH_NAME;
}

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
30 changes: 30 additions & 0 deletions test/getOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ describe("getBaseOptions", function(){
it ("should set service_name and service_job_id if it's running on wercker", function(done){
testWercker(getBaseOptions, done);
});
it ("should set service_name and service_job_id if it's running on Buildkite", function(done){
testBuildkite(getBaseOptions, done);
});
});

describe("getOptions", function(){
Expand Down Expand Up @@ -143,6 +146,9 @@ describe("getOptions", function(){
it ("should set service_name and service_job_id if it's running via Surf", function(done){
testSurf(getOptions, done);
});
it ("should set service_name and service_job_id if it's running via Buildkite", function(done){
testBuildkite(getOptions, done);
});
it ("should set service_name and service_job_id if it's running via Semaphore", function(done){
testSemaphore(getOptions, done);
});
Expand Down Expand Up @@ -448,6 +454,30 @@ var testSurf = function(sut, done) {
});
};

var testBuildkite = function(sut, done) {
process.env.BUILDKITE = true;
process.env.BUILDKITE_BUILD_NUMBER = "1234";
process.env.BUILDKITE_COMMIT = "e3e3e3e3e3e3e3e3e";
process.env.BUILDKITE_BRANCH = "feature";
process.env.BUILDKITE_BUILD_CREATOR = 'john doe';
process.env.BUILDKITE_BUILD_CREATOR_EMAIL = 'john@doe.com';
process.env.BUILDKITE_MESSAGE = 'msgmsgmsg';
sut(function(err, options){
options.service_name.should.equal("buildkite");
options.git.should.eql({ head:
{ id: 'e3e3e3e3e3e3e3e3e',
author_name: 'Unknown Author',
author_email: '',
committer_name: 'john doe',
committer_email: 'john@doe.com',
message: 'msgmsgmsg' },
branch: 'feature',
remotes: [] });
done();
});
};


var testSemaphore = function(sut, done) {
process.env.SEMAPHORE = true;
process.env.SEMAPHORE_BUILD_NUMBER = '1234';
Expand Down

0 comments on commit 9cfb496

Please sign in to comment.