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

Commit

Permalink
Merge branch 'master' into codebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiemoore committed Sep 20, 2019
2 parents e2f6b81 + f628c33 commit 24a0a76
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 13 deletions.
1 change: 1 addition & 0 deletions lib/detect.js
Expand Up @@ -10,6 +10,7 @@ var services = {
wercker: require('./services/wercker'),
jenkins: require('./services/jenkins'),
semaphore: require('./services/semaphore'),
semaphore2x: require('./services/semaphore2x'),
snap: require('./services/snap'),
gitlab: require('./services/gitlab'),
heroku: require('./services/heroku'),
Expand Down
16 changes: 10 additions & 6 deletions lib/services/semaphore.js
@@ -1,15 +1,19 @@
module.exports = {
detect: function() {
return !!process.env.SEMAPHORE
return !!process.env.SEMAPHORE && !!process.env.SEMAPHORE_REPO_SLUG
},

configuration: function() {
console.log(' Semaphore CI Detected')
console.log(' Semaphore 1.x CI Detected')
return {
service: 'semaphore',
branch: process.env.SEMAPHORE_GIT_BRANCH,
build: process.env.SEMAPHORE_WORKFLOW_ID,
commit: process.env.SEMAPHORE_GIT_SHA,
service: 'semaphore1x',
build:
process.env.SEMAPHORE_BUILD_NUMBER +
'.' +
process.env.SEMAPHORE_CURRENT_THREAD,
commit: process.env.REVISION,
branch: process.env.BRANCH_NAME,
slug: process.env.SEMAPHORE_REPO_SLUG,
}
},
}
15 changes: 15 additions & 0 deletions lib/services/semaphore2x.js
@@ -0,0 +1,15 @@
module.exports = {
detect: function() {
return !!process.env.SEMAPHORE && !!process.env.SEMAPHORE_WORKFLOW_ID
},

configuration: function() {
console.log(' Semaphore 2.x CI Detected')
return {
service: 'semaphore2x',
branch: process.env.SEMAPHORE_GIT_BRANCH,
build: process.env.SEMAPHORE_WORKFLOW_ID,
commit: process.env.SEMAPHORE_GIT_SHA,
}
},
}
34 changes: 27 additions & 7 deletions test/services/semaphore.test.js
@@ -1,20 +1,40 @@
var semaphore = require('../../lib/services/semaphore')

describe('Semaphore CI Provider', function() {
var OLD_ENV = process.env

beforeEach(function() {
process.env = Object.assign({}, OLD_ENV)
})

afterEach(function() {
process.env = Object.assign({}, OLD_ENV)
})

it('can detect semaphore', function() {
process.env.SEMAPHORE = 'true'
process.env.SEMAPHORE_REPO_SLUG = 'owner/repo'
expect(semaphore.detect()).toBe(true)
})

it('can get semaphore env info', function() {
process.env.SEMAPHORE_GIT_BRANCH = 'development'
process.env.SEMAPHORE_GIT_SHA = '5c84719708b9b649b9ef3b56af214f38cee6acde'
it('does not detect semaphore 2.x', function() {
process.env.SEMAPHORE = 'true'
process.env.SEMAPHORE_WORKFLOW_ID = '65c9bb1c-aeb6-41f0-b8d9-6fa177241cdf'
expect(semaphore.detect()).toBe(false)
})

it('can get semaphore env info', function() {
process.env.SEMAPHORE_BUILD_NUMBER = '1234'
process.env.REVISION = '5678'
process.env.SEMAPHORE_CURRENT_THREAD = '1'
process.env.BRANCH_NAME = 'master'
process.env.SEMAPHORE_REPO_SLUG = 'owner/repo'
expect(semaphore.configuration()).toEqual({
service: 'semaphore',
branch: 'development',
build: '65c9bb1c-aeb6-41f0-b8d9-6fa177241cdf',
commit: '5c84719708b9b649b9ef3b56af214f38cee6acde',
service: 'semaphore1x',
commit: '5678',
build: '1234.1',
branch: 'master',
slug: 'owner/repo',
})
})
})
37 changes: 37 additions & 0 deletions test/services/semaphore2x.test.js
@@ -0,0 +1,37 @@
var semaphore2 = require('../../lib/services/semaphore2x')

describe('Semaphore 2.x CI Provider', function() {
var OLD_ENV = process.env

beforeEach(function() {
process.env = Object.assign({}, OLD_ENV)
})

afterEach(function() {
process.env = Object.assign({}, OLD_ENV)
})

it('can detect semaphore 2x', function() {
process.env.SEMAPHORE = 'true'
process.env.SEMAPHORE_WORKFLOW_ID = '65c9bb1c-aeb6-41f0-b8d9-6fa177241cdf'
expect(semaphore2.detect()).toBe(true)
})

it('does not detect semaphore 1.x', function() {
process.env.SEMAPHORE = 'true'
process.env.SEMAPHORE_REPO_SLUG = 'owner/repo'
expect(semaphore2.detect()).toBe(false)
})

it('can get semaphore env info', function() {
process.env.SEMAPHORE_GIT_BRANCH = 'development'
process.env.SEMAPHORE_GIT_SHA = '5c84719708b9b649b9ef3b56af214f38cee6acde'
process.env.SEMAPHORE_WORKFLOW_ID = '65c9bb1c-aeb6-41f0-b8d9-6fa177241cdf'
expect(semaphore2.configuration()).toEqual({
service: 'semaphore2x',
branch: 'development',
build: '65c9bb1c-aeb6-41f0-b8d9-6fa177241cdf',
commit: '5c84719708b9b649b9ef3b56af214f38cee6acde',
})
})
})

0 comments on commit 24a0a76

Please sign in to comment.