Skip to content

Commit

Permalink
pr_checker: consider LITE CI as a ci requirement
Browse files Browse the repository at this point in the history
Fixes: #225
  • Loading branch information
priyank-p authored Apr 3, 2018
1 parent 8c6f7cc commit e983b41
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/pr_checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions test/fixtures/comments_with_lite_ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"publishedAt": "2018-02-09T21:38:30Z",
"bodyText": "CI: https://ci.nodejs.org/job/node-test-commit-lite/246/"
}
]
2 changes: 2 additions & 0 deletions test/fixtures/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -79,6 +80,7 @@ module.exports = {
approvingReviews,
requestingChangesReviews,
commentsWithCI,
commentsWithLiteCI,
commentsWithLGTM,
oddCommits,
incorrectGitConfigCommits,
Expand Down
28 changes: 28 additions & 0 deletions test/unit/pr_checker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const {
approvingReviews,
requestingChangesReviews,
commentsWithCI,
commentsWithLiteCI,
commentsWithLGTM,
singleCommitAfterReview,
multipleCommitsAfterReview,
Expand Down Expand Up @@ -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', () => {
Expand Down

0 comments on commit e983b41

Please sign in to comment.