Skip to content

Commit 711a8c9

Browse files
authored
chore(prlint): additional log outputs for debugging (#30125)
Recently got asked to debug why some community reviews were not properly getting tagged and these log statements would have helped. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent d19d97c commit 711a8c9

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

tools/@aws-cdk/prlint/lint.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export class PullRequestLinter {
221221
*/
222222
private async deletePRLinterComment(): Promise<void> {
223223
// Since previous versions of this pr linter didn't add comments, we need to do this check first.
224-
const comment = await this.findExistingComment();
224+
const comment = await this.findExistingPRLinterComment();
225225
if (comment) {
226226
await this.client.issues.deleteComment({
227227
...this.issueParams,
@@ -302,7 +302,7 @@ export class PullRequestLinter {
302302
* Finds existing review, if present
303303
* @returns Existing review, if present
304304
*/
305-
private async findExistingReview(): Promise<Review | undefined> {
305+
private async findExistingPRLinterReview(): Promise<Review | undefined> {
306306
const reviews = await this.client.pulls.listReviews(this.prParams);
307307
return reviews.data.find((review) => review.user?.login === 'aws-cdk-automation' && review.state !== 'DISMISSED') as Review;
308308
}
@@ -311,7 +311,7 @@ export class PullRequestLinter {
311311
* Finds existing comment from previous review, if present
312312
* @returns Existing comment, if present
313313
*/
314-
private async findExistingComment(): Promise<Comment | undefined> {
314+
private async findExistingPRLinterComment(): Promise<Comment | undefined> {
315315
const comments = await this.client.issues.listComments(this.issueParams);
316316
return comments.data.find((comment) => comment.user?.login === 'aws-cdk-automation' && comment.body?.startsWith('The pull request linter fails with the following errors:')) as Comment;
317317
}
@@ -321,7 +321,7 @@ export class PullRequestLinter {
321321
* @param result The result of the PR Linter run.
322322
*/
323323
private async communicateResult(result: ValidationCollector): Promise<void> {
324-
const existingReview = await this.findExistingReview();
324+
const existingReview = await this.findExistingPRLinterReview();
325325
if (result.isValid()) {
326326
console.log('✅ Success');
327327
await this.dismissPRLinterReview(existingReview);
@@ -341,6 +341,8 @@ export class PullRequestLinter {
341341
repo: this.prParams.repo,
342342
ref: sha,
343343
});
344+
let status = statuses.data.filter(status => status.context === CODE_BUILD_CONTEXT).map(status => status.state);
345+
console.log("CodeBuild Commit Statuses: ", status);
344346
return statuses.data.some(status => status.context === CODE_BUILD_CONTEXT && status.state === 'success');
345347
}
346348

@@ -419,6 +421,7 @@ export class PullRequestLinter {
419421
[review.user!.login]: newest,
420422
};
421423
}, {} as Record<string, typeof reviews.data[0]>);
424+
console.log('raw data: ', JSON.stringify(reviewsByTrustedCommunityMembers));
422425
const communityApproved = Object.values(reviewsByTrustedCommunityMembers).some(({state}) => state === 'APPROVED');
423426
const communityRequestedChanges = !communityApproved && Object.values(reviewsByTrustedCommunityMembers).some(({state}) => state === 'CHANGES_REQUESTED')
424427

@@ -572,6 +575,7 @@ export class PullRequestLinter {
572575
],
573576
});
574577

578+
console.log("Deleting PR Linter Comment now");
575579
await this.deletePRLinterComment();
576580
try {
577581
await this.communicateResult(validationCollector);
@@ -580,7 +584,9 @@ export class PullRequestLinter {
580584
// also assess whether the PR needs review or not
581585
try {
582586
const state = await this.codeBuildJobSucceeded(sha);
587+
console.log(`PR code build job ${state ? "SUCCESSFUL" : "not yet successful"}`);
583588
if (state) {
589+
console.log('Assessing if the PR needs a review now');
584590
await this.assessNeedsReview(pr);
585591
}
586592
} catch (e) {

0 commit comments

Comments
 (0)