diff options
| author | Wojtek Siudzinski <[email protected]> | 2019-12-11 18:44:41 +0100 |
|---|---|---|
| committer | Nick Merwin <[email protected]> | 2020-03-19 09:58:58 -0700 |
| commit | 710c50448f79d7145f524948ddd7a5e9f548fa42 (patch) | |
| tree | 1ef7f1f06b6f27e45d7bd21a3ae3720109672512 | |
| parent | 8c4ba99c2a0bf23b8d6d607c78e090863a0bbb69 (diff) | |
| download | node-coveralls-710c50448f79d7145f524948ddd7a5e9f548fa42.tar.xz node-coveralls-710c50448f79d7145f524948ddd7a5e9f548fa42.zip | |
Add Codefresh support
| -rw-r--r-- | lib/getOptions.js | 10 | ||||
| -rw-r--r-- | test/getOptions.js | 34 |
2 files changed, 44 insertions, 0 deletions
diff --git a/lib/getOptions.js b/lib/getOptions.js index 8a0305f..ac12fc6 100644 --- a/lib/getOptions.js +++ b/lib/getOptions.js @@ -131,6 +131,16 @@ const getBaseOptions = cb => { git_branch = process.env.BUILD_SOURCEBRANCHNAME; } + if (process.env.CF_BRANCH) { + options.service_name = 'Codefresh'; + options.service_job_id = process.env.CF_BUILD_ID; + options.service_pull_request = process.env.CF_PULL_REQUEST_ID; + git_commit = process.env.CF_REVISION; + git_branch = process.env.CF_BRANCH; + git_committer_name = process.env.CF_COMMIT_AUTHOR; + git_message = process.env.CF_COMMIT_MESSAGE; + } + options.run_at = process.env.COVERALLS_RUN_AT || JSON.stringify(new Date()).slice(1, -1); if (process.env.COVERALLS_SERVICE_NAME) { options.service_name = process.env.COVERALLS_SERVICE_NAME; diff --git a/test/getOptions.js b/test/getOptions.js index ba6ca7d..becb31f 100644 --- a/test/getOptions.js +++ b/test/getOptions.js @@ -170,6 +170,9 @@ describe('getOptions', () => { it('should set service_name and service_job_id if it\'s running via Azure Pipelines', done => { testAzurePipelines(getOptions, done); }); + it('should set service_name and service_job_id if it\'s running via CodeFresh', done => { + testCodefresh(getOptions, done); + }); it('should override set options with user options', done => { const userOptions = { service_name: 'OVERRIDDEN_SERVICE_NAME' }; process.env.COVERALLS_SERVICE_NAME = 'SERVICE_NAME'; @@ -665,6 +668,37 @@ const testAzurePipelines = (sut, done) => { }); }; +const testCodefresh = (sut, done) => { + process.env.CF_BRANCH = 'hotfix'; + process.env.CF_REVISION = 'e3e3e3e3e3e3e3e3e'; + process.env.CF_BUILD_ID = '1234'; + process.env.CF_COMMIT_AUTHOR = 'john doe'; + process.env.CF_COMMIT_MESSAGE = 'msgmsgmsg'; + process.env.CF_PULL_REQUEST_ID = '3'; + + const git = { + head: { + id: 'e3e3e3e3e3e3e3e3e', + author_name: 'Unknown Author', + author_email: '', + committer_name: 'john doe', + committer_email: '', + message: 'msgmsgmsg' + }, + branch: 'hotfix', + remotes: [] + }; + + sut((err, options) => { + should.not.exist(err); + options.service_name.should.equal('Codefresh'); + options.service_job_id.should.equal('1234'); + options.service_pull_request.should.equal('3'); + options.git.should.eql(git); + done(); + }); +}; + function ensureLocalGitContext(options) { const baseDir = process.cwd(); let dir = baseDir; |
