This repository has been archived by the owner on Jan 10, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into codebuild
- Loading branch information
Showing
5 changed files
with
90 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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', | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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', | ||
}) | ||
}) | ||
}) |