-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #263 from test-results-reporter/feat/circle-ci-inf…
…o-extn feat: Extend ci-info extension to get Circle CI information
- Loading branch information
Showing
4 changed files
with
143 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const ENV = process.env; | ||
|
||
/** | ||
* @returns {import('../../extensions/extensions').ICIInfo} | ||
*/ | ||
function info() { | ||
const circle = { | ||
ci: 'CIRCLE_CI', | ||
git: '', | ||
repository_url: ENV.CIRCLE_REPOSITORY_URL, | ||
repository_name: ENV.CIRCLE_PROJECT_REPONAME, // Need to find a better match | ||
repository_ref: ENV.CIRCLE_BRANCH, | ||
repository_commit_sha: ENV.CIRCLE_SHA1, | ||
branch_url: '', | ||
branch_name: ENV.CIRCLE_BRANCH, | ||
pull_request_url:'', | ||
pull_request_name: '', | ||
build_url: ENV.CIRCLE_BUILD_URL, | ||
build_number: ENV.CIRCLE_BUILD_NUM, | ||
build_name: ENV.CIRCLE_JOB, | ||
build_reason: 'Push', | ||
user: ENV.CIRCLE_USERNAME, | ||
} | ||
return circle | ||
} | ||
|
||
module.exports = { | ||
info | ||
} |
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 |
---|---|---|
|
@@ -14,17 +14,27 @@ describe('extensions - ci-info', () => { | |
process.env.GITHUB_RUN_NUMBER = ''; | ||
process.env.GITHUB_WORKFLOW = ''; | ||
|
||
process.env.GITLAB_CI='' | ||
process.env.CI_PROJECT_URL = '' | ||
process.env.CI_PROJECT_NAME = '' | ||
process.env.CI_COMMIT_REF_NAME = '' | ||
process.env.CI_COMMIT_SHA = '' | ||
process.env.CI_JOB_URL = '' | ||
process.env.CI_JOB_ID = '' | ||
process.env.CI_JOB_NAME = '' | ||
process.env.CI_PIPELINE_SOURCE = '' | ||
process.env.GITLAB_CI = ''; | ||
process.env.CI_PROJECT_URL = ''; | ||
process.env.CI_PROJECT_NAME = ''; | ||
process.env.CI_COMMIT_REF_NAME = ''; | ||
process.env.CI_COMMIT_SHA = ''; | ||
process.env.CI_JOB_URL = ''; | ||
process.env.CI_JOB_ID = ''; | ||
process.env.CI_JOB_NAME = ''; | ||
process.env.CI_PIPELINE_SOURCE = ''; | ||
process.env.GITLAB_USER_LOGIN = ''; | ||
|
||
process.env.CIRCLECI = ''; | ||
process.env.CIRCLE_REPOSITORY_URL = ''; | ||
process.env.CIRCLE_PROJECT_REPONAME = ''; // Need to find a better match | ||
process.env.CIRCLE_SHA1 = ''; | ||
process.env.CIRCLE_BRANCH = ''; | ||
process.env.CIRCLE_BUILD_URL = ''; | ||
process.env.CIRCLE_BUILD_NUM = ''; | ||
process.env.CIRCLE_JOB = ''; | ||
process.env.CIRCLE_USERNAME = ''; | ||
|
||
process.env.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI = ''; | ||
process.env.BUILD_REPOSITORY_URI = ''; | ||
process.env.BUILD_REPOSITORY_NAME = ''; | ||
|
@@ -182,15 +192,15 @@ describe('extensions - ci-info', () => { | |
}); | ||
|
||
it('should send test-summary with gitlab ci information to slack', async () => { | ||
process.env.GITLAB_CI=true | ||
process.env.CI_PROJECT_URL = 'https://gitlab.com/testbeats/demo' | ||
process.env.CI_PROJECT_NAME = 'demo' | ||
process.env.CI_COMMIT_REF_NAME = 'branch' | ||
process.env.CI_COMMIT_SHA = 'sha' | ||
process.env.CI_JOB_URL = 'https://gitlab.com/testbeats/demo/-/jobs/id-123' | ||
process.env.CI_JOB_ID = 'id-123' | ||
process.env.CI_JOB_NAME = 'Test' | ||
process.env.CI_PIPELINE_SOURCE = 'push' | ||
process.env.GITLAB_CI = true; | ||
process.env.CI_PROJECT_URL = 'https://gitlab.com/testbeats/demo'; | ||
process.env.CI_PROJECT_NAME = 'demo'; | ||
process.env.CI_COMMIT_REF_NAME = 'branch'; | ||
process.env.CI_COMMIT_SHA = 'sha'; | ||
process.env.CI_JOB_URL = 'https://gitlab.com/testbeats/demo/-/jobs/id-123'; | ||
process.env.CI_JOB_ID = 'id-123'; | ||
process.env.CI_JOB_NAME = 'Test'; | ||
process.env.CI_PIPELINE_SOURCE = 'push'; | ||
process.env.GITLAB_USER_LOGIN = 'dummy-user'; | ||
|
||
const id = mock.addInteraction('post test-summary with gitlab ci-info to slack'); | ||
|
@@ -223,16 +233,16 @@ describe('extensions - ci-info', () => { | |
}); | ||
|
||
it('should send test-summary with gitlab ci information to slack - with PR', async () => { | ||
process.env.GITLAB_CI=true | ||
process.env.CI_OPEN_MERGE_REQUESTS='testbeats/demo!1' | ||
process.env.CI_PROJECT_URL = 'https://gitlab.com/testbeats/demo' | ||
process.env.CI_PROJECT_NAME = 'demo' | ||
process.env.CI_COMMIT_REF_NAME = 'branch' | ||
process.env.CI_COMMIT_SHA = 'sha' | ||
process.env.CI_JOB_URL = 'https://gitlab.com/testbeats/demo/-/jobs/id-123' | ||
process.env.CI_JOB_ID = 'id-123' | ||
process.env.CI_JOB_NAME = 'Test' | ||
process.env.CI_PIPELINE_SOURCE = 'push' | ||
process.env.GITLAB_CI = true; | ||
process.env.CI_OPEN_MERGE_REQUESTS = 'testbeats/demo!1'; | ||
process.env.CI_PROJECT_URL = 'https://gitlab.com/testbeats/demo'; | ||
process.env.CI_PROJECT_NAME = 'demo'; | ||
process.env.CI_COMMIT_REF_NAME = 'branch'; | ||
process.env.CI_COMMIT_SHA = 'sha'; | ||
process.env.CI_JOB_URL = 'https://gitlab.com/testbeats/demo/-/jobs/id-123'; | ||
process.env.CI_JOB_ID = 'id-123'; | ||
process.env.CI_JOB_NAME = 'Test'; | ||
process.env.CI_PIPELINE_SOURCE = 'push'; | ||
process.env.GITLAB_USER_LOGIN = 'dummy-user'; | ||
|
||
const id = mock.addInteraction('post test-summary with gitlab ci-info with PR to slack'); | ||
|
@@ -264,6 +274,46 @@ describe('extensions - ci-info', () => { | |
assert.equal(mock.getInteraction(id).exercised, true); | ||
}); | ||
|
||
it('should send test-summary with circle-ci\'s ci information to slack', async () => { | ||
process.env.CIRCLECI = true; | ||
process.env.CIRCLE_REPOSITORY_URL = ''; | ||
process.env.CIRCLE_PROJECT_REPONAME = 'demo'; | ||
process.env.CIRCLE_BRANCH = 'branch'; | ||
process.env.CIRCLE_SHA1 = 'sja'; | ||
process.env.CIRCLE_BUILD_URL = 'https://apphttps://app.circleci.com/jobs/circleci/uuid-1/uuid-2'; | ||
process.env.CIRCLE_BUILD_NUM = 1; | ||
process.env.CIRCLE_JOB = 'Test_Build'; | ||
process.env.CIRCLE_USERNAME = '[email protected]'; | ||
|
||
const id = mock.addInteraction('post test-summary with circle-ci ci-info to slack'); | ||
await publish({ | ||
config: { | ||
targets: [ | ||
{ | ||
name: 'slack', | ||
inputs: { | ||
url: 'http://localhost:9393/message' | ||
}, | ||
extensions: [ | ||
{ | ||
name: 'ci-info' | ||
} | ||
] | ||
} | ||
], | ||
results: [ | ||
{ | ||
type: 'testng', | ||
files: [ | ||
'test/data/testng/single-suite.xml' | ||
] | ||
} | ||
] | ||
} | ||
}); | ||
assert.equal(mock.getInteraction(id).exercised, true); | ||
}); | ||
|
||
it('should send test-summary with azure devops ci information to chat and extra data', async () => { | ||
process.env.GITHUB_ACTIONS = 'GITHUB_ACTIONS'; | ||
process.env.GITHUB_SERVER_URL = 'https://github.com'; | ||
|
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