From 0921eafb18b6c473476bb32d94a1725ba5ed3d60 Mon Sep 17 00:00:00 2001 From: Benoit Lacelle Date: Mon, 26 Jul 2021 10:03:51 +0200 Subject: [PATCH 1/2] Simplify code --- .../solven/cleanthat/github/event/GithubWebhookHandler.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/github/src/main/java/eu/solven/cleanthat/github/event/GithubWebhookHandler.java b/github/src/main/java/eu/solven/cleanthat/github/event/GithubWebhookHandler.java index d27434132..6d765c751 100644 --- a/github/src/main/java/eu/solven/cleanthat/github/event/GithubWebhookHandler.java +++ b/github/src/main/java/eu/solven/cleanthat/github/event/GithubWebhookHandler.java @@ -204,10 +204,8 @@ public GithubWebhookRelevancyResult filterWebhookEventRelevant(I3rdPartyWebhookE } pushBranch = true; String ref = optFullRefName.get(); - GitRepoBranchSha1 value = - new GitRepoBranchSha1(PepperMapHelper.getRequiredAs(input, "repository", "full_name"), - ref, - optSha.get()); + String repoName = PepperMapHelper.getRequiredAs(input, "repository", "full_name"); + GitRepoBranchSha1 value = new GitRepoBranchSha1(repoName, ref, optSha.get()); optHeadRef = Optional.of(value); try { From e5fd025076c3e903dafe16de17880bc102d1f7ab Mon Sep 17 00:00:00 2001 From: Benoit Lacelle Date: Mon, 26 Jul 2021 10:37:13 +0200 Subject: [PATCH 2/2] Fix Github instance to scan repo --- .../github/event/GithubWebhookHandler.java | 89 +++- .../event/GithubWebhookHandlerFactory.java | 2 +- .../github/event/IGithubWebhookHandler.java | 3 +- .../github/event/RunProcessWebhookEvent.java | 8 +- .../event/TestGithubWebhookHandler.java | 8 +- .../github/run/RunGithubMonitoring.java | 3 +- .../it/ITGithubWebhookHandlerFactory.java | 43 +- .../github/it/ITGithubPullRequestCleaner.java | 3 +- .../github/webhook/pr_open-open_event.json | 482 ++++++++++++++++++ .../github/webhook/pr_open-push_event-1.json | 186 +++++++ .../github/webhook/pr_open-push_event-2.json | 207 ++++++++ .../github/run/RunCleanGithubBranch.java | 6 +- .../github/run/RunCleanGithubPullRequest.java | 5 +- 13 files changed, 995 insertions(+), 50 deletions(-) create mode 100644 github/src/test/resources/github/webhook/pr_open-open_event.json create mode 100644 github/src/test/resources/github/webhook/pr_open-push_event-1.json create mode 100644 github/src/test/resources/github/webhook/pr_open-push_event-2.json diff --git a/github/src/main/java/eu/solven/cleanthat/github/event/GithubWebhookHandler.java b/github/src/main/java/eu/solven/cleanthat/github/event/GithubWebhookHandler.java index 6d765c751..ec8fd2fd0 100644 --- a/github/src/main/java/eu/solven/cleanthat/github/event/GithubWebhookHandler.java +++ b/github/src/main/java/eu/solven/cleanthat/github/event/GithubWebhookHandler.java @@ -8,6 +8,7 @@ import java.util.Optional; import java.util.concurrent.TimeUnit; +import org.kohsuke.github.GHApp; import org.kohsuke.github.GHAppCreateTokenBuilder; import org.kohsuke.github.GHAppInstallation; import org.kohsuke.github.GHCheckRun; @@ -15,7 +16,6 @@ import org.kohsuke.github.GHCheckRunBuilder; import org.kohsuke.github.GHCommitPointer; import org.kohsuke.github.GHFileNotFoundException; -import org.kohsuke.github.GHIssueState; import org.kohsuke.github.GHPermissionType; import org.kohsuke.github.GHPullRequest; import org.kohsuke.github.GHRateLimit; @@ -51,24 +51,24 @@ public class GithubWebhookHandler implements IGithubWebhookHandler { private static final Logger LOGGER = LoggerFactory.getLogger(GithubWebhookHandler.class); - final GitHub github; + final GHApp githubApp; final List objectMappers; - public GithubWebhookHandler(GitHub github, List objectMappers) { - this.github = github; + public GithubWebhookHandler(GHApp githubApp, List objectMappers) { + this.githubApp = githubApp; this.objectMappers = objectMappers; } @Override - public GitHub getGithubAsApp() { - return github; + public GHApp getGithubAsApp() { + return githubApp; } @Override public GithubAndToken makeInstallationGithub(long installationId) { try { - GHAppInstallation installationById = github.getApp().getInstallationById(installationId); + GHAppInstallation installationById = getGithubAsApp().getInstallationById(installationId); LOGGER.info("Permissions: {}", installationById.getPermissions()); LOGGER.info("RepositorySelection: {}", installationById.getRepositorySelection()); // https://github.com/hub4j/github-api/issues/570 @@ -141,7 +141,7 @@ public GithubWebhookRelevancyResult filterWebhookEventRelevant(I3rdPartyWebhookE if (optAction.isEmpty()) { throw new IllegalStateException("We miss an action for a webhook holding a pull_request"); } else if ("opened".equals(optAction.get()) || "reopened".equals(optAction.get())) { - String headRef = PepperMapHelper.getRequiredString(input, "head", "ref"); + String headRef = PepperMapHelper.getRequiredString(optPullRequest.get(), "head", "ref"); if (headRef.startsWith(GithubRefCleaner.PREFIX_REF_CLEANTHAT)) { // Do not process CleanThat own PR open events LOGGER.info("We discard as headRef is: {}", headRef); @@ -155,14 +155,16 @@ public GithubWebhookRelevancyResult filterWebhookEventRelevant(I3rdPartyWebhookE // Some dirty commits may have been pushed while the PR was closed prOpen = true; refHasOpenReviewRequest = true; - String baseRepoName = PepperMapHelper.getRequiredString(input, "base", "repo", "full_name"); - String baseRef = PepperMapHelper.getRequiredString(input, "base", "ref"); - String prId = PepperMapHelper.getRequiredString(optPullRequest.get(), "id"); + String baseRepoName = + PepperMapHelper.getRequiredString(optPullRequest.get(), "base", "repo", "full_name"); + String baseRef = PepperMapHelper.getRequiredString(optPullRequest.get(), "base", "ref"); + long prId = PepperMapHelper.getRequiredNumber(optPullRequest.get(), "id").longValue(); optOpenPr = Optional.of(new GitPrHeadRef(baseRepoName, prId)); - String headRepoName = PepperMapHelper.getRequiredString(input, "head", "repo", "full_name"); - String baseSha = PepperMapHelper.getRequiredString(input, "base", "sha"); + String headRepoName = + PepperMapHelper.getRequiredString(optPullRequest.get(), "head", "repo", "full_name"); + String baseSha = PepperMapHelper.getRequiredString(optPullRequest.get(), "base", "sha"); optBaseRef = Optional.of(new GitRepoBranchSha1(baseRepoName, baseRef, baseSha)); - String headSha = PepperMapHelper.getRequiredString(input, "head", "sha"); + String headSha = PepperMapHelper.getRequiredString(optPullRequest.get(), "head", "sha"); optHeadRef = Optional.of(new GitRepoBranchSha1(headRepoName, headRef, headSha)); } else { prOpen = false; @@ -207,18 +209,25 @@ public GithubWebhookRelevancyResult filterWebhookEventRelevant(I3rdPartyWebhookE String repoName = PepperMapHelper.getRequiredAs(input, "repository", "full_name"); GitRepoBranchSha1 value = new GitRepoBranchSha1(repoName, ref, optSha.get()); optHeadRef = Optional.of(value); - try { - Optional prMatchingHead = - new GithubFacade(github, value.getRepoName()).findFirstPrHeadMatchingRef(ref); - optBaseRef = prMatchingHead.map(pr -> { - GHCommitPointer base = pr.getBase(); - return new GitRepoBranchSha1(base.getRepository().getName(), base.getRef(), base.getSha()); - }); - refHasOpenReviewRequest = prMatchingHead.isPresent(); - } catch (IOException e) { - throw new UncheckedIOException(e); - } + // We need a Github installation instance to check for this, while current call has to be offline + // (i.e. just analyzing the event) + // try { + // Optional prMatchingHead = + // new GithubFacade(github, value.getRepoName()).findFirstPrHeadMatchingRef(ref); + // optBaseRef = prMatchingHead.map(pr -> { + // GHCommitPointer base = pr.getBase(); + // return new GitRepoBranchSha1(base.getRepository().getName(), base.getRef(), base.getSha()); + // }); + // refHasOpenReviewRequest = prMatchingHead.isPresent(); + // } catch (IOException e) { + // throw new UncheckedIOException(e); + // } + optBaseRef = Optional.empty(); + + // TODO We could set a 'maybe' instead of 'false' + refHasOpenReviewRequest = false; + } else { // TODO Unclear which case this can be (no pull_request and no action) LOGGER.warn("WTF We miss at least one of sha1 and refName"); @@ -283,13 +292,38 @@ public WebhookRelevancyResult filterWebhookEventTargetRelevantBranch(ICodeCleane } catch (IOException e) { throw new UncheckedIOException(e); } + + Optional optOpenPr = offlineResult.optOpenPr(); + if (offlineResult.isPushBranch() && !offlineResult.refHasOpenReviewRequest()) { + assert optOpenPr.isEmpty(); + + LOGGER.info("Search for a PR merging the commited branch"); + try { + String repoName = offlineResult.optPushedRef().get().getRepoName(); + Optional prMatchingHead = new GithubFacade(githubAsInst, repoName) + .findFirstPrHeadMatchingRef(offlineResult.optPushedRef().get().getRef()); + // Optional optBaseRef = prMatchingHead.map(pr -> { + // GHCommitPointer base = pr.getBase(); + // return new GitRepoBranchSha1(base.getRepository().getName(), base.getRef(), base.getSha()); + // }); + + if (prMatchingHead.isPresent()) { + optOpenPr = prMatchingHead.map(b -> new GitPrHeadRef(repoName, prMatchingHead.get().getId())); + } + + // refHasOpenReviewRequest = prMatchingHead.isPresent(); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + // String defaultBranch = GitHelper.getDefaultBranch(Optional.ofNullable(repo.getDefaultBranch())); // final boolean isMainBranchCommit; GitRepoBranchSha1 theRef; - if (offlineResult.optOpenPr().isPresent()) { + if (optOpenPr.isPresent()) { Optional optPr; try { - String rawPrId = String.valueOf(offlineResult.optOpenPr().get().getId()); + String rawPrId = String.valueOf(optOpenPr.get().getId()); int prIdAsInteger = Integer.parseInt(rawPrId); optPr = Optional.of(baseRepo.getPullRequest(prIdAsInteger)); } catch (IOException e) { @@ -350,6 +384,7 @@ public void doExecuteWebhookEvent(ICodeCleanerFactory cleanerFactory, IWebhookEv } WebhookRelevancyResult relevancyResult = filterWebhookEventTargetRelevantBranch(cleanerFactory, githubAndBranchAcceptedEvent); + if (relevancyResult.getOptBranchToClean().isEmpty()) { // TODO May happen if the PR is closed in the meantime throw new IllegalArgumentException("We should have rejected this earlier"); diff --git a/github/src/main/java/eu/solven/cleanthat/github/event/GithubWebhookHandlerFactory.java b/github/src/main/java/eu/solven/cleanthat/github/event/GithubWebhookHandlerFactory.java index 152eee1d1..8847fea8c 100644 --- a/github/src/main/java/eu/solven/cleanthat/github/event/GithubWebhookHandlerFactory.java +++ b/github/src/main/java/eu/solven/cleanthat/github/event/GithubWebhookHandlerFactory.java @@ -50,7 +50,7 @@ public IGithubWebhookHandler makeWithFreshJwt() throws IOException, JOSEExceptio // This leads to 401. Why? // .withRateLimitChecker(new NoWaitRateLimitChecker()) .build(); - return new GithubWebhookHandler(github, objectMappers); + return new GithubWebhookHandler(github.getApp(), objectMappers); } // https://connect2id.com/products/nimbus-jose-jwt/examples/jwt-with-rsa-signature diff --git a/github/src/main/java/eu/solven/cleanthat/github/event/IGithubWebhookHandler.java b/github/src/main/java/eu/solven/cleanthat/github/event/IGithubWebhookHandler.java index 3e57d0288..5c9b52cc6 100644 --- a/github/src/main/java/eu/solven/cleanthat/github/event/IGithubWebhookHandler.java +++ b/github/src/main/java/eu/solven/cleanthat/github/event/IGithubWebhookHandler.java @@ -1,5 +1,6 @@ package eu.solven.cleanthat.github.event; +import org.kohsuke.github.GHApp; import org.kohsuke.github.GitHub; import eu.solven.cleanthat.github.event.pojo.GithubWebhookRelevancyResult; @@ -18,7 +19,7 @@ public interface IGithubWebhookHandler { * * @return a {@link GitHub} instance authenticated as the Github Application. */ - GitHub getGithubAsApp(); + GHApp getGithubAsApp(); /** * diff --git a/github/src/test/java/eu/solven/cleanthat/github/event/RunProcessWebhookEvent.java b/github/src/test/java/eu/solven/cleanthat/github/event/RunProcessWebhookEvent.java index 1cbc91a45..f1597c0b6 100644 --- a/github/src/test/java/eu/solven/cleanthat/github/event/RunProcessWebhookEvent.java +++ b/github/src/test/java/eu/solven/cleanthat/github/event/RunProcessWebhookEvent.java @@ -29,7 +29,7 @@ public class RunProcessWebhookEvent { // Relevant to rely on GitHub.offline()? - final GitHub github = Mockito.mock(GitHub.class); + final GHApp ghApp = Mockito.mock(GHApp.class); final GitHub installGithub = Mockito.mock(GitHub.class); @@ -40,7 +40,7 @@ public class RunProcessWebhookEvent { final IGithubRefCleaner prCleaner = Mockito.mock(IGithubRefCleaner.class); final GithubWebhookHandler handler = - new GithubWebhookHandler(github, Arrays.asList(ConfigHelpers.makeJsonObjectMapper())) { + new GithubWebhookHandler(ghApp, Arrays.asList(ConfigHelpers.makeJsonObjectMapper())) { @Override protected GitHub makeInstallationGithub(String token) throws IOException { @@ -52,8 +52,8 @@ protected GitHub makeInstallationGithub(String token) throws IOException { @Before public void initMocks() throws IOException { - GHApp ghApp = Mockito.mock(GHApp.class); - Mockito.when(github.getApp()).thenReturn(ghApp); + // GHApp ghApp = Mockito.mock(GHApp.class); + // Mockito.when(github.getApp()).thenReturn(ghApp); GHAppInstallation appInstall = Mockito.mock(GHAppInstallation.class); Mockito.when(ghApp.getInstallationById(Mockito.anyLong())).thenReturn(appInstall); GHAppCreateTokenBuilder tokenBuilder = Mockito.mock(GHAppCreateTokenBuilder.class); diff --git a/github/src/test/java/eu/solven/cleanthat/github/event/TestGithubWebhookHandler.java b/github/src/test/java/eu/solven/cleanthat/github/event/TestGithubWebhookHandler.java index 798864894..a4d930088 100644 --- a/github/src/test/java/eu/solven/cleanthat/github/event/TestGithubWebhookHandler.java +++ b/github/src/test/java/eu/solven/cleanthat/github/event/TestGithubWebhookHandler.java @@ -29,7 +29,7 @@ public class TestGithubWebhookHandler { // Relevant to rely on GitHub.offline()? - final GitHub github = Mockito.mock(GitHub.class); + final GHApp ghApp = Mockito.mock(GHApp.class); final GitHub installGithub = Mockito.mock(GitHub.class); @@ -40,7 +40,7 @@ public class TestGithubWebhookHandler { final IGithubRefCleaner prCleaner = Mockito.mock(IGithubRefCleaner.class); final GithubWebhookHandler handler = - new GithubWebhookHandler(github, Arrays.asList(ConfigHelpers.makeJsonObjectMapper())) { + new GithubWebhookHandler(ghApp, Arrays.asList(ConfigHelpers.makeJsonObjectMapper())) { @Override protected GitHub makeInstallationGithub(String token) throws IOException { @@ -52,8 +52,8 @@ protected GitHub makeInstallationGithub(String token) throws IOException { @Before public void initMocks() throws IOException { - GHApp ghApp = Mockito.mock(GHApp.class); - Mockito.when(github.getApp()).thenReturn(ghApp); + // GHApp ghApp = Mockito.mock(GHApp.class); + // Mockito.when(github.getApp()).thenReturn(ghApp); GHAppInstallation appInstall = Mockito.mock(GHAppInstallation.class); Mockito.when(ghApp.getInstallationById(Mockito.anyLong())).thenReturn(appInstall); GHAppCreateTokenBuilder tokenBuilder = Mockito.mock(GHAppCreateTokenBuilder.class); diff --git a/github/src/test/java/eu/solven/cleanthat/github/run/RunGithubMonitoring.java b/github/src/test/java/eu/solven/cleanthat/github/run/RunGithubMonitoring.java index 634042fc1..981899802 100644 --- a/github/src/test/java/eu/solven/cleanthat/github/run/RunGithubMonitoring.java +++ b/github/src/test/java/eu/solven/cleanthat/github/run/RunGithubMonitoring.java @@ -59,8 +59,7 @@ public void doSomethingAfterStartup(ContextRefreshedEvent event) throws IOExcept GithubWebhookHandlerFactory factory = appContext.getBean(GithubWebhookHandlerFactory.class); IGithubWebhookHandler handler = factory.makeWithFreshJwt(); - GitHub github = handler.getGithubAsApp(); - GHApp app = github.getApp(); + GHApp app = handler.getGithubAsApp(); LOGGER.info("CleanThat has been installed {} times", app.getInstallationsCount()); app.listInstallations().forEach(installation -> { long appId = installation.getAppId(); diff --git a/github/src/test/java/eu/solven/cleanthat/it/ITGithubWebhookHandlerFactory.java b/github/src/test/java/eu/solven/cleanthat/it/ITGithubWebhookHandlerFactory.java index 957c6605d..be31b32e4 100644 --- a/github/src/test/java/eu/solven/cleanthat/it/ITGithubWebhookHandlerFactory.java +++ b/github/src/test/java/eu/solven/cleanthat/it/ITGithubWebhookHandlerFactory.java @@ -6,13 +6,14 @@ import java.security.PrivateKey; import java.security.spec.PKCS8EncodedKeySpec; import java.util.Arrays; +import java.util.Map; import org.assertj.core.api.Assertions; import org.junit.Test; import org.kohsuke.github.GHApp; -import org.kohsuke.github.GitHub; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.core.io.ClassPathResource; import org.springframework.mock.env.MockEnvironment; import com.google.common.io.Files; @@ -23,8 +24,11 @@ import eu.solven.cleanthat.config.ConfigHelpers; import eu.solven.cleanthat.git_abstraction.GithubFacade; import eu.solven.cleanthat.github.event.GithubAndToken; +import eu.solven.cleanthat.github.event.GithubWebhookHandler; import eu.solven.cleanthat.github.event.GithubWebhookHandlerFactory; import eu.solven.cleanthat.github.event.IGithubWebhookHandler; +import eu.solven.cleanthat.github.event.pojo.GithubWebhookEvent; +import eu.solven.cleanthat.github.event.pojo.GithubWebhookRelevancyResult; //https://github-api.kohsuke.org/githubappjwtauth.html public class ITGithubWebhookHandlerFactory { @@ -60,8 +64,7 @@ public void testMakeJwt() throws JOSEException, IOException { GithubWebhookHandlerFactory factory = new GithubWebhookHandlerFactory(env, Arrays.asList(ConfigHelpers.makeJsonObjectMapper())); IGithubWebhookHandler fresh = factory.makeWithFreshJwt(); - GitHub gitHubApp = fresh.getGithubAsApp(); - GHApp app = gitHubApp.getApp(); + GHApp app = fresh.getGithubAsApp(); app.listInstallations().forEach(install -> { LOGGER.info("appId={} url={}", install.getId(), install.getHtmlUrl()); }); @@ -75,5 +78,39 @@ public void testMakeJwt() throws JOSEException, IOException { // Private repo in same organisation Assertions.assertThat(new GithubFacade(gitHubInstallation.getGithub(), SOLVEN_EU_MITRUST_DATASHARING) .findFirstPrBaseMatchingRef("refs/heads/master")).isPresent(); + + { + Map body = ConfigHelpers.makeJsonObjectMapper() + .readValue(new ClassPathResource("/github/webhook/pr_open-open_event.json").getInputStream(), + Map.class); + GithubWebhookRelevancyResult result = + new GithubWebhookHandler(app, Arrays.asList(ConfigHelpers.makeJsonObjectMapper())) + .filterWebhookEventRelevant(new GithubWebhookEvent(body)); + + Assertions.assertThat(result.isPrOpen()).isTrue(); + Assertions.assertThat(result.isPushBranch()).isFalse(); + } + { + Map body = ConfigHelpers.makeJsonObjectMapper() + .readValue(new ClassPathResource("/github/webhook/pr_open-push_event-1.json").getInputStream(), + Map.class); + GithubWebhookRelevancyResult result = + new GithubWebhookHandler(app, Arrays.asList(ConfigHelpers.makeJsonObjectMapper())) + .filterWebhookEventRelevant(new GithubWebhookEvent(body)); + + Assertions.assertThat(result.isPrOpen()).isFalse(); + Assertions.assertThat(result.isPushBranch()).isTrue(); + } + { + Map body = ConfigHelpers.makeJsonObjectMapper() + .readValue(new ClassPathResource("/github/webhook/pr_open-push_event-1.json").getInputStream(), + Map.class); + GithubWebhookRelevancyResult result = + new GithubWebhookHandler(app, Arrays.asList(ConfigHelpers.makeJsonObjectMapper())) + .filterWebhookEventRelevant(new GithubWebhookEvent(body)); + + Assertions.assertThat(result.isPrOpen()).isFalse(); + Assertions.assertThat(result.isPushBranch()).isTrue(); + } } } diff --git a/github/src/test/java/github/it/ITGithubPullRequestCleaner.java b/github/src/test/java/github/it/ITGithubPullRequestCleaner.java index ea23194e8..9dd94236a 100644 --- a/github/src/test/java/github/it/ITGithubPullRequestCleaner.java +++ b/github/src/test/java/github/it/ITGithubPullRequestCleaner.java @@ -43,8 +43,7 @@ public class ITGithubPullRequestCleaner { public void testInitWithDefaultConfiguration() throws IOException, JOSEException { IGithubWebhookHandler handler = factory.makeWithFreshJwt(); - GitHub github = handler.getGithubAsApp(); - GHApp app = github.getApp(); + GHApp app = handler.getGithubAsApp(); String repoName = "cleanthat"; GHAppInstallation installation = app.getInstallationByRepository("solven-eu", repoName); diff --git a/github/src/test/resources/github/webhook/pr_open-open_event.json b/github/src/test/resources/github/webhook/pr_open-open_event.json new file mode 100644 index 000000000..712625d99 --- /dev/null +++ b/github/src/test/resources/github/webhook/pr_open-open_event.json @@ -0,0 +1,482 @@ +{ + "action": "opened", + "number": 163, + "pull_request": { + "url": "https://api.github.com/repos/solven-eu/cleanthat/pulls/163", + "id": 696788495, + "node_id": "MDExOlB1bGxSZXF1ZXN0Njk2Nzg4NDk1", + "html_url": "https://github.com/solven-eu/cleanthat/pull/163", + "diff_url": "https://github.com/solven-eu/cleanthat/pull/163.diff", + "patch_url": "https://github.com/solven-eu/cleanthat/pull/163.patch", + "issue_url": "https://api.github.com/repos/solven-eu/cleanthat/issues/163", + "number": 163, + "state": "open", + "locked": false, + "title": "Simplify code", + "user": { + "login": "blacelle", + "id": 2117911, + "node_id": "MDQ6VXNlcjIxMTc5MTE=", + "avatar_url": "https://avatars.githubusercontent.com/u/2117911?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/blacelle", + "html_url": "https://github.com/blacelle", + "followers_url": "https://api.github.com/users/blacelle/followers", + "following_url": "https://api.github.com/users/blacelle/following{/other_user}", + "gists_url": "https://api.github.com/users/blacelle/gists{/gist_id}", + "starred_url": "https://api.github.com/users/blacelle/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/blacelle/subscriptions", + "organizations_url": "https://api.github.com/users/blacelle/orgs", + "repos_url": "https://api.github.com/users/blacelle/repos", + "events_url": "https://api.github.com/users/blacelle/events{/privacy}", + "received_events_url": "https://api.github.com/users/blacelle/received_events", + "type": "User", + "site_admin": false + }, + "body": "", + "created_at": "2021-07-26T08:04:01Z", + "updated_at": "2021-07-26T08:04:01Z", + "closed_at": null, + "merged_at": null, + "merge_commit_sha": null, + "assignee": null, + "assignees": [ + + ], + "requested_reviewers": [ + + ], + "requested_teams": [ + + ], + "labels": [ + + ], + "milestone": null, + "draft": false, + "commits_url": "https://api.github.com/repos/solven-eu/cleanthat/pulls/163/commits", + "review_comments_url": "https://api.github.com/repos/solven-eu/cleanthat/pulls/163/comments", + "review_comment_url": "https://api.github.com/repos/solven-eu/cleanthat/pulls/comments{/number}", + "comments_url": "https://api.github.com/repos/solven-eu/cleanthat/issues/163/comments", + "statuses_url": "https://api.github.com/repos/solven-eu/cleanthat/statuses/0921eafb18b6c473476bb32d94a1725ba5ed3d60", + "head": { + "label": "solven-eu:cleanthat_tests/open_review_request", + "ref": "cleanthat_tests/open_review_request", + "sha": "0921eafb18b6c473476bb32d94a1725ba5ed3d60", + "user": { + "login": "solven-eu", + "id": 34552197, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjM0NTUyMTk3", + "avatar_url": "https://avatars.githubusercontent.com/u/34552197?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/solven-eu", + "html_url": "https://github.com/solven-eu", + "followers_url": "https://api.github.com/users/solven-eu/followers", + "following_url": "https://api.github.com/users/solven-eu/following{/other_user}", + "gists_url": "https://api.github.com/users/solven-eu/gists{/gist_id}", + "starred_url": "https://api.github.com/users/solven-eu/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/solven-eu/subscriptions", + "organizations_url": "https://api.github.com/users/solven-eu/orgs", + "repos_url": "https://api.github.com/users/solven-eu/repos", + "events_url": "https://api.github.com/users/solven-eu/events{/privacy}", + "received_events_url": "https://api.github.com/users/solven-eu/received_events", + "type": "Organization", + "site_admin": false + }, + "repo": { + "id": 264855617, + "node_id": "MDEwOlJlcG9zaXRvcnkyNjQ4NTU2MTc=", + "name": "cleanthat", + "full_name": "solven-eu/cleanthat", + "private": false, + "owner": { + "login": "solven-eu", + "id": 34552197, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjM0NTUyMTk3", + "avatar_url": "https://avatars.githubusercontent.com/u/34552197?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/solven-eu", + "html_url": "https://github.com/solven-eu", + "followers_url": "https://api.github.com/users/solven-eu/followers", + "following_url": "https://api.github.com/users/solven-eu/following{/other_user}", + "gists_url": "https://api.github.com/users/solven-eu/gists{/gist_id}", + "starred_url": "https://api.github.com/users/solven-eu/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/solven-eu/subscriptions", + "organizations_url": "https://api.github.com/users/solven-eu/orgs", + "repos_url": "https://api.github.com/users/solven-eu/repos", + "events_url": "https://api.github.com/users/solven-eu/events{/privacy}", + "received_events_url": "https://api.github.com/users/solven-eu/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/solven-eu/cleanthat", + "description": "Github App opening automatically cleaning PR", + "fork": false, + "url": "https://api.github.com/repos/solven-eu/cleanthat", + "forks_url": "https://api.github.com/repos/solven-eu/cleanthat/forks", + "keys_url": "https://api.github.com/repos/solven-eu/cleanthat/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/solven-eu/cleanthat/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/solven-eu/cleanthat/teams", + "hooks_url": "https://api.github.com/repos/solven-eu/cleanthat/hooks", + "issue_events_url": "https://api.github.com/repos/solven-eu/cleanthat/issues/events{/number}", + "events_url": "https://api.github.com/repos/solven-eu/cleanthat/events", + "assignees_url": "https://api.github.com/repos/solven-eu/cleanthat/assignees{/user}", + "branches_url": "https://api.github.com/repos/solven-eu/cleanthat/branches{/branch}", + "tags_url": "https://api.github.com/repos/solven-eu/cleanthat/tags", + "blobs_url": "https://api.github.com/repos/solven-eu/cleanthat/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/solven-eu/cleanthat/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/solven-eu/cleanthat/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/solven-eu/cleanthat/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/solven-eu/cleanthat/statuses/{sha}", + "languages_url": "https://api.github.com/repos/solven-eu/cleanthat/languages", + "stargazers_url": "https://api.github.com/repos/solven-eu/cleanthat/stargazers", + "contributors_url": "https://api.github.com/repos/solven-eu/cleanthat/contributors", + "subscribers_url": "https://api.github.com/repos/solven-eu/cleanthat/subscribers", + "subscription_url": "https://api.github.com/repos/solven-eu/cleanthat/subscription", + "commits_url": "https://api.github.com/repos/solven-eu/cleanthat/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/solven-eu/cleanthat/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/solven-eu/cleanthat/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/solven-eu/cleanthat/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/solven-eu/cleanthat/contents/{+path}", + "compare_url": "https://api.github.com/repos/solven-eu/cleanthat/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/solven-eu/cleanthat/merges", + "archive_url": "https://api.github.com/repos/solven-eu/cleanthat/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/solven-eu/cleanthat/downloads", + "issues_url": "https://api.github.com/repos/solven-eu/cleanthat/issues{/number}", + "pulls_url": "https://api.github.com/repos/solven-eu/cleanthat/pulls{/number}", + "milestones_url": "https://api.github.com/repos/solven-eu/cleanthat/milestones{/number}", + "notifications_url": "https://api.github.com/repos/solven-eu/cleanthat/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/solven-eu/cleanthat/labels{/name}", + "releases_url": "https://api.github.com/repos/solven-eu/cleanthat/releases{/id}", + "deployments_url": "https://api.github.com/repos/solven-eu/cleanthat/deployments", + "created_at": "2020-05-18T07:04:21Z", + "updated_at": "2021-07-26T08:01:55Z", + "pushed_at": "2021-07-26T08:04:01Z", + "git_url": "git://github.com/solven-eu/cleanthat.git", + "ssh_url": "git@github.com:solven-eu/cleanthat.git", + "clone_url": "https://github.com/solven-eu/cleanthat.git", + "svn_url": "https://github.com/solven-eu/cleanthat", + "homepage": null, + "size": 793, + "stargazers_count": 2, + "watchers_count": 2, + "language": "Java", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 20, + "license": null, + "forks": 0, + "open_issues": 20, + "watchers": 2, + "default_branch": "master", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "delete_branch_on_merge": false + } + }, + "base": { + "label": "solven-eu:master", + "ref": "master", + "sha": "957d4697599b1cea7b81f60dddbe3edfb236f2af", + "user": { + "login": "solven-eu", + "id": 34552197, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjM0NTUyMTk3", + "avatar_url": "https://avatars.githubusercontent.com/u/34552197?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/solven-eu", + "html_url": "https://github.com/solven-eu", + "followers_url": "https://api.github.com/users/solven-eu/followers", + "following_url": "https://api.github.com/users/solven-eu/following{/other_user}", + "gists_url": "https://api.github.com/users/solven-eu/gists{/gist_id}", + "starred_url": "https://api.github.com/users/solven-eu/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/solven-eu/subscriptions", + "organizations_url": "https://api.github.com/users/solven-eu/orgs", + "repos_url": "https://api.github.com/users/solven-eu/repos", + "events_url": "https://api.github.com/users/solven-eu/events{/privacy}", + "received_events_url": "https://api.github.com/users/solven-eu/received_events", + "type": "Organization", + "site_admin": false + }, + "repo": { + "id": 264855617, + "node_id": "MDEwOlJlcG9zaXRvcnkyNjQ4NTU2MTc=", + "name": "cleanthat", + "full_name": "solven-eu/cleanthat", + "private": false, + "owner": { + "login": "solven-eu", + "id": 34552197, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjM0NTUyMTk3", + "avatar_url": "https://avatars.githubusercontent.com/u/34552197?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/solven-eu", + "html_url": "https://github.com/solven-eu", + "followers_url": "https://api.github.com/users/solven-eu/followers", + "following_url": "https://api.github.com/users/solven-eu/following{/other_user}", + "gists_url": "https://api.github.com/users/solven-eu/gists{/gist_id}", + "starred_url": "https://api.github.com/users/solven-eu/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/solven-eu/subscriptions", + "organizations_url": "https://api.github.com/users/solven-eu/orgs", + "repos_url": "https://api.github.com/users/solven-eu/repos", + "events_url": "https://api.github.com/users/solven-eu/events{/privacy}", + "received_events_url": "https://api.github.com/users/solven-eu/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/solven-eu/cleanthat", + "description": "Github App opening automatically cleaning PR", + "fork": false, + "url": "https://api.github.com/repos/solven-eu/cleanthat", + "forks_url": "https://api.github.com/repos/solven-eu/cleanthat/forks", + "keys_url": "https://api.github.com/repos/solven-eu/cleanthat/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/solven-eu/cleanthat/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/solven-eu/cleanthat/teams", + "hooks_url": "https://api.github.com/repos/solven-eu/cleanthat/hooks", + "issue_events_url": "https://api.github.com/repos/solven-eu/cleanthat/issues/events{/number}", + "events_url": "https://api.github.com/repos/solven-eu/cleanthat/events", + "assignees_url": "https://api.github.com/repos/solven-eu/cleanthat/assignees{/user}", + "branches_url": "https://api.github.com/repos/solven-eu/cleanthat/branches{/branch}", + "tags_url": "https://api.github.com/repos/solven-eu/cleanthat/tags", + "blobs_url": "https://api.github.com/repos/solven-eu/cleanthat/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/solven-eu/cleanthat/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/solven-eu/cleanthat/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/solven-eu/cleanthat/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/solven-eu/cleanthat/statuses/{sha}", + "languages_url": "https://api.github.com/repos/solven-eu/cleanthat/languages", + "stargazers_url": "https://api.github.com/repos/solven-eu/cleanthat/stargazers", + "contributors_url": "https://api.github.com/repos/solven-eu/cleanthat/contributors", + "subscribers_url": "https://api.github.com/repos/solven-eu/cleanthat/subscribers", + "subscription_url": "https://api.github.com/repos/solven-eu/cleanthat/subscription", + "commits_url": "https://api.github.com/repos/solven-eu/cleanthat/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/solven-eu/cleanthat/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/solven-eu/cleanthat/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/solven-eu/cleanthat/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/solven-eu/cleanthat/contents/{+path}", + "compare_url": "https://api.github.com/repos/solven-eu/cleanthat/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/solven-eu/cleanthat/merges", + "archive_url": "https://api.github.com/repos/solven-eu/cleanthat/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/solven-eu/cleanthat/downloads", + "issues_url": "https://api.github.com/repos/solven-eu/cleanthat/issues{/number}", + "pulls_url": "https://api.github.com/repos/solven-eu/cleanthat/pulls{/number}", + "milestones_url": "https://api.github.com/repos/solven-eu/cleanthat/milestones{/number}", + "notifications_url": "https://api.github.com/repos/solven-eu/cleanthat/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/solven-eu/cleanthat/labels{/name}", + "releases_url": "https://api.github.com/repos/solven-eu/cleanthat/releases{/id}", + "deployments_url": "https://api.github.com/repos/solven-eu/cleanthat/deployments", + "created_at": "2020-05-18T07:04:21Z", + "updated_at": "2021-07-26T08:01:55Z", + "pushed_at": "2021-07-26T08:04:01Z", + "git_url": "git://github.com/solven-eu/cleanthat.git", + "ssh_url": "git@github.com:solven-eu/cleanthat.git", + "clone_url": "https://github.com/solven-eu/cleanthat.git", + "svn_url": "https://github.com/solven-eu/cleanthat", + "homepage": null, + "size": 793, + "stargazers_count": 2, + "watchers_count": 2, + "language": "Java", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 20, + "license": null, + "forks": 0, + "open_issues": 20, + "watchers": 2, + "default_branch": "master", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "delete_branch_on_merge": false + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/solven-eu/cleanthat/pulls/163" + }, + "html": { + "href": "https://github.com/solven-eu/cleanthat/pull/163" + }, + "issue": { + "href": "https://api.github.com/repos/solven-eu/cleanthat/issues/163" + }, + "comments": { + "href": "https://api.github.com/repos/solven-eu/cleanthat/issues/163/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/solven-eu/cleanthat/pulls/163/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/solven-eu/cleanthat/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/solven-eu/cleanthat/pulls/163/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/solven-eu/cleanthat/statuses/0921eafb18b6c473476bb32d94a1725ba5ed3d60" + } + }, + "author_association": "MEMBER", + "auto_merge": null, + "active_lock_reason": null, + "merged": false, + "mergeable": null, + "rebaseable": null, + "mergeable_state": "unknown", + "merged_by": null, + "comments": 0, + "review_comments": 0, + "maintainer_can_modify": false, + "commits": 1, + "additions": 2, + "deletions": 4, + "changed_files": 1 + }, + "repository": { + "id": 264855617, + "node_id": "MDEwOlJlcG9zaXRvcnkyNjQ4NTU2MTc=", + "name": "cleanthat", + "full_name": "solven-eu/cleanthat", + "private": false, + "owner": { + "login": "solven-eu", + "id": 34552197, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjM0NTUyMTk3", + "avatar_url": "https://avatars.githubusercontent.com/u/34552197?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/solven-eu", + "html_url": "https://github.com/solven-eu", + "followers_url": "https://api.github.com/users/solven-eu/followers", + "following_url": "https://api.github.com/users/solven-eu/following{/other_user}", + "gists_url": "https://api.github.com/users/solven-eu/gists{/gist_id}", + "starred_url": "https://api.github.com/users/solven-eu/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/solven-eu/subscriptions", + "organizations_url": "https://api.github.com/users/solven-eu/orgs", + "repos_url": "https://api.github.com/users/solven-eu/repos", + "events_url": "https://api.github.com/users/solven-eu/events{/privacy}", + "received_events_url": "https://api.github.com/users/solven-eu/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/solven-eu/cleanthat", + "description": "Github App opening automatically cleaning PR", + "fork": false, + "url": "https://api.github.com/repos/solven-eu/cleanthat", + "forks_url": "https://api.github.com/repos/solven-eu/cleanthat/forks", + "keys_url": "https://api.github.com/repos/solven-eu/cleanthat/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/solven-eu/cleanthat/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/solven-eu/cleanthat/teams", + "hooks_url": "https://api.github.com/repos/solven-eu/cleanthat/hooks", + "issue_events_url": "https://api.github.com/repos/solven-eu/cleanthat/issues/events{/number}", + "events_url": "https://api.github.com/repos/solven-eu/cleanthat/events", + "assignees_url": "https://api.github.com/repos/solven-eu/cleanthat/assignees{/user}", + "branches_url": "https://api.github.com/repos/solven-eu/cleanthat/branches{/branch}", + "tags_url": "https://api.github.com/repos/solven-eu/cleanthat/tags", + "blobs_url": "https://api.github.com/repos/solven-eu/cleanthat/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/solven-eu/cleanthat/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/solven-eu/cleanthat/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/solven-eu/cleanthat/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/solven-eu/cleanthat/statuses/{sha}", + "languages_url": "https://api.github.com/repos/solven-eu/cleanthat/languages", + "stargazers_url": "https://api.github.com/repos/solven-eu/cleanthat/stargazers", + "contributors_url": "https://api.github.com/repos/solven-eu/cleanthat/contributors", + "subscribers_url": "https://api.github.com/repos/solven-eu/cleanthat/subscribers", + "subscription_url": "https://api.github.com/repos/solven-eu/cleanthat/subscription", + "commits_url": "https://api.github.com/repos/solven-eu/cleanthat/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/solven-eu/cleanthat/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/solven-eu/cleanthat/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/solven-eu/cleanthat/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/solven-eu/cleanthat/contents/{+path}", + "compare_url": "https://api.github.com/repos/solven-eu/cleanthat/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/solven-eu/cleanthat/merges", + "archive_url": "https://api.github.com/repos/solven-eu/cleanthat/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/solven-eu/cleanthat/downloads", + "issues_url": "https://api.github.com/repos/solven-eu/cleanthat/issues{/number}", + "pulls_url": "https://api.github.com/repos/solven-eu/cleanthat/pulls{/number}", + "milestones_url": "https://api.github.com/repos/solven-eu/cleanthat/milestones{/number}", + "notifications_url": "https://api.github.com/repos/solven-eu/cleanthat/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/solven-eu/cleanthat/labels{/name}", + "releases_url": "https://api.github.com/repos/solven-eu/cleanthat/releases{/id}", + "deployments_url": "https://api.github.com/repos/solven-eu/cleanthat/deployments", + "created_at": "2020-05-18T07:04:21Z", + "updated_at": "2021-07-26T08:01:55Z", + "pushed_at": "2021-07-26T08:04:01Z", + "git_url": "git://github.com/solven-eu/cleanthat.git", + "ssh_url": "git@github.com:solven-eu/cleanthat.git", + "clone_url": "https://github.com/solven-eu/cleanthat.git", + "svn_url": "https://github.com/solven-eu/cleanthat", + "homepage": null, + "size": 793, + "stargazers_count": 2, + "watchers_count": 2, + "language": "Java", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 20, + "license": null, + "forks": 0, + "open_issues": 20, + "watchers": 2, + "default_branch": "master" + }, + "organization": { + "login": "solven-eu", + "id": 34552197, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjM0NTUyMTk3", + "url": "https://api.github.com/orgs/solven-eu", + "repos_url": "https://api.github.com/orgs/solven-eu/repos", + "events_url": "https://api.github.com/orgs/solven-eu/events", + "hooks_url": "https://api.github.com/orgs/solven-eu/hooks", + "issues_url": "https://api.github.com/orgs/solven-eu/issues", + "members_url": "https://api.github.com/orgs/solven-eu/members{/member}", + "public_members_url": "https://api.github.com/orgs/solven-eu/public_members{/member}", + "avatar_url": "https://avatars.githubusercontent.com/u/34552197?v=4", + "description": "" + }, + "sender": { + "login": "blacelle", + "id": 2117911, + "node_id": "MDQ6VXNlcjIxMTc5MTE=", + "avatar_url": "https://avatars.githubusercontent.com/u/2117911?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/blacelle", + "html_url": "https://github.com/blacelle", + "followers_url": "https://api.github.com/users/blacelle/followers", + "following_url": "https://api.github.com/users/blacelle/following{/other_user}", + "gists_url": "https://api.github.com/users/blacelle/gists{/gist_id}", + "starred_url": "https://api.github.com/users/blacelle/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/blacelle/subscriptions", + "organizations_url": "https://api.github.com/users/blacelle/orgs", + "repos_url": "https://api.github.com/users/blacelle/repos", + "events_url": "https://api.github.com/users/blacelle/events{/privacy}", + "received_events_url": "https://api.github.com/users/blacelle/received_events", + "type": "User", + "site_admin": false + }, + "installation": { + "id": 9086720, + "node_id": "MDIzOkludGVncmF0aW9uSW5zdGFsbGF0aW9uOTA4NjcyMA==" + } +} \ No newline at end of file diff --git a/github/src/test/resources/github/webhook/pr_open-push_event-1.json b/github/src/test/resources/github/webhook/pr_open-push_event-1.json new file mode 100644 index 000000000..5d893b770 --- /dev/null +++ b/github/src/test/resources/github/webhook/pr_open-push_event-1.json @@ -0,0 +1,186 @@ +{ + "ref": "refs/heads/cleanthat_tests/open_review_request", + "before": "0000000000000000000000000000000000000000", + "after": "957d4697599b1cea7b81f60dddbe3edfb236f2af", + "repository": { + "id": 264855617, + "node_id": "MDEwOlJlcG9zaXRvcnkyNjQ4NTU2MTc=", + "name": "cleanthat", + "full_name": "solven-eu/cleanthat", + "private": false, + "owner": { + "name": "solven-eu", + "email": "benoit.lacelle@solven.eu", + "login": "solven-eu", + "id": 34552197, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjM0NTUyMTk3", + "avatar_url": "https://avatars.githubusercontent.com/u/34552197?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/solven-eu", + "html_url": "https://github.com/solven-eu", + "followers_url": "https://api.github.com/users/solven-eu/followers", + "following_url": "https://api.github.com/users/solven-eu/following{/other_user}", + "gists_url": "https://api.github.com/users/solven-eu/gists{/gist_id}", + "starred_url": "https://api.github.com/users/solven-eu/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/solven-eu/subscriptions", + "organizations_url": "https://api.github.com/users/solven-eu/orgs", + "repos_url": "https://api.github.com/users/solven-eu/repos", + "events_url": "https://api.github.com/users/solven-eu/events{/privacy}", + "received_events_url": "https://api.github.com/users/solven-eu/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/solven-eu/cleanthat", + "description": "Github App opening automatically cleaning PR", + "fork": false, + "url": "https://github.com/solven-eu/cleanthat", + "forks_url": "https://api.github.com/repos/solven-eu/cleanthat/forks", + "keys_url": "https://api.github.com/repos/solven-eu/cleanthat/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/solven-eu/cleanthat/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/solven-eu/cleanthat/teams", + "hooks_url": "https://api.github.com/repos/solven-eu/cleanthat/hooks", + "issue_events_url": "https://api.github.com/repos/solven-eu/cleanthat/issues/events{/number}", + "events_url": "https://api.github.com/repos/solven-eu/cleanthat/events", + "assignees_url": "https://api.github.com/repos/solven-eu/cleanthat/assignees{/user}", + "branches_url": "https://api.github.com/repos/solven-eu/cleanthat/branches{/branch}", + "tags_url": "https://api.github.com/repos/solven-eu/cleanthat/tags", + "blobs_url": "https://api.github.com/repos/solven-eu/cleanthat/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/solven-eu/cleanthat/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/solven-eu/cleanthat/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/solven-eu/cleanthat/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/solven-eu/cleanthat/statuses/{sha}", + "languages_url": "https://api.github.com/repos/solven-eu/cleanthat/languages", + "stargazers_url": "https://api.github.com/repos/solven-eu/cleanthat/stargazers", + "contributors_url": "https://api.github.com/repos/solven-eu/cleanthat/contributors", + "subscribers_url": "https://api.github.com/repos/solven-eu/cleanthat/subscribers", + "subscription_url": "https://api.github.com/repos/solven-eu/cleanthat/subscription", + "commits_url": "https://api.github.com/repos/solven-eu/cleanthat/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/solven-eu/cleanthat/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/solven-eu/cleanthat/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/solven-eu/cleanthat/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/solven-eu/cleanthat/contents/{+path}", + "compare_url": "https://api.github.com/repos/solven-eu/cleanthat/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/solven-eu/cleanthat/merges", + "archive_url": "https://api.github.com/repos/solven-eu/cleanthat/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/solven-eu/cleanthat/downloads", + "issues_url": "https://api.github.com/repos/solven-eu/cleanthat/issues{/number}", + "pulls_url": "https://api.github.com/repos/solven-eu/cleanthat/pulls{/number}", + "milestones_url": "https://api.github.com/repos/solven-eu/cleanthat/milestones{/number}", + "notifications_url": "https://api.github.com/repos/solven-eu/cleanthat/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/solven-eu/cleanthat/labels{/name}", + "releases_url": "https://api.github.com/repos/solven-eu/cleanthat/releases{/id}", + "deployments_url": "https://api.github.com/repos/solven-eu/cleanthat/deployments", + "created_at": 1589785461, + "updated_at": "2021-07-26T08:01:55Z", + "pushed_at": 1627286563, + "git_url": "git://github.com/solven-eu/cleanthat.git", + "ssh_url": "git@github.com:solven-eu/cleanthat.git", + "clone_url": "https://github.com/solven-eu/cleanthat.git", + "svn_url": "https://github.com/solven-eu/cleanthat", + "homepage": null, + "size": 793, + "stargazers_count": 2, + "watchers_count": 2, + "language": "Java", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 19, + "license": null, + "forks": 0, + "open_issues": 19, + "watchers": 2, + "default_branch": "master", + "stargazers": 2, + "master_branch": "master", + "organization": "solven-eu" + }, + "pusher": { + "name": "blacelle", + "email": "benoit.lacelle@gmail.com" + }, + "organization": { + "login": "solven-eu", + "id": 34552197, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjM0NTUyMTk3", + "url": "https://api.github.com/orgs/solven-eu", + "repos_url": "https://api.github.com/orgs/solven-eu/repos", + "events_url": "https://api.github.com/orgs/solven-eu/events", + "hooks_url": "https://api.github.com/orgs/solven-eu/hooks", + "issues_url": "https://api.github.com/orgs/solven-eu/issues", + "members_url": "https://api.github.com/orgs/solven-eu/members{/member}", + "public_members_url": "https://api.github.com/orgs/solven-eu/public_members{/member}", + "avatar_url": "https://avatars.githubusercontent.com/u/34552197?v=4", + "description": "" + }, + "sender": { + "login": "blacelle", + "id": 2117911, + "node_id": "MDQ6VXNlcjIxMTc5MTE=", + "avatar_url": "https://avatars.githubusercontent.com/u/2117911?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/blacelle", + "html_url": "https://github.com/blacelle", + "followers_url": "https://api.github.com/users/blacelle/followers", + "following_url": "https://api.github.com/users/blacelle/following{/other_user}", + "gists_url": "https://api.github.com/users/blacelle/gists{/gist_id}", + "starred_url": "https://api.github.com/users/blacelle/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/blacelle/subscriptions", + "organizations_url": "https://api.github.com/users/blacelle/orgs", + "repos_url": "https://api.github.com/users/blacelle/repos", + "events_url": "https://api.github.com/users/blacelle/events{/privacy}", + "received_events_url": "https://api.github.com/users/blacelle/received_events", + "type": "User", + "site_admin": false + }, + "installation": { + "id": 9086720, + "node_id": "MDIzOkludGVncmF0aW9uSW5zdGFsbGF0aW9uOTA4NjcyMA==" + }, + "created": true, + "deleted": false, + "forced": false, + "base_ref": "refs/heads/master", + "compare": "https://github.com/solven-eu/cleanthat/compare/cleanthat_tests/open_review_request", + "commits": [ + + ], + "head_commit": { + "id": "957d4697599b1cea7b81f60dddbe3edfb236f2af", + "tree_id": "ca1dfae6eb731516fc1aff2c01e8f354ac423583", + "distinct": true, + "message": "Add logs in case of event processing failre, Fix functionNames in lambda pom", + "timestamp": "2021-07-26T10:01:47+02:00", + "url": "https://github.com/solven-eu/cleanthat/commit/957d4697599b1cea7b81f60dddbe3edfb236f2af", + "author": { + "name": "Benoit Lacelle", + "email": "benoit.lacelle@gmail.com", + "username": "blacelle" + }, + "committer": { + "name": "Benoit Lacelle", + "email": "benoit.lacelle@gmail.com", + "username": "blacelle" + }, + "added": [ + "github/src/main/java/eu/solven/cleanthat/git_abstraction/GithubFacade.java", + "github/src/test/java/eu/solven/cleanthat/it/ITGithubWebhookHandlerFactory.java" + ], + "removed": [ + "github/src/test/java/eu/solven/cleanthat/github/run/RunGenerateGithubJwt.java" + ], + "modified": [ + "github/src/main/java/eu/solven/cleanthat/github/event/GithubWebhookHandler.java", + "lambda/README.md", + "lambda/pom.xml", + "parent/pom.xml", + "runnable/src/main/java/eu/solven/cleanthat/lambda/ACleanThatXxxFunction.java" + ] + } +} \ No newline at end of file diff --git a/github/src/test/resources/github/webhook/pr_open-push_event-2.json b/github/src/test/resources/github/webhook/pr_open-push_event-2.json new file mode 100644 index 000000000..bd17e3e55 --- /dev/null +++ b/github/src/test/resources/github/webhook/pr_open-push_event-2.json @@ -0,0 +1,207 @@ +{ + "ref": "refs/heads/cleanthat_tests/open_review_request", + "before": "957d4697599b1cea7b81f60dddbe3edfb236f2af", + "after": "0921eafb18b6c473476bb32d94a1725ba5ed3d60", + "repository": { + "id": 264855617, + "node_id": "MDEwOlJlcG9zaXRvcnkyNjQ4NTU2MTc=", + "name": "cleanthat", + "full_name": "solven-eu/cleanthat", + "private": false, + "owner": { + "name": "solven-eu", + "email": "benoit.lacelle@solven.eu", + "login": "solven-eu", + "id": 34552197, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjM0NTUyMTk3", + "avatar_url": "https://avatars.githubusercontent.com/u/34552197?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/solven-eu", + "html_url": "https://github.com/solven-eu", + "followers_url": "https://api.github.com/users/solven-eu/followers", + "following_url": "https://api.github.com/users/solven-eu/following{/other_user}", + "gists_url": "https://api.github.com/users/solven-eu/gists{/gist_id}", + "starred_url": "https://api.github.com/users/solven-eu/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/solven-eu/subscriptions", + "organizations_url": "https://api.github.com/users/solven-eu/orgs", + "repos_url": "https://api.github.com/users/solven-eu/repos", + "events_url": "https://api.github.com/users/solven-eu/events{/privacy}", + "received_events_url": "https://api.github.com/users/solven-eu/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/solven-eu/cleanthat", + "description": "Github App opening automatically cleaning PR", + "fork": false, + "url": "https://github.com/solven-eu/cleanthat", + "forks_url": "https://api.github.com/repos/solven-eu/cleanthat/forks", + "keys_url": "https://api.github.com/repos/solven-eu/cleanthat/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/solven-eu/cleanthat/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/solven-eu/cleanthat/teams", + "hooks_url": "https://api.github.com/repos/solven-eu/cleanthat/hooks", + "issue_events_url": "https://api.github.com/repos/solven-eu/cleanthat/issues/events{/number}", + "events_url": "https://api.github.com/repos/solven-eu/cleanthat/events", + "assignees_url": "https://api.github.com/repos/solven-eu/cleanthat/assignees{/user}", + "branches_url": "https://api.github.com/repos/solven-eu/cleanthat/branches{/branch}", + "tags_url": "https://api.github.com/repos/solven-eu/cleanthat/tags", + "blobs_url": "https://api.github.com/repos/solven-eu/cleanthat/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/solven-eu/cleanthat/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/solven-eu/cleanthat/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/solven-eu/cleanthat/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/solven-eu/cleanthat/statuses/{sha}", + "languages_url": "https://api.github.com/repos/solven-eu/cleanthat/languages", + "stargazers_url": "https://api.github.com/repos/solven-eu/cleanthat/stargazers", + "contributors_url": "https://api.github.com/repos/solven-eu/cleanthat/contributors", + "subscribers_url": "https://api.github.com/repos/solven-eu/cleanthat/subscribers", + "subscription_url": "https://api.github.com/repos/solven-eu/cleanthat/subscription", + "commits_url": "https://api.github.com/repos/solven-eu/cleanthat/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/solven-eu/cleanthat/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/solven-eu/cleanthat/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/solven-eu/cleanthat/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/solven-eu/cleanthat/contents/{+path}", + "compare_url": "https://api.github.com/repos/solven-eu/cleanthat/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/solven-eu/cleanthat/merges", + "archive_url": "https://api.github.com/repos/solven-eu/cleanthat/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/solven-eu/cleanthat/downloads", + "issues_url": "https://api.github.com/repos/solven-eu/cleanthat/issues{/number}", + "pulls_url": "https://api.github.com/repos/solven-eu/cleanthat/pulls{/number}", + "milestones_url": "https://api.github.com/repos/solven-eu/cleanthat/milestones{/number}", + "notifications_url": "https://api.github.com/repos/solven-eu/cleanthat/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/solven-eu/cleanthat/labels{/name}", + "releases_url": "https://api.github.com/repos/solven-eu/cleanthat/releases{/id}", + "deployments_url": "https://api.github.com/repos/solven-eu/cleanthat/deployments", + "created_at": 1589785461, + "updated_at": "2021-07-26T08:01:55Z", + "pushed_at": 1627286636, + "git_url": "git://github.com/solven-eu/cleanthat.git", + "ssh_url": "git@github.com:solven-eu/cleanthat.git", + "clone_url": "https://github.com/solven-eu/cleanthat.git", + "svn_url": "https://github.com/solven-eu/cleanthat", + "homepage": null, + "size": 793, + "stargazers_count": 2, + "watchers_count": 2, + "language": "Java", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 19, + "license": null, + "forks": 0, + "open_issues": 19, + "watchers": 2, + "default_branch": "master", + "stargazers": 2, + "master_branch": "master", + "organization": "solven-eu" + }, + "pusher": { + "name": "blacelle", + "email": "benoit.lacelle@gmail.com" + }, + "organization": { + "login": "solven-eu", + "id": 34552197, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjM0NTUyMTk3", + "url": "https://api.github.com/orgs/solven-eu", + "repos_url": "https://api.github.com/orgs/solven-eu/repos", + "events_url": "https://api.github.com/orgs/solven-eu/events", + "hooks_url": "https://api.github.com/orgs/solven-eu/hooks", + "issues_url": "https://api.github.com/orgs/solven-eu/issues", + "members_url": "https://api.github.com/orgs/solven-eu/members{/member}", + "public_members_url": "https://api.github.com/orgs/solven-eu/public_members{/member}", + "avatar_url": "https://avatars.githubusercontent.com/u/34552197?v=4", + "description": "" + }, + "sender": { + "login": "blacelle", + "id": 2117911, + "node_id": "MDQ6VXNlcjIxMTc5MTE=", + "avatar_url": "https://avatars.githubusercontent.com/u/2117911?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/blacelle", + "html_url": "https://github.com/blacelle", + "followers_url": "https://api.github.com/users/blacelle/followers", + "following_url": "https://api.github.com/users/blacelle/following{/other_user}", + "gists_url": "https://api.github.com/users/blacelle/gists{/gist_id}", + "starred_url": "https://api.github.com/users/blacelle/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/blacelle/subscriptions", + "organizations_url": "https://api.github.com/users/blacelle/orgs", + "repos_url": "https://api.github.com/users/blacelle/repos", + "events_url": "https://api.github.com/users/blacelle/events{/privacy}", + "received_events_url": "https://api.github.com/users/blacelle/received_events", + "type": "User", + "site_admin": false + }, + "installation": { + "id": 9086720, + "node_id": "MDIzOkludGVncmF0aW9uSW5zdGFsbGF0aW9uOTA4NjcyMA==" + }, + "created": false, + "deleted": false, + "forced": false, + "base_ref": null, + "compare": "https://github.com/solven-eu/cleanthat/compare/957d4697599b...0921eafb18b6", + "commits": [ + { + "id": "0921eafb18b6c473476bb32d94a1725ba5ed3d60", + "tree_id": "bc6967c64a60cb46d5318fda177542f5993c442f", + "distinct": true, + "message": "Simplify code", + "timestamp": "2021-07-26T10:03:51+02:00", + "url": "https://github.com/solven-eu/cleanthat/commit/0921eafb18b6c473476bb32d94a1725ba5ed3d60", + "author": { + "name": "Benoit Lacelle", + "email": "benoit.lacelle@gmail.com", + "username": "blacelle" + }, + "committer": { + "name": "Benoit Lacelle", + "email": "benoit.lacelle@gmail.com", + "username": "blacelle" + }, + "added": [ + + ], + "removed": [ + + ], + "modified": [ + "github/src/main/java/eu/solven/cleanthat/github/event/GithubWebhookHandler.java" + ] + } + ], + "head_commit": { + "id": "0921eafb18b6c473476bb32d94a1725ba5ed3d60", + "tree_id": "bc6967c64a60cb46d5318fda177542f5993c442f", + "distinct": true, + "message": "Simplify code", + "timestamp": "2021-07-26T10:03:51+02:00", + "url": "https://github.com/solven-eu/cleanthat/commit/0921eafb18b6c473476bb32d94a1725ba5ed3d60", + "author": { + "name": "Benoit Lacelle", + "email": "benoit.lacelle@gmail.com", + "username": "blacelle" + }, + "committer": { + "name": "Benoit Lacelle", + "email": "benoit.lacelle@gmail.com", + "username": "blacelle" + }, + "added": [ + + ], + "removed": [ + + ], + "modified": [ + "github/src/main/java/eu/solven/cleanthat/github/event/GithubWebhookHandler.java" + ] + } +} \ No newline at end of file diff --git a/runnable/src/test/java/eu/solven/cleanthat/github/run/RunCleanGithubBranch.java b/runnable/src/test/java/eu/solven/cleanthat/github/run/RunCleanGithubBranch.java index d2791138b..c9358839b 100644 --- a/runnable/src/test/java/eu/solven/cleanthat/github/run/RunCleanGithubBranch.java +++ b/runnable/src/test/java/eu/solven/cleanthat/github/run/RunCleanGithubBranch.java @@ -59,13 +59,12 @@ public void doSomethingAfterStartup(ContextRefreshedEvent event) throws IOExcept IGithubWebhookHandler handler = factory.makeWithFreshJwt(); GHAppInstallation installation = handler.getGithubAsApp() - .getApp() .getInstallationByRepository(repoFullName.split("/")[0], repoFullName.split("/")[1]); // TODO Unclear when we need an installation/server-to-server Github or a user-to-server Github GithubAndToken githubAndToken = handler.makeInstallationGithub(installation.getId()); GitHub github = githubAndToken.getGithub(); - GitHub userToServerGithub = handler.getGithubAsApp(); + // GitHub userToServerGithub = handler.getGithubAsApp(); GithubRefCleaner cleaner = appContext.getBean(GithubRefCleaner.class); GHRepository repo; @@ -109,7 +108,8 @@ public void doSomethingAfterStartup(ContextRefreshedEvent event) throws IOExcept if (!configExistsAnywhere) { // At some point, we could prefer remaining silent if we understand the repository tried to integrate // us, but did not completed. - cleaner.openPRWithCleanThatStandardConfiguration(userToServerGithub, defaultBranch); + LOGGER.debug("TODO"); + // cleaner.openPRWithCleanThatStandardConfiguration(userToServerGithub, defaultBranch); } else { LOGGER.info("There is at least one branch with CleanThat configured ({})", branchWithConfig.get().getName()); diff --git a/runnable/src/test/java/eu/solven/cleanthat/github/run/RunCleanGithubPullRequest.java b/runnable/src/test/java/eu/solven/cleanthat/github/run/RunCleanGithubPullRequest.java index 631a86d87..b4363953b 100644 --- a/runnable/src/test/java/eu/solven/cleanthat/github/run/RunCleanGithubPullRequest.java +++ b/runnable/src/test/java/eu/solven/cleanthat/github/run/RunCleanGithubPullRequest.java @@ -59,13 +59,12 @@ public void doSomethingAfterStartup(ContextRefreshedEvent event) throws IOExcept IGithubWebhookHandler handler = factory.makeWithFreshJwt(); GHAppInstallation installation = handler.getGithubAsApp() - .getApp() .getInstallationByRepository(repoFullName.split("/")[0], repoFullName.split("/")[1]); // TODO Unclear when we need an installation/server-to-server Github or a user-to-server Github GithubAndToken githubAndToken = handler.makeInstallationGithub(installation.getId()); GitHub github = githubAndToken.getGithub(); - GitHub userToServerGithub = handler.getGithubAsApp(); + // GitHub userToServerGithub = handler.getGithubAsApp(); GithubRefCleaner cleaner = appContext.getBean(GithubRefCleaner.class); GHRepository repo; @@ -109,7 +108,7 @@ public void doSomethingAfterStartup(ContextRefreshedEvent event) throws IOExcept if (!configExistsAnywhere) { // At some point, we could prefer remaining silent if we understand the repository tried to integrate // us, but did not completed. - cleaner.openPRWithCleanThatStandardConfiguration(userToServerGithub, defaultBranch); + // cleaner.openPRWithCleanThatStandardConfiguration(userToServerGithub, defaultBranch); } else { LOGGER.info("There is at least one branch with CleanThat configured ({})", branchWithConfig.get().getName());