Skip to content

chore(prlint): additional log outputs for debugging #30125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions tools/@aws-cdk/prlint/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export class PullRequestLinter {
*/
private async deletePRLinterComment(): Promise<void> {
// Since previous versions of this pr linter didn't add comments, we need to do this check first.
const comment = await this.findExistingComment();
const comment = await this.findExistingPRLinterComment();
if (comment) {
await this.client.issues.deleteComment({
...this.issueParams,
Expand Down Expand Up @@ -302,7 +302,7 @@ export class PullRequestLinter {
* Finds existing review, if present
* @returns Existing review, if present
*/
private async findExistingReview(): Promise<Review | undefined> {
private async findExistingPRLinterReview(): Promise<Review | undefined> {
const reviews = await this.client.pulls.listReviews(this.prParams);
return reviews.data.find((review) => review.user?.login === 'aws-cdk-automation' && review.state !== 'DISMISSED') as Review;
}
Expand All @@ -311,7 +311,7 @@ export class PullRequestLinter {
* Finds existing comment from previous review, if present
* @returns Existing comment, if present
*/
private async findExistingComment(): Promise<Comment | undefined> {
private async findExistingPRLinterComment(): Promise<Comment | undefined> {
const comments = await this.client.issues.listComments(this.issueParams);
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;
}
Expand All @@ -321,7 +321,7 @@ export class PullRequestLinter {
* @param result The result of the PR Linter run.
*/
private async communicateResult(result: ValidationCollector): Promise<void> {
const existingReview = await this.findExistingReview();
const existingReview = await this.findExistingPRLinterReview();
if (result.isValid()) {
console.log('✅ Success');
await this.dismissPRLinterReview(existingReview);
Expand All @@ -341,6 +341,8 @@ export class PullRequestLinter {
repo: this.prParams.repo,
ref: sha,
});
let status = statuses.data.filter(status => status.context === CODE_BUILD_CONTEXT).map(status => status.state);
console.log("CodeBuild Commit Statuses: ", status);
return statuses.data.some(status => status.context === CODE_BUILD_CONTEXT && status.state === 'success');
}

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

Expand Down Expand Up @@ -572,6 +575,7 @@ export class PullRequestLinter {
],
});

console.log("Deleting PR Linter Comment now");
await this.deletePRLinterComment();
try {
await this.communicateResult(validationCollector);
Expand All @@ -580,7 +584,9 @@ export class PullRequestLinter {
// also assess whether the PR needs review or not
try {
const state = await this.codeBuildJobSucceeded(sha);
console.log(`PR code build job ${state ? "SUCCESSFUL" : "not yet successful"}`);
if (state) {
console.log('Assessing if the PR needs a review now');
await this.assessNeedsReview(pr);
}
} catch (e) {
Expand Down