Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/maven-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,10 @@ jobs:
- uses: s4u/maven-settings-action@v3.0.0
with:
servers: '[{"id": "ossrh", "username": "${{ secrets.DISTRIBUTION_REPOSITORY_RELEASE_USERNAME }}", "password": "${{ secrets.DISTRIBUTION_REPOSITORY_RELEASE_PASSWORD }}"}]'

- uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.TAG_SSH_KEY }}

- name: Release to production
run: mvn clean release:clean release:prepare release:perform -B -DaltDeploymentRepository=ossrh::https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/
run: mvn clean release:clean release:prepare release:perform -B -DaltDeploymentRepository=ossrh::https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ -Darguments="-Ddevelop.api.key=${{ secrets.DEVELOP_SERVER_API_KEY }} -Dprod.na1.api.key=${{ secrets.PROD_EU1_SERVER_API_KEY }} -Dprod.eu1.api.key=${{ secrets.PROD_NA1_SERVER_API_KEY }}" -P release
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package io.polyapi.commons.api.error.http;

import io.polyapi.commons.api.http.Response;
import org.apache.commons.io.IOUtils;

import java.io.IOException;
import java.io.InputStream;

/**
* Exception thrown when there's an Internal Server Error (status code 500) response from the server.
Expand All @@ -13,6 +17,14 @@ public class InternalServerErrorException extends HttpResponseException {
* @param response The response.
*/
public InternalServerErrorException(Response response) {
super("An internal error occurred on the server. Please contact an administrator.", response);
super(doIt(response.body()), response);
}

private static String doIt(InputStream body) {
try {
return IOUtils.toString(body);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
119 changes: 118 additions & 1 deletion polyapi-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,125 @@
</plugins>
</build>

<!-- Release profile. -->
<profiles>
<profile>
<id>develop-check</id>
<activation>
<property>
<name>develop.api.key</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<postBuildHookScript>verify</postBuildHookScript>
<showErrors>true</showErrors>
<writeJunitReport>true</writeJunitReport>
</configuration>
<executions>
<execution>
<id>develop-run</id>
<goals>
<goal>install</goal>
<goal>run</goal>
</goals>
<configuration>
<properties>
<cloneProjectsTo>${project.build.directory}/it/develop</cloneProjectsTo>
<host>https://develop-k8s.polyapi.io</host>
<apiKey>${develop.api.key}</apiKey>
<port>443</port>
</properties>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>prod-na1-check</id>
<activation>
<property>
<name>prod.na1.api.key</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<postBuildHookScript>verify</postBuildHookScript>
<showErrors>true</showErrors>
<writeJunitReport>true</writeJunitReport>
</configuration>
<executions>
<execution>
<id>prod-na1-run</id>
<goals>
<goal>install</goal>
<goal>run</goal>
</goals>
<configuration>
<properties>
<cloneProjectsTo>${project.build.directory}/it/prod/na1</cloneProjectsTo>
<host>https://na1.polyapi.io</host>
<apiKey>${prod.na1.api.key}</apiKey>
<port>443</port>
</properties>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>prod-eu1-check</id>
<activation>
<property>
<name>prod.eu1.api.key</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<postBuildHookScript>verify</postBuildHookScript>
<showErrors>true</showErrors>
<writeJunitReport>true</writeJunitReport>
</configuration>
<executions>
<execution>
<id>prod-eu1-run</id>
<goals>
<goal>install</goal>
<goal>run</goal>
</goals>
<configuration>
<properties>
<cloneProjectsTo>${project.build.directory}/it/prod/eu1</cloneProjectsTo>
<host>https://eu1.polyapi.io</host>
<apiKey>${prod.eu1.api.key}</apiKey>
<port>443</port>
</properties>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<!-- Release profile. -->
<profile>
<id>release</id>
<activation>
Expand Down
161 changes: 161 additions & 0 deletions polyapi-maven-plugin/src/it/deploy-function-it/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.polyapi.it</groupId>
<artifactId>deploy-function-it</artifactId>
<version>@project.version@</version>

<url>https://polyapi.io</url>
<description>Deploy function IT for Poly API</description>
<scm>
<url>https://github.com/polyapi/polyapi-java</url>
</scm>
<properties>
<org.slf4j.simpleLogger.defaultLogLevel>debug</org.slf4j.simpleLogger.defaultLogLevel>
<junit.version>5.10.0</junit.version>
<context>${project.groupId}</context>
</properties>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<dependencies>

<!-- JUnit dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.polyapi</groupId>
<artifactId>library</artifactId>
<version>@project.version@</version>
</dependency>
</dependencies>

<build>
<resources>
<resource>
<directory>target/generated-resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.12.1</version>
<configuration>
<parameters>true</parameters>
</configuration>
<executions>
<execution>
<id>poly-compilation</id>
<phase>validate</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.polyapi</groupId>
<artifactId>polyapi-maven-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<id>clear-function</id>
<phase>clean</phase>
<goals>
<goal>delete-function</goal>
</goals>
<configuration>
<functionName>defaultFunction</functionName>
</configuration>
</execution>
<execution>
<id>deploy-and-generate</id>
<phase>validate</phase>
<goals>
<goal>deploy-functions</goal>
<goal>generate-sources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>target/generated-sources</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<!-- Profile to be run exclusively in EU1 function due to a bug that requires some time between deployment of a server function and it's execution. -->
<profile>
<id>delayed-function-execution</id>
<activation>
<property>
<name>host</name>
<value>https://eu1.polyapi.io</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>sleep-for-a-while</id>
<phase>test-compile</phase>
<configuration>
<target>
<sleep seconds="10" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.polyapi.it;

import io.polyapi.commons.api.model.PolyFunction;

public class DefaultFunction {

@PolyFunction
public String defaultFunction(String parameter) {
return String.format("%s - %s", parameter, parameter);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package io.polyapi;

import org.junit.jupiter.api.Test;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;

public class ReleaseTest {

@Test
public void defaultFunctionTest() {
assertThat(Poly.io.polyapi.it.defaultFunction("test"), equalTo("test - test"));
}
}
Loading