diff --git a/.mergify.yml b/.mergify.yml index 47f6c06f10d90..8e10c3d045820 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -12,6 +12,7 @@ queue_rules: - -closed - "#approved-reviews-by>=1" - -approved-reviews-by~=author + # This is important! It makes the PR Linter work. - "#changes-requested-reviews-by=0" - status-success~=AWS CodeBuild us-east-1 - status-success=validate-pr @@ -30,6 +31,7 @@ queue_rules: - -closed - "#approved-reviews-by>=1" - -approved-reviews-by~=author + # This is important! It makes the PR Linter work. - "#changes-requested-reviews-by=0" - status-success~=AWS CodeBuild us-east-1 - status-success=validate-pr @@ -61,6 +63,7 @@ pull_request_rules: - author!=dependabot-preview[bot] - "#approved-reviews-by>=1" - -approved-reviews-by~=author + # This is important! It makes the PR Linter work. - "#changes-requested-reviews-by=0" - status-success~=AWS CodeBuild us-east-1 - status-success=validate-pr @@ -81,6 +84,7 @@ pull_request_rules: - author!=dependabot-preview[bot] - "#approved-reviews-by>=2" - -approved-reviews-by~=author + # This is important! It makes the PR Linter work. - "#changes-requested-reviews-by=0" - status-success~=AWS CodeBuild us-east-1 - status-success=validate-pr @@ -101,6 +105,7 @@ pull_request_rules: - author!=dependabot-preview[bot] - "#approved-reviews-by>=1" - -approved-reviews-by~=author + # This is important! It makes the PR Linter work. - "#changes-requested-reviews-by=0" - status-success~=AWS CodeBuild us-east-1 - status-success=validate-pr @@ -140,6 +145,7 @@ pull_request_rules: - -closed - author~=dependabot - "#approved-reviews-by>=1" + # This is important! It makes the PR Linter work. - "#changes-requested-reviews-by=0" - status-success~=AWS CodeBuild us-east-1 - status-success=validate-pr diff --git a/tools/@aws-cdk/prlint/index.ts b/tools/@aws-cdk/prlint/index.ts index d430fd745f34f..5f231c0dae755 100644 --- a/tools/@aws-cdk/prlint/index.ts +++ b/tools/@aws-cdk/prlint/index.ts @@ -1,4 +1,3 @@ -import * as core from '@actions/core'; import * as github from '@actions/github'; import { Octokit } from '@octokit/rest'; import { StatusEvent, PullRequestEvent } from '@octokit/webhooks-definitions/schema'; @@ -33,50 +32,42 @@ async function run() { throw new Error(`Could not find PR number from event: ${github.context.eventName}`); } - try { - const prLinter = new PullRequestLinter({ - client, - owner, - repo, - number, - // On purpose || instead of ??, also collapse empty string - linterLogin: process.env.LINTER_LOGIN || DEFEAULT_LINTER_LOGIN, - }); - - let actions: LinterActions | undefined; - - switch (github.context.eventName) { - case 'status': - // Triggering on a 'status' event is solely used to see if the CodeBuild - // job just turned green, and adding certain 'ready for review' labels - // if it does. - const statusPayload = github.context.payload as StatusEvent; - console.log('validating status event'); - actions = await prLinter.validateStatusEvent(statusPayload); - break; - - default: - // This is the main PR validator action. - actions = await prLinter.validatePullRequestTarget(); - break; - } - - if (actions) { - console.log(actions); + const prLinter = new PullRequestLinter({ + client, + owner, + repo, + number, + // On purpose || instead of ??, also collapse empty string + linterLogin: process.env.LINTER_LOGIN || DEFEAULT_LINTER_LOGIN, + }); + + let actions: LinterActions | undefined; + + switch (github.context.eventName) { + case 'status': + // Triggering on a 'status' event is solely used to see if the CodeBuild + // job just turned green, and adding certain 'ready for review' labels + // if it does. + const statusPayload = github.context.payload as StatusEvent; + console.log('validating status event'); + actions = await prLinter.validateStatusEvent(statusPayload); + break; + + default: + // This is the main PR validator action. + actions = await prLinter.validatePullRequestTarget(); + break; + } - if (github.context.eventName || process.env.FOR_REAL) { - console.log('Carrying out actions'); + if (actions) { + console.log(actions); - // Actually running in GitHub actions, do it (otherwise we're just testing) - await prLinter.executeActions(actions); - } + if (github.context.eventName || process.env.FOR_REAL) { + console.log('Carrying out actions'); - await prLinter.actionsToException(actions); + // Actually running in GitHub actions, do it (otherwise we're just testing) + await prLinter.executeActions(actions); } - - } catch (error: any) { - // Fail the action - core.setFailed(error.message); } }