Skip to content

Commit b010d3d

Browse files
authored
If COVERALLS_SERVICE_NUMBER is set, set service_number from it. (#208)
* If COVERALLS_SERVICE_NUMBER is set, set service_number from it. Remove the duplicate service_pull_request set.
1 parent 2ea7be3 commit b010d3d

File tree

4 files changed

+26
-7
lines changed

4 files changed

+26
-7
lines changed

lib/convertLcovToCoveralls.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ const convertLcovToCoveralls = (input, options, cb) => {
7979
if (options.service_name) {
8080
postJson.service_name = options.service_name;
8181
}
82-
82+
83+
if (options.service_number) {
84+
postJson.service_number = options.service_number;
85+
}
86+
8387
if (options.service_job_id) {
8488
postJson.service_job_id = options.service_job_id;
8589
}
@@ -95,11 +99,6 @@ const convertLcovToCoveralls = (input, options, cb) => {
9599
if (options.parallel) {
96100
postJson.parallel = options.parallel;
97101
}
98-
99-
if (options.service_pull_request) {
100-
postJson.service_pull_request = options.service_pull_request;
101-
}
102-
103102
parsed.forEach(file => {
104103
file.file = cleanFilePath(file.file);
105104
const currentFilePath = path.resolve(filepath, file.file);

lib/getOptions.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ const getBaseOptions = cb => {
143143

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

146+
if (process.env.COVERALLS_SERVICE_NUMBER) {
147+
options.service_number = process.env.COVERALLS_SERVICE_NUMBER;
148+
}
149+
146150
if (process.env.COVERALLS_SERVICE_JOB_ID) {
147151
options.service_job_id = process.env.COVERALLS_SERVICE_JOB_ID;
148152
}

test/convertLcovToCoveralls.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ describe('convertLcovToCoveralls', () => {
2929
process.env.COVERALLS_GIT_COMMIT = 'GIT_HASH';
3030
process.env.COVERALLS_GIT_BRANCH = 'master';
3131
process.env.COVERALLS_SERVICE_NAME = 'SERVICE_NAME';
32+
process.env.COVERALLS_SERVICE_NUMBER = 'SERVICE_NUMBER';
3233
process.env.COVERALLS_SERVICE_JOB_ID = 'SERVICE_JOB_ID';
3334
process.env.COVERALLS_REPO_TOKEN = 'REPO_TOKEN';
3435
process.env.CI_PULL_REQUEST = 'https://github.com/fake/fake/pulls/123';
@@ -43,6 +44,9 @@ describe('convertLcovToCoveralls', () => {
4344
options.filepath = libpath;
4445
convertLcovToCoveralls(input, options, (err, output) => {
4546
should.not.exist(err);
47+
output.service_name.should.equal('SERVICE_NAME');
48+
output.service_number.should.equal('SERVICE_NUMBER');
49+
output.service_job_id.should.equal('SERVICE_JOB_ID');
4650
output.service_pull_request.should.equal('123');
4751
output.parallel.should.equal(true);
4852
//output.git.should.equal("GIT_HASH");

test/getOptions.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ describe('getOptions', () => {
134134
it('should set service_name if it exists', done => {
135135
testServiceName(getOptions, done);
136136
});
137-
it('should set service_pull_request if it exists', done => {
137+
it ("should set service_number if it exists", done => {
138+
testServiceNumber(getOptions, done);
139+
});
140+
it("should set service_pull_request if it exists", done => {
138141
testServicePullRequest(getOptions, done);
139142
});
140143
it('should set service_name and service_job_id if it\'s running on travis-ci', done => {
@@ -334,6 +337,15 @@ const testServiceName = (sut, done) => {
334337
});
335338
};
336339

340+
const testServiceNumber = (sut, done) => {
341+
process.env.COVERALLS_SERVICE_NUMBER = 'SERVICE_NUMBER';
342+
sut((err, options) => {
343+
should.not.exist(err);
344+
options.service_number.should.equal('SERVICE_NUMBER');
345+
done();
346+
});
347+
};
348+
337349
const testServicePullRequest = (sut, done) => {
338350
process.env.CI_PULL_REQUEST = 'https://github.com/fake/fake/pulls/123';
339351
sut((err, options) => {

0 commit comments

Comments
 (0)