From 50eba13167cc25af6d7276b1e62244b1958f3076 Mon Sep 17 00:00:00 2001 From: xjusko Date: Thu, 23 Jan 2025 16:39:53 +0100 Subject: [PATCH] Add additional logging for debugging purpose of request reviewer intermittent issue. --- .../org/wildfly/bot/util/GithubProcessor.java | 53 +++++++++++++++---- .../bot/webhooks/PRReviewAssignmentTest.java | 4 +- 2 files changed, 46 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/wildfly/bot/util/GithubProcessor.java b/src/main/java/org/wildfly/bot/util/GithubProcessor.java index 3c203a7..6b3b46e 100644 --- a/src/main/java/org/wildfly/bot/util/GithubProcessor.java +++ b/src/main/java/org/wildfly/bot/util/GithubProcessor.java @@ -104,8 +104,12 @@ public void processNotifies(GHPullRequest pullRequest, GitHub gitHub, Set finalRequestedReviewers = pullRequest.getRequestedReviewers() + .stream() + .map(GHPerson::getLogin) + .toList(); + + LOG.infof("Final reviewers added to the PR: %s", finalRequestedReviewers); + + // Remove successfully added reviewers from the failed list + failedReviewers.removeAll(finalRequestedReviewers); + + // Log the actual failed reviewers that were not added + if (!failedReviewers.isEmpty()) { + LOG.warnf("Bot failed to request PR review from the following people: %s", failedReviewers); + + sendEmail( + COLLABORATOR_MISSING_SUBJECT.formatted(repository.getFullName()), + COLLABORATOR_MISSING_BODY.formatted(repository.getFullName(), pullRequest.getNumber(), + failedReviewers), + emails); + } else { + LOG.info("All initially failed reviewers were successfully added to the PR after verification."); + } } } } diff --git a/src/test/java/org/wildfly/bot/webhooks/PRReviewAssignmentTest.java b/src/test/java/org/wildfly/bot/webhooks/PRReviewAssignmentTest.java index 49d80d6..8219660 100644 --- a/src/test/java/org/wildfly/bot/webhooks/PRReviewAssignmentTest.java +++ b/src/test/java/org/wildfly/bot/webhooks/PRReviewAssignmentTest.java @@ -88,7 +88,7 @@ public void testOnlyMissingCollaboratorsNoReviewAssignment() throws Throwable { .comment(ArgumentMatchers.anyString()); Assertions.assertTrue(inMemoryLogHandler.getRecords().stream().anyMatch( logRecord -> logRecord.getMessage().contains( - "Bot can not request PR review from the following people: [Butterfly, Tadpole]"))); + "Bot failed to request PR review from the following people: [Butterfly, Tadpole]"))); List sent = mailbox.getMailsSentTo("foo@bar.baz"); Assertions.assertEquals(sent.size(), 1); @@ -143,7 +143,7 @@ public void testCommentAndReviewAssignmentCombination() throws Throwable { .toList(), Matchers.containsInAnyOrder("Tadpole")); Assertions.assertTrue(inMemoryLogHandler.getRecords().stream().anyMatch( logRecord -> logRecord.getMessage().contains( - "Bot can not request PR review from the following people: [Butterfly]"))); + "Bot failed to request PR review from the following people: [Butterfly]"))); List sent = mailbox.getMailsSentTo("foo@bar.baz"); Assertions.assertEquals(sent.size(), 1);