Skip to content

Commit f4be765

Browse files
joyeecheungtargos
authored andcommitted
land: fast-track code and learn PRs
Co-Authored-By: targos <[email protected]>
1 parent 0179399 commit f4be765

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

lib/pr_checker.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ class PRChecker {
115115
const labels = pr.labels.nodes.map((l) => l.name);
116116

117117
const isFastTracked = labels.includes('fast-track');
118+
const isCodeAndLearn = labels.includes('code-and-learn');
118119
const isSemverMajor = labels.includes('semver-major');
119120

120121
const dateStr = new Date(pr.createdAt).toUTCString();
@@ -124,6 +125,9 @@ class PRChecker {
124125
// these labels removed because that doesn't make sense
125126
if (isFastTracked) {
126127
cli.info('This PR is being fast-tracked');
128+
} else if (isCodeAndLearn) {
129+
cli.info('This PR is being fast-tracked because ' +
130+
'it is from a Code and Learn event');
127131
}
128132

129133
if (approved.length === 0 || requestedChanges.length > 0) {
@@ -148,7 +152,7 @@ class PRChecker {
148152
const timeLeftSingle = WAIT_TIME_SINGLE_APPROVAL - hoursFromCreateTime;
149153

150154
if (approved.length >= 2) {
151-
if (isFastTracked) {
155+
if (isFastTracked || isCodeAndLearn) {
152156
return true;
153157
}
154158
if (timeLeftMulti < 0) {

test/unit/pr_checker.test.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,52 @@ describe('PRChecker', () => {
370370
cli.assertCalledWith(expectedLogs);
371371
});
372372

373+
it('should fast track code-and-learn PRs', () => {
374+
const cli = new TestCLI();
375+
376+
const expectedLogs = {
377+
ok:
378+
[ [ 'Approvals: 4' ],
379+
[ '- Foo User (@foo): https://github.com/nodejs/node/pull/16438#pullrequestreview-71480624' ],
380+
[ '- Quux User (@Quux): LGTM' ],
381+
[ '- Baz User (@Baz): https://github.com/nodejs/node/pull/16438#pullrequestreview-71488236' ],
382+
[ '- Bar User (@bar) (TSC): lgtm' ] ],
383+
info:
384+
[ [ 'This PR was created on Fri, 30 Nov 2018 17:50:44 GMT' ],
385+
[ 'This PR is being fast-tracked because ' +
386+
'it is from a Code and Learn event' ]
387+
]
388+
};
389+
390+
const pr = Object.assign({}, firstTimerPR, {
391+
createdAt: LT_48H,
392+
labels: {
393+
nodes: [
394+
{ name: 'code-and-learn' }
395+
]
396+
}
397+
});
398+
399+
const data = {
400+
pr,
401+
reviewers: allGreenReviewers,
402+
comments: commentsWithCI,
403+
reviews: approvingReviews,
404+
commits: [],
405+
collaborators,
406+
authorIsNew: () => true,
407+
getThread() {
408+
return PRData.prototype.getThread.call(this);
409+
}
410+
};
411+
const checker = new PRChecker(cli, data, argv);
412+
413+
cli.clearCalls();
414+
const status = checker.checkReviewsAndWait(new Date(NOW));
415+
assert(status);
416+
cli.assertCalledWith(expectedLogs);
417+
});
418+
373419
it('should warn about approvals and CI for fast-tracked PR', () => {
374420
const cli = new TestCLI();
375421

0 commit comments

Comments
 (0)