Skip to content

Commit

Permalink
If COVERALLS_SERVICE_NUMBER is set, set service_number from it. (#208)
Browse files Browse the repository at this point in the history
* If COVERALLS_SERVICE_NUMBER is set, set service_number from it.

Remove the duplicate service_pull_request set.
  • Loading branch information
midgleyc authored Mar 19, 2020
1 parent 2ea7be3 commit b010d3d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
11 changes: 5 additions & 6 deletions lib/convertLcovToCoveralls.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ const convertLcovToCoveralls = (input, options, cb) => {
if (options.service_name) {
postJson.service_name = options.service_name;
}


if (options.service_number) {
postJson.service_number = options.service_number;
}

if (options.service_job_id) {
postJson.service_job_id = options.service_job_id;
}
Expand All @@ -95,11 +99,6 @@ const convertLcovToCoveralls = (input, options, cb) => {
if (options.parallel) {
postJson.parallel = options.parallel;
}

if (options.service_pull_request) {
postJson.service_pull_request = options.service_pull_request;
}

parsed.forEach(file => {
file.file = cleanFilePath(file.file);
const currentFilePath = path.resolve(filepath, file.file);
Expand Down
4 changes: 4 additions & 0 deletions lib/getOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ const getBaseOptions = cb => {

options.run_at = process.env.COVERALLS_RUN_AT || JSON.stringify(new Date()).slice(1, -1);

if (process.env.COVERALLS_SERVICE_NUMBER) {
options.service_number = process.env.COVERALLS_SERVICE_NUMBER;
}

if (process.env.COVERALLS_SERVICE_JOB_ID) {
options.service_job_id = process.env.COVERALLS_SERVICE_JOB_ID;
}
Expand Down
4 changes: 4 additions & 0 deletions test/convertLcovToCoveralls.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe('convertLcovToCoveralls', () => {
process.env.COVERALLS_GIT_COMMIT = 'GIT_HASH';
process.env.COVERALLS_GIT_BRANCH = 'master';
process.env.COVERALLS_SERVICE_NAME = 'SERVICE_NAME';
process.env.COVERALLS_SERVICE_NUMBER = 'SERVICE_NUMBER';
process.env.COVERALLS_SERVICE_JOB_ID = 'SERVICE_JOB_ID';
process.env.COVERALLS_REPO_TOKEN = 'REPO_TOKEN';
process.env.CI_PULL_REQUEST = 'https://github.com/fake/fake/pulls/123';
Expand All @@ -43,6 +44,9 @@ describe('convertLcovToCoveralls', () => {
options.filepath = libpath;
convertLcovToCoveralls(input, options, (err, output) => {
should.not.exist(err);
output.service_name.should.equal('SERVICE_NAME');
output.service_number.should.equal('SERVICE_NUMBER');
output.service_job_id.should.equal('SERVICE_JOB_ID');
output.service_pull_request.should.equal('123');
output.parallel.should.equal(true);
//output.git.should.equal("GIT_HASH");
Expand Down
14 changes: 13 additions & 1 deletion test/getOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ describe('getOptions', () => {
it('should set service_name if it exists', done => {
testServiceName(getOptions, done);
});
it('should set service_pull_request if it exists', done => {
it ("should set service_number if it exists", done => {
testServiceNumber(getOptions, done);
});
it("should set service_pull_request if it exists", done => {
testServicePullRequest(getOptions, done);
});
it('should set service_name and service_job_id if it\'s running on travis-ci', done => {
Expand Down Expand Up @@ -334,6 +337,15 @@ const testServiceName = (sut, done) => {
});
};

const testServiceNumber = (sut, done) => {
process.env.COVERALLS_SERVICE_NUMBER = 'SERVICE_NUMBER';
sut((err, options) => {
should.not.exist(err);
options.service_number.should.equal('SERVICE_NUMBER');
done();
});
};

const testServicePullRequest = (sut, done) => {
process.env.CI_PULL_REQUEST = 'https://github.com/fake/fake/pulls/123';
sut((err, options) => {
Expand Down

0 comments on commit b010d3d

Please sign in to comment.