Skip to content

Commit

Permalink
feat: update CI requirements for landing pull requests (#533)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alicia Lopez committed Feb 26, 2021
1 parent 304b5f4 commit ae04eec
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 14 deletions.
38 changes: 28 additions & 10 deletions lib/pr_checker.js
Expand Up @@ -397,8 +397,8 @@ class PRChecker {
return true;
}

isOnlyDocChanges() {
const { cli, pr } = this;
requiresJenkinsRun() {
const { pr } = this;

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

for (const { path } of pr.files.nodes) {
if (!path.endsWith('.md')) {
return false;
}
}
cli.info('Doc-only changes');
return true;
const ciNeededFolderRx = /^(deps|lib|src|test)\//;
const ciNeededToolFolderRx =
/^tools\/(code_cache|gyp|icu|inspector|msvs|snapshot|v8_gypfiles)/;
const ciNeededFileRx = /^tools\/\.+.py$/;
const ciNeededFileList = [
'tools/build-addons.js',
'configure',
'configure.py',
'Makefile'
];
const ciNeededExtensionList = ['.gyp', '.gypi', '.bat'];

return pr.files.nodes.some(
({ path }) =>
ciNeededFolderRx.test(path) ||
ciNeededToolFolderRx.test(path) ||
ciNeededFileRx.test(path) ||
ciNeededFileList.includes(path) ||
ciNeededExtensionList.some((ext) => path.endsWith(ext))
);
}

async checkNodejsCI() {
let status = this.checkActionsCI();
if (!this.isOnlyDocChanges()) {
if (
this.pr.labels.nodes.some((l) => l.name === 'needs-ci') ||
this.requiresJenkinsRun()
) {
status &= await this.checkJenkinsCI();
} else {
this.cli.info('Green GitHub Actions CI is sufficient');
}
return status;
}
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/first_timer_pr.json
Expand Up @@ -11,6 +11,9 @@
"bodyText": "Awesome changes",
"labels": {
"nodes": [
{
"name": "needs-ci"
},
{
"name": "test"
},
Expand Down
6 changes: 3 additions & 3 deletions test/unit/pr_checker.test.js
Expand Up @@ -655,7 +655,7 @@ describe('PRChecker', () => {
['No GitHub CI runs detected']
],
info: [
['Doc-only changes']
['Green GitHub Actions CI is sufficient']
]
};

Expand Down Expand Up @@ -697,7 +697,7 @@ describe('PRChecker', () => {
['Last GitHub Actions successful']
],
info: [
['Doc-only changes']
['Green GitHub Actions CI is sufficient']
]
};

Expand Down Expand Up @@ -741,7 +741,7 @@ describe('PRChecker', () => {
['Last GitHub Actions successful']
],
info: [
['Doc-only changes']
['Green GitHub Actions CI is sufficient']
]
};

Expand Down
2 changes: 1 addition & 1 deletion test/unit/pr_summary.test.js
Expand Up @@ -44,7 +44,7 @@ describe('PRSummary', () => {
'Their Github Account email <pr_author@example.com>' +
' (@pr_author, first-time contributor)'],
['Branch', 'pr_author:awesome-changes -> nodejs:master'],
['Labels', 'test, doc'],
['Labels', 'needs-ci, test, doc'],
['Commits', '6'],
['Committers', '3']
]
Expand Down

0 comments on commit ae04eec

Please sign in to comment.