Skip to content

Commit

Permalink
Issue-361: Add prudent information about a publishing of checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
macetwatargo committed Oct 4, 2023
1 parent 8d17133 commit 3838fa3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,12 @@ public void publish(final ChecksDetails details) {

context.addActionIfMissing(run.getId(), gitHubDetails.getName());

buildLogger.log("GitHub check (name: %s, status: %s) has been published.", gitHubDetails.getName(),
gitHubDetails.getStatus());
SYSTEM_LOGGER.fine(format("Published check for repo: %s, sha: %s, job name: %s, name: %s, status: %s",
buildLogger.log("GitHub check (name: %s, status: %s, url: %s) has been published.",
gitHubDetails.getName(),
gitHubDetails.getStatus(),
gitHub.getApiUrl());
SYSTEM_LOGGER.fine(format("Published check for url: %s, repo: %s, sha: %s, job name: %s, name: %s, status: %s",
gitHub.getApiUrl(),
context.getRepository(),
context.getHeadSha(),
context.getJob().getFullName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ public static Collection<Object[]> contextBuilders() {
*/
@Test
public void shouldPublishGitHubCheckRunCorrectly() {
loggerRule.record(GitHubChecksPublisher.class.getName(), Level.WARNING).capture(1);

ChecksDetails details = new ChecksDetailsBuilder()
.withName("Jenkins")
.withStatus(ChecksStatus.COMPLETED)
Expand Down Expand Up @@ -206,6 +208,12 @@ public void shouldPublishGitHubCheckRunCorrectly() {
new PluginLogger(j.createTaskListener().getLogger(), "GitHub Checks"),
wireMockRule.baseUrl())
.publish(details);

assertThat(loggerRule.getRecords().size()).isEqualTo(1);
assertThat(loggerRule.getMessages().get(0))
.contains("Failed Publishing GitHub checks: ")
.contains("name='Jenkins'")
.contains("status=COMPLETED");
}

/**
Expand Down

0 comments on commit 3838fa3

Please sign in to comment.