Skip to content

Commit

Permalink
added more verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
Bullrich authored Jul 26, 2023
1 parent afcbd28 commit a0d02a7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/review-bot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
rules:
- name: Opstooling
condition:
include:
include:
- '.*'
exclude:
- 'example'
Expand Down
1 change: 1 addition & 0 deletions src/github/pullRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export class PullRequestApi {
const approvals = reviews.filter((review) => review.state === "approved");
this.usersThatApprovedThePr = approvals.map((approval) => approval.user.login);
}
this.logger.debug(`PR approvals are ${JSON.stringify(this.usersThatApprovedThePr)}`);
return this.usersThatApprovedThePr;
}
}
5 changes: 5 additions & 0 deletions src/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ export class ActionRunner {
* @see-also ReviewError
*/
async evaluateCondition(rule: { min_approvals: number } & Reviewers): Promise<ReviewState> {
this.logger.debug(JSON.stringify(rule));

// This is a list of all the users that need to approve a PR
const requiredUsers: string[] = [];
// If team is set, we fetch the members of such team
Expand Down Expand Up @@ -124,6 +126,7 @@ export class ActionRunner {

// We get the list of users that approved the PR
const approvals = await this.prApi.listApprovedReviewsAuthors();
this.logger.info(`Found ${approvals.length} approvals`);

// This is the amount of reviews required. To succeed this should be 0 or lower
let missingReviews = rule.min_approvals;
Expand All @@ -136,6 +139,7 @@ export class ActionRunner {

// Now we verify if we have any remaining missing review.
if (missingReviews > 0) {
this.logger.warn(`${missingReviews} reviews are missing.`);
// If we have at least one missing review, we return an object with the list of missing reviewers, and
// which users/teams we should request to review
return [
Expand All @@ -148,6 +152,7 @@ export class ActionRunner {
},
];
} else {
this.logger.info("Rule requirements fulfilled");
// If we don't have any missing reviews, we return the succesful case
return [true];
}
Expand Down

0 comments on commit a0d02a7

Please sign in to comment.