From e983b41f784611673eba1d9c8e32acb9824cc29a Mon Sep 17 00:00:00 2001 From: Priyank Patel <23620441+cPhost@users.noreply.github.com> Date: Tue, 3 Apr 2018 08:41:28 -0400 Subject: [PATCH] pr_checker: consider LITE CI as a ci requirement Fixes: https://github.com/nodejs/node-core-utils/issues/225 --- lib/pr_checker.js | 6 ++--- test/fixtures/comments_with_lite_ci.json | 6 +++++ test/fixtures/data.js | 2 ++ test/unit/pr_checker.test.js | 28 ++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 test/fixtures/comments_with_lite_ci.json diff --git a/lib/pr_checker.js b/lib/pr_checker.js index 49ae13c3..19ced56a 100644 --- a/lib/pr_checker.js +++ b/lib/pr_checker.js @@ -19,7 +19,7 @@ const { const CIParser = require('./ci'); const CI_TYPES = CIParser.TYPES; -const { FULL } = CIParser.constants; +const { FULL, LITE } = CIParser.constants; class PRChecker { /** @@ -203,9 +203,9 @@ class PRChecker { cli.error('No CI runs detected'); this.CIStatus = false; return false; - } else if (!ciMap.get(FULL)) { + } else if (!ciMap.get(FULL) && !ciMap.get(LITE)) { status = false; - cli.error('No full CI runs detected'); + cli.error('No full CI runs or lite CI runs detected'); } let lastCI; diff --git a/test/fixtures/comments_with_lite_ci.json b/test/fixtures/comments_with_lite_ci.json new file mode 100644 index 00000000..6ef6a443 --- /dev/null +++ b/test/fixtures/comments_with_lite_ci.json @@ -0,0 +1,6 @@ +[ + { + "publishedAt": "2018-02-09T21:38:30Z", + "bodyText": "CI: https://ci.nodejs.org/job/node-test-commit-lite/246/" + } +] diff --git a/test/fixtures/data.js b/test/fixtures/data.js index 0ab5a126..37535453 100644 --- a/test/fixtures/data.js +++ b/test/fixtures/data.js @@ -23,6 +23,7 @@ const requestedChangesReviewers = { const approvingReviews = readJSON('reviews_approved.json'); const requestingChangesReviews = readJSON('reviews_requesting_changes.json'); +const commentsWithLiteCI = readJSON('comments_with_lite_ci.json'); const commentsWithCI = readJSON('comments_with_ci.json'); const commentsWithLGTM = readJSON('comments_with_lgtm.json'); @@ -79,6 +80,7 @@ module.exports = { approvingReviews, requestingChangesReviews, commentsWithCI, + commentsWithLiteCI, commentsWithLGTM, oddCommits, incorrectGitConfigCommits, diff --git a/test/unit/pr_checker.test.js b/test/unit/pr_checker.test.js index 2c126730..a8fe4c8a 100644 --- a/test/unit/pr_checker.test.js +++ b/test/unit/pr_checker.test.js @@ -13,6 +13,7 @@ const { approvingReviews, requestingChangesReviews, commentsWithCI, + commentsWithLiteCI, commentsWithLGTM, singleCommitAfterReview, multipleCommitsAfterReview, @@ -548,6 +549,33 @@ describe('PRChecker', () => { assert(!status); cli.assertCalledWith(expectedLogs); }); + + it('should count LITE CI as valid ci requirement', () => { + const cli = new TestCLI(); + + const expectedLogs = { + info: [ + [ + 'Last Lite CI on 2018-02-09T21:38:30Z: ' + + 'https://ci.nodejs.org/job/node-test-commit-lite/246/' + ] + ] + }; + + const checker = new PRChecker(cli, { + pr: firstTimerPR, + reviewers: allGreenReviewers, + comments: commentsWithLiteCI, + reviews: approvingReviews, + commits: [], + collaborators, + authorIsNew: () => true + }, { maxCommits: 0 }); + + const status = checker.checkCI(); + assert(status); + cli.assertCalledWith(expectedLogs); + }); }); describe('checkAuthor', () => {