diff --git a/.github/workflows/pr-linter-exemption-labeler.yml b/.github/workflows/pr-linter-exemption-labeler.yml new file mode 100644 index 0000000000000..332a216a6811e --- /dev/null +++ b/.github/workflows/pr-linter-exemption-labeler.yml @@ -0,0 +1,17 @@ +name: pr-linter-exemption-labeler +on: + issue_comment: + types: + - created + - edited + - deleted + +jobs: + pr_commented: + name: PR Comment + if: ${{ (github.event.issue.pull_request) && (github.event.issue.state == 'open') }} + runs-on: ubuntu-latest + steps: + - uses: TheRealAmazonKendra/pr-linter-exemption-labeler@main + with: + github-token: ${{ secrets.PROJEN_GITHUB_TOKEN }} \ No newline at end of file diff --git a/tools/@aws-cdk/prlint/lint.ts b/tools/@aws-cdk/prlint/lint.ts index be1246d04f23b..c0e82f4df0af1 100644 --- a/tools/@aws-cdk/prlint/lint.ts +++ b/tools/@aws-cdk/prlint/lint.ts @@ -217,12 +217,17 @@ export class PullRequestLinter { * @param existingReview The review created by a previous run of the linter. */ private async createOrUpdatePRLinterReview(failureMessages: string[], existingReview?: Review): Promise { - const body = `The pull request linter fails with the following errors:${this.formatErrors(failureMessages)}PRs must pass status checks before we can provide a meaningful review.`; + const body = `The pull request linter fails with the following errors:${this.formatErrors(failureMessages)}` + + 'PRs must pass status checks before we can provide a meaningful review.\n\n' + + 'If you would like to request an exemption from the status checks or clarification on feedback,' + + ' please leave a comment on this PR containing `Exemption Request` and/or `Clarification Request`.'; if (!existingReview) { await this.client.pulls.createReview({ ...this.prParams, - body: 'The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons.' + - ' If you believe this pull request should receive an exemption, please comment and provide a justification.', + body: 'The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons.' + + ' If you believe this pull request should receive an exemption, please comment and provide a justification.' + + '\n\n\nA comment requesting an exemption should contain the text `Exemption Request`.' + + ' Additionally, if clarification is needed add `Clarification Request` to a comment.', event: 'REQUEST_CHANGES', }) } diff --git a/tools/@aws-cdk/prlint/test/lint.test.ts b/tools/@aws-cdk/prlint/test/lint.test.ts index f3d45031f96c1..8afc6e33452fa 100644 --- a/tools/@aws-cdk/prlint/test/lint.test.ts +++ b/tools/@aws-cdk/prlint/test/lint.test.ts @@ -272,7 +272,9 @@ describe('integration tests required on features', () => { await expect(prLinter.validate()).rejects.toThrow( 'The pull request linter fails with the following errors:' + '\n\n\t❌ Features must contain a change to an integration test file and the resulting snapshot.' + - '\n\nPRs must pass status checks before we can provide a meaningful review.' + '\n\nPRs must pass status checks before we can provide a meaningful review.\n\n' + + 'If you would like to request an exemption from the status checks or clarification on feedback,' + + ' please leave a comment on this PR containing `Exemption Request` and/or `Clarification Request`.' ); }); @@ -305,7 +307,9 @@ describe('integration tests required on features', () => { await expect(prLinter.validate()).rejects.toThrow( 'The pull request linter fails with the following errors:' + '\n\n\t❌ Features must contain a change to an integration test file and the resulting snapshot.' + - '\n\nPRs must pass status checks before we can provide a meaningful review.' + '\n\nPRs must pass status checks before we can provide a meaningful review.\n\n' + + 'If you would like to request an exemption from the status checks or clarification on feedback,' + + ' please leave a comment on this PR containing `Exemption Request` and/or `Clarification Request`.' ); }); @@ -338,7 +342,9 @@ describe('integration tests required on features', () => { await expect(prLinter.validate()).rejects.toThrow( 'The pull request linter fails with the following errors:' + '\n\n\t❌ Fixes must contain a change to an integration test file and the resulting snapshot.' + - '\n\nPRs must pass status checks before we can provide a meaningful review.' + '\n\nPRs must pass status checks before we can provide a meaningful review.\n\n' + + 'If you would like to request an exemption from the status checks or clarification on feedback,' + + ' please leave a comment on this PR containing `Exemption Request` and/or `Clarification Request`.' ); }); @@ -371,7 +377,9 @@ describe('integration tests required on features', () => { await expect(prLinter.validate()).rejects.toThrow( 'The pull request linter fails with the following errors:' + '\n\n\t❌ Fixes must contain a change to an integration test file and the resulting snapshot.' + - '\n\nPRs must pass status checks before we can provide a meaningful review.' + '\n\nPRs must pass status checks before we can provide a meaningful review.\n\n' + + 'If you would like to request an exemption from the status checks or clarification on feedback,' + + ' please leave a comment on this PR containing `Exemption Request` and/or `Clarification Request`.' ); });