Skip to content

Commit 47bad81

Browse files
authored
Merge pull request #30 from polyapi/develop
Releasing v0.11.0
2 parents 12f5d9d + 782eced commit 47bad81

File tree

10 files changed

+8903
-6
lines changed

10 files changed

+8903
-6
lines changed

.github/workflows/maven-publish.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,10 @@ jobs:
2626
- uses: s4u/[email protected]
2727
with:
2828
servers: '[{"id": "ossrh", "username": "${{ secrets.DISTRIBUTION_REPOSITORY_RELEASE_USERNAME }}", "password": "${{ secrets.DISTRIBUTION_REPOSITORY_RELEASE_PASSWORD }}"}]'
29+
30+
- uses: webfactory/[email protected]
31+
with:
32+
ssh-private-key: ${{ secrets.TAG_SSH_KEY }}
33+
2934
- name: Release to production
30-
run: mvn clean release:clean release:prepare release:perform -B -DaltDeploymentRepository=ossrh::https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/
35+
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

commons/src/main/java/io/polyapi/commons/api/error/http/InternalServerErrorException.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package io.polyapi.commons.api.error.http;
22

33
import io.polyapi.commons.api.http.Response;
4+
import org.apache.commons.io.IOUtils;
5+
6+
import java.io.IOException;
7+
import java.io.InputStream;
48

59
/**
610
* Exception thrown when there's an Internal Server Error (status code 500) response from the server.
@@ -13,6 +17,14 @@ public class InternalServerErrorException extends HttpResponseException {
1317
* @param response The response.
1418
*/
1519
public InternalServerErrorException(Response response) {
16-
super("An internal error occurred on the server. Please contact an administrator.", response);
20+
super(doIt(response.body()), response);
21+
}
22+
23+
private static String doIt(InputStream body) {
24+
try {
25+
return IOUtils.toString(body);
26+
} catch (IOException e) {
27+
throw new RuntimeException(e);
28+
}
1729
}
1830
}

polyapi-maven-plugin/pom.xml

Lines changed: 118 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,125 @@
120120
</plugins>
121121
</build>
122122

