Skip to content

Commit

Permalink
ncu-ci: parse node-test-pull-request-lite-pipeline pipelines
Browse files Browse the repository at this point in the history
Fixes: #259
  • Loading branch information
joyeecheung committed Mar 22, 2019
1 parent 63ffb65 commit 311a0d1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
5 changes: 2 additions & 3 deletions lib/ci/ci_type_parser.js
Expand Up @@ -86,7 +86,7 @@ const CI_TYPES = new Map([
[LITE_PR_PIPELINE, {
name: 'Lite PR Pipeline',
jobName: 'node-test-pull-request-lite-pipeline',
pattern: /job\/node-test-pull-request-lite-pipeline\/(\d+)\/pipeline/,
pattern: /node-test-pull-request-lite-pipeline\/(\d+)\/pipeline/,
type: LITE_CI
}],
[LITE_COMMIT, {
Expand Down Expand Up @@ -120,8 +120,7 @@ function parseJobFromURL(url) {
}

for (let [ type, info ] of CI_TYPES) {
const re = new RegExp(`job/${info.jobName}/(\\d+)`);
const match = url.match(re);
const match = url.match(info.pattern);
if (match) {
return {
link: url,
Expand Down
15 changes: 14 additions & 1 deletion test/unit/ci_type_parser.test.js
Expand Up @@ -56,10 +56,23 @@ const expected = new Map([
jobid: 7213
}]
]);

describe('JobParser', () => {
it('should parse CI results', () => {
const results = new JobParser(commentsWithCI).parse();
assert.deepStrictEqual([...results.entries()], [...expected.entries()]);
});

it('should parse pipeline links', () => {
const data = [{
'publishedAt': '2017-10-29T04:16:36.458Z',
'bodyText': '@contributer build started: https://ci.nodejs.org/blue/organizations/jenkins/node-test-pull-request-lite-pipeline/detail/node-test-pull-request-lite-pipeline/3009/pipeline/'
}];
const results = new JobParser(data).parse();
assert.deepStrictEqual([...results.entries()], [
['LITE_PR_PIPELINE', {
link: 'https://ci.nodejs.org/blue/organizations/jenkins/node-test-pull-request-lite-pipeline/detail/node-test-pull-request-lite-pipeline/3009/pipeline/',
date: '2017-10-29T04:16:36.458Z',
jobid: 3009
}]]);
});
});

0 comments on commit 311a0d1

Please sign in to comment.