@@ -1039,6 +1039,71 @@ describe('integration tests required on features', () => {
1039
1039
} ) ;
1040
1040
} ) ;
1041
1041
1042
+ describe ( 'with existing Exemption Request comment' , ( ) => {
1043
+ test ( 'valid exemption request comment' , async ( ) => {
1044
+ const issue : Subset < linter . GitHubPr > = {
1045
+ number : 1 ,
1046
+ title : 'fix: some title' ,
1047
+ body : '' ,
1048
+ labels : [ { name : 'pr-linter/exempt-test' } ] ,
1049
+ user : {
1050
+ login : 'author' ,
1051
+ } ,
1052
+ } ;
1053
+ const prLinter = configureMock ( issue , undefined , [ 'Exemption Request' ] ) ;
1054
+ await expect ( prLinter . validatePullRequestTarget ( SHA ) ) . rejects . toThrow (
1055
+ 'The pull request linter fails with the following errors:' +
1056
+ '\n\n\t❌ Fixes must contain a change to an integration test file and the resulting snapshot.' +
1057
+ '\n\n<b>PRs must pass status checks before we can provide a meaningful review.</b>\n\n' +
1058
+ 'If you would like to request an exemption from the status checks or clarification on feedback,' +
1059
+ ' please leave a comment on this PR containing `Exemption Request` and/or `Clarification Request`.' +
1060
+ '\n\n✅ A exemption request has been requested. Please wait for a maintainer\'s review.' ,
1061
+ ) ;
1062
+ } ) ;
1063
+
1064
+ test ( 'valid exemption request with additional context' , async ( ) => {
1065
+ const issue : Subset < linter . GitHubPr > = {
1066
+ number : 1 ,
1067
+ title : 'fix: some title' ,
1068
+ body : '' ,
1069
+ labels : [ { name : 'pr-linter/exempt-test' } ] ,
1070
+ user : {
1071
+ login : 'author' ,
1072
+ } ,
1073
+ } ;
1074
+ const prLinter = configureMock ( issue , undefined , [ 'Exemption Request: \nThe reason is blah blah blah.' ] ) ;
1075
+ await expect ( prLinter . validatePullRequestTarget ( SHA ) ) . rejects . toThrow (
1076
+ 'The pull request linter fails with the following errors:' +
1077
+ '\n\n\t❌ Fixes must contain a change to an integration test file and the resulting snapshot.' +
1078
+ '\n\n<b>PRs must pass status checks before we can provide a meaningful review.</b>\n\n' +
1079
+ 'If you would like to request an exemption from the status checks or clarification on feedback,' +
1080
+ ' please leave a comment on this PR containing `Exemption Request` and/or `Clarification Request`.' +
1081
+ '\n\n✅ A exemption request has been requested. Please wait for a maintainer\'s review.' ,
1082
+ ) ;
1083
+ } ) ;
1084
+
1085
+ test ( 'valid exemption request with middle exemption request' , async ( ) => {
1086
+ const issue : Subset < linter . GitHubPr > = {
1087
+ number : 1 ,
1088
+ title : 'fix: some title' ,
1089
+ body : '' ,
1090
+ labels : [ { name : 'pr-linter/exempt-test' } ] ,
1091
+ user : {
1092
+ login : 'author' ,
1093
+ } ,
1094
+ } ;
1095
+ const prLinter = configureMock ( issue , undefined , [ 'Random content - Exemption Request - hello world' ] ) ;
1096
+ await expect ( prLinter . validatePullRequestTarget ( SHA ) ) . rejects . toThrow (
1097
+ 'The pull request linter fails with the following errors:' +
1098
+ '\n\n\t❌ Fixes must contain a change to an integration test file and the resulting snapshot.' +
1099
+ '\n\n<b>PRs must pass status checks before we can provide a meaningful review.</b>\n\n' +
1100
+ 'If you would like to request an exemption from the status checks or clarification on feedback,' +
1101
+ ' please leave a comment on this PR containing `Exemption Request` and/or `Clarification Request`.' +
1102
+ '\n\n✅ A exemption request has been requested. Please wait for a maintainer\'s review.' ,
1103
+ ) ;
1104
+ } ) ;
1105
+ } ) ;
1106
+
1042
1107
describe ( 'metadata file changed' , ( ) => {
1043
1108
const files : linter . GitHubFile [ ] = [ {
1044
1109
filename : 'packages/aws-cdk-lib/region-info/build-tools/metadata.ts' ,
@@ -1074,7 +1139,7 @@ describe('integration tests required on features', () => {
1074
1139
} ) ;
1075
1140
} ) ;
1076
1141
1077
- function configureMock ( pr : Subset < linter . GitHubPr > , prFiles ?: linter . GitHubFile [ ] ) : linter . PullRequestLinter {
1142
+ function configureMock ( pr : Subset < linter . GitHubPr > , prFiles ?: linter . GitHubFile [ ] , existingComments ?: string [ ] ) : linter . PullRequestLinter {
1078
1143
const pullsClient = {
1079
1144
get ( _props : { _owner : string , _repo : string , _pull_number : number , _user : { _login : string } } ) {
1080
1145
return { data : pr } ;
@@ -1103,7 +1168,11 @@ function configureMock(pr: Subset<linter.GitHubPr>, prFiles?: linter.GitHubFile[
1103
1168
deleteComment ( ) { } ,
1104
1169
1105
1170
listComments ( ) {
1106
- return { data : [ { id : 1212121212 , user : { login : 'aws-cdk-automation' } , body : 'The pull request linter fails with the following errors:' } ] } ;
1171
+ const data = [ { id : 1212121212 , user : { login : 'aws-cdk-automation' } , body : 'The pull request linter fails with the following errors:' } ] ;
1172
+ if ( existingComments ) {
1173
+ existingComments . forEach ( comment => data . push ( { id : 1212121211 , user : { login : 'aws-cdk-automation' } , body : comment } ) ) ;
1174
+ }
1175
+ return { data } ;
1107
1176
} ,
1108
1177
1109
1178
removeLabel : mockRemoveLabel ,
0 commit comments