123-
<!-- Release profile. -->
124123
<profiles>
124+
<profile>
125+
<id>develop-check</id>
126+
<activation>
127+
<property>
128+
<name>develop.api.key</name>
129+
</property>
130+
</activation>
131+
<build>
132+
<plugins>
133+
<plugin>
134+
<groupId>org.apache.maven.plugins</groupId>
135+
<artifactId>maven-invoker-plugin</artifactId>
136+
<version>3.7.0</version>
137+
<configuration>
138+
<postBuildHookScript>verify</postBuildHookScript>
139+
<showErrors>true</showErrors>
140+
<writeJunitReport>true</writeJunitReport>
141+
</configuration>
142+
<executions>
143+
<execution>
144+
<id>develop-run</id>
145+
<goals>
146+
<goal>install</goal>
147+
<goal>run</goal>
148+
</goals>
149+
<configuration>
150+
<properties>
151+
<cloneProjectsTo>${project.build.directory}/it/develop</cloneProjectsTo>
152+
<host>https://develop-k8s.polyapi.io</host>
153+
<apiKey>${develop.api.key}</apiKey>
154+
<port>443</port>
155+
</properties>
156+
</configuration>
157+
</execution>
158+
</executions>
159+
</plugin>
160+
</plugins>
161+
</build>
162+
</profile>
163+
<profile>
164+
<id>prod-na1-check</id>
165+
<activation>
166+
<property>
167+
<name>prod.na1.api.key</name>
168+
</property>
169+
</activation>
170+
<build>
171+
<plugins>
172+
<plugin>
173+
<groupId>org.apache.maven.plugins</groupId>
174+
<artifactId>maven-invoker-plugin</artifactId>
175+
<version>3.7.0</version>
176+
<configuration>
177+
<postBuildHookScript>verify</postBuildHookScript>
178+
<showErrors>true</showErrors>
179+
<writeJunitReport>true</writeJunitReport>
180+
</configuration>
181+
<executions>
182+
<execution>
183+
<id>prod-na1-run</id>
184+
<goals>
185+
<goal>install</goal>
186+
<goal>run</goal>
187+
</goals>
188+
<configuration>
189+
<properties>
190+
<cloneProjectsTo>${project.build.directory}/it/prod/na1</cloneProjectsTo>
191+
<host>https://na1.polyapi.io</host>
192+
<apiKey>${prod.na1.api.key}</apiKey>
193+
<port>443</port>
194+
</properties>
195+
</configuration>
196+
</execution>
197+
</executions>
198+
</plugin>
199+
</plugins>
200+
</build>
201+
</profile>
202+
<profile>
203+
<id>prod-eu1-check</id>
204+
<activation>
205+
<property>
206+
<name>prod.eu1.api.key</name>
207+
</property>
208+
</activation>
209+
<build>
210+
<plugins>
211+
<plugin>
212+
<groupId>org.apache.maven.plugins</groupId>
213+
<artifactId>maven-invoker-plugin</artifactId>
214+
<version>3.7.0</version>
215+
<configuration>
216+
<postBuildHookScript>verify</postBuildHookScript>
217+
<showErrors>true</showErrors>
218+
<writeJunitReport>true</writeJunitReport>
219+
</configuration>
220+
<executions>
221+
<execution>
222+
<id>prod-eu1-run</id>
223+
<goals>
224+
<goal>install</goal>
225+
<goal>run</goal>
226+
</goals>
227+
<configuration>
228+
<properties>
229+
<cloneProjectsTo>${project.build.directory}/it/prod/eu1</cloneProjectsTo>
230+
<host>https://eu1.polyapi.io</host>
231+
<apiKey>${prod.eu1.api.key}</apiKey>
232+
<port>443</port>
233+
</properties>
234+
</configuration>
235+
</execution>
236+
</executions>
237+
</plugin>
238+
</plugins>
239+
</build>
240+
</profile>
241+
<!-- Release profile. -->
125242
<profile>
126243
<id>release</id>
127244
<activation>
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<groupId>io.polyapi.it</groupId>
7+
<artifactId>deploy-function-it</artifactId>
8+
<version>@project.version@</version>
9+
10+
<url>https://polyapi.io</url>
11+
<description>Deploy function IT for Poly API</description>
12+
<scm>
13+
<url>https://github.com/polyapi/polyapi-java</url>
14+
</scm>
15+
<properties>
16+
<org.slf4j.simpleLogger.defaultLogLevel>debug</org.slf4j.simpleLogger.defaultLogLevel>
17+
<junit.version>5.10.0</junit.version>
18+
<context>${project.groupId}</context>
19+
</properties>
20+
<licenses>
21+
<license>
22+
<name>The Apache Software License, Version 2.0</name>
23+
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
24+
<distribution>repo</distribution>
25+
</license>
26+
</licenses>
27+
<dependencies>
28+
29+
<!-- JUnit dependencies -->
30+
<dependency>
31+
<groupId>org.junit.jupiter</groupId>
32+
<artifactId>junit-jupiter-engine</artifactId>
33+
<version>${junit.version}</version>
34+
<scope>test</scope>
35+
</dependency>
36+
<dependency>
37+
<groupId>org.junit.jupiter</groupId>
38+
<artifactId>junit-jupiter-params</artifactId>
39+
<version>${junit.version}</version>
40+
<scope>test</scope>
41+
</dependency>
42+
<dependency>
43+
<groupId>junit</groupId>
44+
<artifactId>junit</artifactId>
45+
<version>4.13.2</version>
46+
<scope>test</scope>
47+
</dependency>
48+
<dependency>
49+
<groupId>io.polyapi</groupId>
50+
<artifactId>library</artifactId>
51+
<version>@project.version@</version>
52+
</dependency>
53+
</dependencies>
54+
55+
<build>
56+
<resources>
57+
<resource>
58+
<directory>target/generated-resources</directory>
59+
</resource>
60+
</resources>
61+
<plugins>
62+
<plugin>
63+
<groupId>org.apache.maven.plugins</groupId>
64+
<artifactId>maven-compiler-plugin</artifactId>
65+
<version>3.12.1</version>
66+
<configuration>
67+
<parameters>true</parameters>
68+
</configuration>
69+
<executions>
70+
<execution>
71+
<id>poly-compilation</id>
72+
<phase>validate</phase>
73+
<goals>
74+
<goal>compile</goal>
75+
</goals>
76+
</execution>
77+
</executions>
78+
</plugin>
79+
<plugin>
80+
<groupId>io.polyapi</groupId>
81+
<artifactId>polyapi-maven-plugin</artifactId>
82+
<version>@project.version@</version>
83+
<executions>
84+
<execution>
85+
<id>clear-function</id>
86+
<phase>clean</phase>
87+
<goals>
88+
<goal>delete-function</goal>
89+
</goals>
90+
<configuration>
91+
<functionName>defaultFunction</functionName>
92+
</configuration>
93+
</execution>
94+
<execution>
95+
<id>deploy-and-generate</id>
96+
<phase>validate</phase>
97+
<goals>
98+
<goal>deploy-functions</goal>
99+
<goal>generate-sources</goal>
100+
</goals>
101+
</execution>
102+
</executions>
103+
</plugin>
104+
<plugin>
105+
<groupId>org.codehaus.mojo</groupId>
106+
<artifactId>build-helper-maven-plugin</artifactId>
107+
<version>3.2.0</version>
108+
<executions>
109+
<execution>
110+
<id>add-source</id>
111+
<phase>generate-sources</phase>
112+
<goals>
113+
<goal>add-source</goal>
114+
</goals>
115+
<configuration>
116+
<sources>
117+
<source>target/generated-sources</source>
118+
</sources>
119+
</configuration>
120+
</execution>
121+
</executions>
122+
</plugin>
123+
</plugins>
124+
</build>
125+
126+
<profiles>
127+
<!-- 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. -->
128+
<profile>
129+
<id>delayed-function-execution</id>
130+
<activation>
131+
<property>
132+
<name>host</name>
133+
<value>https://eu1.polyapi.io</value>
134+
</property>
135+
</activation>
136+
<build>
137+
<plugins>
138+
<plugin>
139+
<groupId>org.apache.maven.plugins</groupId>
140+
<artifactId>maven-antrun-plugin</artifactId>
141+
<version>1.8</version>
142+
<executions>
143+
<execution>
144+
<id>sleep-for-a-while</id>
145+
<phase>test-compile</phase>
146+
<configuration>
147+
<target>
148+
<sleep seconds="10" />
149+
</target>
150+
</configuration>
151+
<goals>
152+
<goal>run</goal>
153+
</goals>
154+
</execution>
155+
</executions>
156+
</plugin>
157+
</plugins>
158+
</build>
159+
</profile>
160+
</profiles>
161+
</project>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package io.polyapi.it;
2+
3+
import io.polyapi.commons.api.model.PolyFunction;
4+
5+
public class DefaultFunction {
6+
7+
@PolyFunction
8+
public String defaultFunction(String parameter) {
9+
return String.format("%s - %s", parameter, parameter);
10+
}
11+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package io.polyapi;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import static org.hamcrest.CoreMatchers.equalTo;
6+
import static org.hamcrest.MatcherAssert.assertThat;
7+
8+
public class ReleaseTest {
9+
10+
@Test
11+
public void defaultFunctionTest() {
12+
assertThat(Poly.io.polyapi.it.defaultFunction("test"), equalTo("test - test"));
13+
}
14+
}

0 commit comments

Comments
 (0)