diff --git a/lib/pr_checker.js b/lib/pr_checker.js index 5aceb94d..77e638e5 100644 --- a/lib/pr_checker.js +++ b/lib/pr_checker.js @@ -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 @@ -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; } diff --git a/test/fixtures/first_timer_pr.json b/test/fixtures/first_timer_pr.json index 1fce6480..8e57b7c6 100644 --- a/test/fixtures/first_timer_pr.json +++ b/test/fixtures/first_timer_pr.json @@ -11,6 +11,9 @@ "bodyText": "Awesome changes", "labels": { "nodes": [ + { + "name": "needs-ci" + }, { "name": "test" }, diff --git a/test/unit/pr_checker.test.js b/test/unit/pr_checker.test.js index 134015a6..2c915943 100644 --- a/test/unit/pr_checker.test.js +++ b/test/unit/pr_checker.test.js @@ -655,7 +655,7 @@ describe('PRChecker', () => { ['No GitHub CI runs detected'] ], info: [ - ['Doc-only changes'] + ['Green GitHub Actions CI is sufficient'] ] }; @@ -697,7 +697,7 @@ describe('PRChecker', () => { ['Last GitHub Actions successful'] ], info: [ - ['Doc-only changes'] + ['Green GitHub Actions CI is sufficient'] ] }; @@ -741,7 +741,7 @@ describe('PRChecker', () => { ['Last GitHub Actions successful'] ], info: [ - ['Doc-only changes'] + ['Green GitHub Actions CI is sufficient'] ] }; diff --git a/test/unit/pr_summary.test.js b/test/unit/pr_summary.test.js index 46d5e3c6..0bdb4e4a 100644 --- a/test/unit/pr_summary.test.js +++ b/test/unit/pr_summary.test.js @@ -44,7 +44,7 @@ describe('PRSummary', () => { 'Their Github Account email ' + ' (@pr_author, first-time contributor)'], ['Branch', 'pr_author:awesome-changes -> nodejs:master'], - ['Labels', 'test, doc'], + ['Labels', 'needs-ci, test, doc'], ['Commits', '6'], ['Committers', '3'] ]