Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Commit 24a0a76

Browse files
authored
Merge branch 'master' into codebuild
2 parents e2f6b81 + f628c33 commit 24a0a76

File tree

5 files changed

+90
-13
lines changed

5 files changed

+90
-13
lines changed

lib/detect.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ var services = {
1010
wercker: require('./services/wercker'),
1111
jenkins: require('./services/jenkins'),
1212
semaphore: require('./services/semaphore'),
13+
semaphore2x: require('./services/semaphore2x'),
1314
snap: require('./services/snap'),
1415
gitlab: require('./services/gitlab'),
1516
heroku: require('./services/heroku'),

lib/services/semaphore.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
module.exports = {
22
detect: function() {
3-
return !!process.env.SEMAPHORE
3+
return !!process.env.SEMAPHORE && !!process.env.SEMAPHORE_REPO_SLUG
44
},
55

66
configuration: function() {
7-
console.log(' Semaphore CI Detected')
7+
console.log(' Semaphore 1.x CI Detected')
88
return {
9-
service: 'semaphore',
10-
branch: process.env.SEMAPHORE_GIT_BRANCH,
11-
build: process.env.SEMAPHORE_WORKFLOW_ID,
12-
commit: process.env.SEMAPHORE_GIT_SHA,
9+
service: 'semaphore1x',
10+
build:
11+
process.env.SEMAPHORE_BUILD_NUMBER +
12+
'.' +
13+
process.env.SEMAPHORE_CURRENT_THREAD,
14+
commit: process.env.REVISION,
15+
branch: process.env.BRANCH_NAME,
16+
slug: process.env.SEMAPHORE_REPO_SLUG,
1317
}
1418
},
1519
}

lib/services/semaphore2x.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = {
2+
detect: function() {
3+
return !!process.env.SEMAPHORE && !!process.env.SEMAPHORE_WORKFLOW_ID
4+
},
5+
6+
configuration: function() {
7+
console.log(' Semaphore 2.x CI Detected')
8+
return {
9+
service: 'semaphore2x',
10+
branch: process.env.SEMAPHORE_GIT_BRANCH,
11+
build: process.env.SEMAPHORE_WORKFLOW_ID,
12+
commit: process.env.SEMAPHORE_GIT_SHA,
13+
}
14+
},
15+
}

test/services/semaphore.test.js

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,40 @@
11
var semaphore = require('../../lib/services/semaphore')
22

33
describe('Semaphore CI Provider', function() {
4+
var OLD_ENV = process.env
5+
6+
beforeEach(function() {
7+
process.env = Object.assign({}, OLD_ENV)
8+
})
9+
10+
afterEach(function() {
11+
process.env = Object.assign({}, OLD_ENV)
12+
})
13+
414
it('can detect semaphore', function() {
515
process.env.SEMAPHORE = 'true'
16+
process.env.SEMAPHORE_REPO_SLUG = 'owner/repo'
617
expect(semaphore.detect()).toBe(true)
718
})
819

9-
it('can get semaphore env info', function() {
10-
process.env.SEMAPHORE_GIT_BRANCH = 'development'
11-
process.env.SEMAPHORE_GIT_SHA = '5c84719708b9b649b9ef3b56af214f38cee6acde'
20+
it('does not detect semaphore 2.x', function() {
21+
process.env.SEMAPHORE = 'true'
1222
process.env.SEMAPHORE_WORKFLOW_ID = '65c9bb1c-aeb6-41f0-b8d9-6fa177241cdf'
23+
expect(semaphore.detect()).toBe(false)
24+
})
25+
26+
it('can get semaphore env info', function() {
27+
process.env.SEMAPHORE_BUILD_NUMBER = '1234'
28+
process.env.REVISION = '5678'
29+
process.env.SEMAPHORE_CURRENT_THREAD = '1'
30+
process.env.BRANCH_NAME = 'master'
31+
process.env.SEMAPHORE_REPO_SLUG = 'owner/repo'
1332
expect(semaphore.configuration()).toEqual({
14-
service: 'semaphore',
15-
branch: 'development',
16-
build: '65c9bb1c-aeb6-41f0-b8d9-6fa177241cdf',
17-
commit: '5c84719708b9b649b9ef3b56af214f38cee6acde',
33+
service: 'semaphore1x',
34+
commit: '5678',
35+
build: '1234.1',
36+
branch: 'master',
37+
slug: 'owner/repo',
1838
})
1939
})
2040
})

test/services/semaphore2x.test.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
var semaphore2 = require('../../lib/services/semaphore2x')
2+
3+
describe('Semaphore 2.x CI Provider', function() {
4+
var OLD_ENV = process.env
5+
6+
beforeEach(function() {
7+
process.env = Object.assign({}, OLD_ENV)
8+
})
9+
10+
afterEach(function() {
11+
process.env = Object.assign({}, OLD_ENV)
12+
})
13+
14+
it('can detect semaphore 2x', function() {
15+
process.env.SEMAPHORE = 'true'
16+
process.env.SEMAPHORE_WORKFLOW_ID = '65c9bb1c-aeb6-41f0-b8d9-6fa177241cdf'
17+
expect(semaphore2.detect()).toBe(true)
18+
})
19+
20+
it('does not detect semaphore 1.x', function() {
21+
process.env.SEMAPHORE = 'true'
22+
process.env.SEMAPHORE_REPO_SLUG = 'owner/repo'
23+
expect(semaphore2.detect()).toBe(false)
24+
})
25+
26+
it('can get semaphore env info', function() {
27+
process.env.SEMAPHORE_GIT_BRANCH = 'development'
28+
process.env.SEMAPHORE_GIT_SHA = '5c84719708b9b649b9ef3b56af214f38cee6acde'
29+
process.env.SEMAPHORE_WORKFLOW_ID = '65c9bb1c-aeb6-41f0-b8d9-6fa177241cdf'
30+
expect(semaphore2.configuration()).toEqual({
31+
service: 'semaphore2x',
32+
branch: 'development',
33+
build: '65c9bb1c-aeb6-41f0-b8d9-6fa177241cdf',
34+
commit: '5c84719708b9b649b9ef3b56af214f38cee6acde',
35+
})
36+
})
37+
})

0 commit comments

Comments
 (0)