Skip to content

Commit

Permalink
Support for release event.
Browse files Browse the repository at this point in the history
  • Loading branch information
coverbeck committed Aug 7, 2024
1 parent da37df9 commit 6fdee8b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 28 deletions.
14 changes: 7 additions & 7 deletions THIRD-PARTY-LICENSES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ Lists of 417 third-party dependencies.
(The Apache Software License, Version 2.0) docker-java-core (com.github.docker-java:docker-java-core:3.3.6 - https://github.com/docker-java/docker-java)
(The Apache Software License, Version 2.0) docker-java-transport (com.github.docker-java:docker-java-transport:3.3.6 - https://github.com/docker-java/docker-java)
(The Apache Software License, Version 2.0) docker-java-transport-httpclient5 (com.github.docker-java:docker-java-transport-httpclient5:3.3.6 - https://github.com/docker-java/docker-java)
(Apache Software License, Version 2.0) dockstore-common (io.dockstore:dockstore-common:1.16.0-alpha.11 - no url defined)
(Apache Software License, Version 2.0) dockstore-integration-testing (io.dockstore:dockstore-integration-testing:1.16.0-alpha.11 - no url defined)
(Apache Software License, Version 2.0) dockstore-language-plugin-parent (io.dockstore:dockstore-language-plugin-parent:1.16.0-alpha.11 - no url defined)
(Apache Software License, Version 2.0) dockstore-webservice (io.dockstore:dockstore-webservice:1.16.0-alpha.11 - no url defined)
(Apache Software License, Version 2.0) dockstore-common (io.dockstore:dockstore-common:1.16.0-alpha.12 - no url defined)
(Apache Software License, Version 2.0) dockstore-integration-testing (io.dockstore:dockstore-integration-testing:1.16.0-alpha.12 - no url defined)
(Apache Software License, Version 2.0) dockstore-language-plugin-parent (io.dockstore:dockstore-language-plugin-parent:1.16.0-alpha.12 - no url defined)
(Apache Software License, Version 2.0) dockstore-webservice (io.dockstore:dockstore-webservice:1.16.0-alpha.12 - no url defined)
(Apache License 2.0) Dropwizard (io.dropwizard:dropwizard-core:4.0.2 - http://www.dropwizard.io/4.0.2/dropwizard-bom/dropwizard-dependencies/dropwizard-parent/dropwizard-core)
(Apache License 2.0) Dropwizard Asset Bundle (io.dropwizard:dropwizard-assets:4.0.2 - http://www.dropwizard.io/4.0.2/dropwizard-bom/dropwizard-dependencies/dropwizard-parent/dropwizard-assets)
(Apache License 2.0) Dropwizard Authentication (io.dropwizard:dropwizard-auth:4.0.2 - http://www.dropwizard.io/4.0.2/dropwizard-bom/dropwizard-dependencies/dropwizard-parent/dropwizard-auth)
Expand Down Expand Up @@ -163,7 +163,7 @@ Lists of 417 third-party dependencies.
(The Apache Software License, Version 2.0) FindBugs-jsr305 (com.google.code.findbugs:jsr305:3.0.2 - http://findbugs.sourceforge.net/)
(The Apache Software License, Version 2.0) GeantyRef (io.leangen.geantyref:geantyref:1.3.14 - https://github.com/leangen/geantyref)
(Apache 2.0) genericExtras (io.circe:circe-generic-extras_2.13:0.14.1 - https://github.com/circe/circe-generic-extras)
(The MIT license) GitHub API for Java (org.kohsuke:github-api:1.313 - https://github-api.kohsuke.org/)
(The MIT license) GitHub API for Java (org.kohsuke:github-api:1.322 - https://github-api.kohsuke.org/)
(The Apache Software License, Version 2.0) Gitlab Java API Wrapper (org.gitlab:java-gitlab-api:4.0.0 - http://nexus.sonatype.org/oss-repository-hosting.html/java-gitlab-api)
(The Apache Software License, Version 2.0) Google APIs Client Library for Java (com.google.api-client:google-api-client:1.35.0 - https://github.com/googleapis/google-api-java-client/google-api-client)
(BSD New license) Google Auth Library for Java - Credentials (com.google.auth:google-auth-library-credentials:1.5.3 - https://github.com/googleapis/google-auth-library-java/google-auth-library-credentials)
Expand Down Expand Up @@ -352,7 +352,7 @@ Lists of 417 third-party dependencies.
(Apache License, Version 2.0) Objenesis (org.objenesis:objenesis:3.2 - http://objenesis.org/objenesis)
(The Apache Software License, Version 2.0) okhttp (com.squareup.okhttp3:okhttp:4.10.0 - https://square.github.io/okhttp/)
(The Apache Software License, Version 2.0) okio (com.squareup.okio:okio-jvm:3.0.0 - https://github.com/square/okio/)
(Apache Software License, Version 2.0) openapi-java-client (io.dockstore:openapi-java-client:1.16.0-alpha.11 - no url defined)
(Apache Software License, Version 2.0) openapi-java-client (io.dockstore:openapi-java-client:1.16.0-alpha.12 - no url defined)
(The Apache License, Version 2.0) OpenCensus (io.opencensus:opencensus-api:0.31.0 - https://github.com/census-instrumentation/opencensus-java)
(Apache 2) opencsv (com.opencsv:opencsv:5.7.1 - http://opencsv.sf.net)
(Apache 2.0) optics (io.circe:circe-optics_2.13:0.14.1 - https://github.com/circe/circe-optics)
Expand Down Expand Up @@ -394,7 +394,7 @@ Lists of 417 third-party dependencies.
(Apache License 2.0) swagger-core-jakarta (io.swagger.core.v3:swagger-core-jakarta:2.2.15 - https://github.com/swagger-api/swagger-core/modules/swagger-core-jakarta)
(Apache License 2.0) swagger-integration-jakarta (io.swagger.core.v3:swagger-integration-jakarta:2.2.15 - https://github.com/swagger-api/swagger-core/modules/swagger-integration-jakarta)
(Apache Software License, Version 2.0) swagger-java-bitbucket-client (io.dockstore:swagger-java-bitbucket-client:2.0.3 - no url defined)
(Apache Software License, Version 2.0) swagger-java-client (io.dockstore:swagger-java-client:1.16.0-alpha.11 - no url defined)
(Apache Software License, Version 2.0) swagger-java-client (io.dockstore:swagger-java-client:1.16.0-alpha.12 - no url defined)
(Apache Software License, Version 2.0) swagger-java-discourse-client (io.dockstore:swagger-java-discourse-client:2.0.1 - no url defined)
(Apache Software License, Version 2.0) swagger-java-quay-client (io.dockstore:swagger-java-quay-client:2.0.2 - no url defined)
(Apache Software License, Version 2.0) swagger-java-sam-client (io.dockstore:swagger-java-sam-client:2.0.2 - no url defined)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import io.dockstore.openapi.client.api.WorkflowsApi;
import io.dockstore.openapi.client.model.InstallationRepositoriesPayload;
import io.dockstore.openapi.client.model.PushPayload;
import io.dockstore.openapi.client.model.ReleasePayload;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import org.apache.commons.configuration2.INIConfiguration;
Expand Down Expand Up @@ -125,23 +126,21 @@ private String getObject(String key) throws IOException {
return IOUtils.toString(object, StandardCharsets.UTF_8);
}
private PushPayload getGitHubPushPayloadByKey(String eventType, String body, String key) throws IOException, NoSuchKeyException {
try {
PushPayload pushPayload;
pushPayload = MAPPER.readValue(body, PushPayload.class);
if (pushPayload == null) {
logReadError(eventType, key);
}
return pushPayload;
} catch (JsonSyntaxException e) {
exceptionReadError(e, eventType, key);
}
return null;
return getPayloadByKey(eventType, body, key, PushPayload.class);
}
private InstallationRepositoriesPayload getGitHubInstallationRepositoriesPayloadByKey(String eventType, String body, String key) throws IOException, NoSuchKeyException {
return getPayloadByKey(eventType, body, key, InstallationRepositoriesPayload.class);
}
private ReleasePayload getGitHubReleasePayloadByKey(String eventType, String body, String key) throws IOException, NoSuchKeyException {
return getPayloadByKey(eventType, body, key, ReleasePayload.class);
}
private <T> T getPayloadByKey(String eventType, String body, String key, Class<T> clazz) throws IOException, NoSuchKeyException {
try {
InstallationRepositoriesPayload installationRepositoriesPayload;
installationRepositoriesPayload = MAPPER.readValue(body, InstallationRepositoriesPayload.class);
return installationRepositoriesPayload;
T payload = MAPPER.readValue(body, clazz);
if (payload == null) {
logReadError(eventType, key);
}
return payload;
} catch (JsonSyntaxException e) {
exceptionReadError(e, eventType, key);
}
Expand Down Expand Up @@ -183,16 +182,17 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA
JsonObject jsonObject = GSON.fromJson(s3GithubObject, JsonObject.class);
JsonObject body = jsonObject.get("body").getAsJsonObject();
String bodyString = body.toString();
String eventType = jsonObject.get("eventType").getAsString();
if ("installation_repositories".equals(eventType)) {
final String eventType = jsonObject.get("eventType").getAsString();
switch (eventType) {
case "installation_repositories" -> {
InstallationRepositoriesPayload payload = getGitHubInstallationRepositoriesPayloadByKey(eventType, bodyString, key);
if (payload != null) {
workflowsApi.handleGitHubInstallation(payload, deliveryid);
} else {
logReadError(eventType, key);
}

} else if ("push".equals(eventType)) {
}
case "push" -> {
//push events
PushPayload payload = getGitHubPushPayloadByKey(eventType, bodyString, key);
if (payload != null) {
Expand All @@ -204,11 +204,20 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA
} else {
logReadError(eventType, key);
}

} else {
}
case "release" -> {
final ReleasePayload releasePayload = getGitHubReleasePayloadByKey(eventType, bodyString, key);
if (releasePayload != null) {
workflowsApi.handleGitHubTaggedRelease(releasePayload, deliveryid);
} else {
logReadError(eventType, key);
}
}
default -> {
LOG.error("Invalid eventType {} format for key {}", eventType, key);
return;
}
}
LOG.info("Successfully submitted events for key {}", key);
} catch (IOException e) {
exceptionMessage(e, String.format("Could not submit github event from key %s", key), 1);
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

<github.url>scm:git:git@github.com:dockstore/dockstore-support.git</github.url>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<dockstore-core.version>1.16.0-alpha.11</dockstore-core.version>
<dockstore-core.version>1.16.0-alpha.12</dockstore-core.version>
<maven-surefire.version>3.0.0-M5</maven-surefire.version>
<maven-failsafe.version>2.22.2</maven-failsafe.version>
<skipTests>false</skipTests>
Expand Down

0 comments on commit 6fdee8b

Please sign in to comment.