Skip to content

Commit 39d4c8b

Browse files
committed
feat: update CI requirements for landing pull requests (#533)
Refs: nodejs/node#37308
1 parent f2a3fdf commit 39d4c8b

File tree

4 files changed

+35
-14
lines changed

4 files changed

+35
-14
lines changed

lib/pr_checker.js

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,8 @@ class PRChecker {
397397
return true;
398398
}
399399

400-
isOnlyDocChanges() {
401-
const { cli, pr } = this;
400+
requiresJenkinsRun() {
401+
const { pr } = this;
402402

403403
// NOTE(mmarchini): if files not present, fallback
404404
// to old behavior. This should only be the case on old tests
@@ -407,19 +407,37 @@ class PRChecker {
407407
return false;
408408
}
409409

410-
for (const { path } of pr.files.nodes) {
411-
if (!path.endsWith('.md')) {
412-
return false;
413-
}
414-
}
415-
cli.info('Doc-only changes');
416-
return true;
410+
const ciNeededFolderRx = /^(deps|lib|src|test)\//;
411+
const ciNeededToolFolderRx =
412+
/^tools\/(code_cache|gyp|icu|inspector|msvs|snapshot|v8_gypfiles)/;
413+
const ciNeededFileRx = /^tools\/\.+.py$/;
414+
const ciNeededFileList = [
415+
'tools/build-addons.js',
416+
'configure',
417+
'configure.py',
418+
'Makefile'
419+
];
420+
const ciNeededExtensionList = ['.gyp', '.gypi', '.bat'];
421+
422+
return pr.files.nodes.some(
423+
({ path }) =>
424+
ciNeededFolderRx.test(path) ||
425+
ciNeededToolFolderRx.test(path) ||
426+
ciNeededFileRx.test(path) ||
427+
ciNeededFileList.includes(path) ||
428+
ciNeededExtensionList.some((ext) => path.endsWith(ext))
429+
);
417430
}
418431

419432
async checkNodejsCI() {
420433
let status = this.checkActionsCI();
421-
if (!this.isOnlyDocChanges()) {
434+
if (
435+
this.pr.labels.nodes.some((l) => l.name === 'needs-ci') ||
436+
this.requiresJenkinsRun()
437+
) {
422438
status &= await this.checkJenkinsCI();
439+
} else {
440+
this.cli.info('Green GitHub Actions CI is sufficient');
423441
}
424442
return status;
425443
}

test/fixtures/first_timer_pr.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
"bodyText": "Awesome changes",
1212
"labels": {
1313
"nodes": [
14+
{
15+
"name": "needs-ci"
16+
},
1417
{
1518
"name": "test"
1619
},

test/unit/pr_checker.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ describe('PRChecker', () => {
655655
['No GitHub CI runs detected']
656656
],
657657
info: [
658-
['Doc-only changes']
658+
['Green GitHub Actions CI is sufficient']
659659
]
660660
};
661661

@@ -697,7 +697,7 @@ describe('PRChecker', () => {
697697
['Last GitHub Actions successful']
698698
],
699699
info: [
700-
['Doc-only changes']
700+
['Green GitHub Actions CI is sufficient']
701701
]
702702
};
703703

@@ -741,7 +741,7 @@ describe('PRChecker', () => {
741741
['Last GitHub Actions successful']
742742
],
743743
info: [
744-
['Doc-only changes']
744+
['Green GitHub Actions CI is sufficient']
745745
]
746746
};
747747

test/unit/pr_summary.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('PRSummary', () => {
4444
'Their Github Account email <[email protected]>' +
4545
' (@pr_author, first-time contributor)'],
4646
['Branch', 'pr_author:awesome-changes -> nodejs:master'],
47-
['Labels', 'test, doc'],
47+
['Labels', 'needs-ci, test, doc'],
4848
['Commits', '6'],
4949
['Committers', '3']
5050
]

0 commit comments

Comments
 (0)