From 311a0d17781e1e7d4ad7099d749f7ea43499667e Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Sat, 23 Mar 2019 00:38:31 +0800 Subject: [PATCH] ncu-ci: parse node-test-pull-request-lite-pipeline pipelines Fixes: https://github.com/nodejs/node-core-utils/issues/259 --- lib/ci/ci_type_parser.js | 5 ++--- test/unit/ci_type_parser.test.js | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/ci/ci_type_parser.js b/lib/ci/ci_type_parser.js index a41543c0..61161280 100644 --- a/lib/ci/ci_type_parser.js +++ b/lib/ci/ci_type_parser.js @@ -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, { @@ -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, diff --git a/test/unit/ci_type_parser.test.js b/test/unit/ci_type_parser.test.js index 495056b8..e090c921 100644 --- a/test/unit/ci_type_parser.test.js +++ b/test/unit/ci_type_parser.test.js @@ -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 + }]]); + }); });