Skip to content

Commit 33e6a6b

Browse files
committed
CI env: yet another attempt to get stability in travis and gh workflow
1 parent c76b6fe commit 33e6a6b

File tree

11 files changed

+56
-20
lines changed

11 files changed

+56
-20
lines changed

.github/workflows/full-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
with:
2020
java-version: ${{ matrix.java_version }}
2121
- name: Install
22-
run: mvn clean install --fail-never -q -pl '!docs'
22+
run: mvn clean install -DskipTests -q -pl '!docs'
2323
env:
2424
BUILD_PORT: 0
2525
BUILD_SECURE_PORT: 0

.github/workflows/quick-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
with:
2121
java-version: ${{ matrix.java_version }}
2222
- name: Install
23-
run: mvn clean install --fail-never -q -pl '!docs'
23+
run: mvn clean install -DskipTests -q -pl '!docs'
2424
env:
2525
BUILD_PORT: 0
2626
BUILD_SECURE_PORT: 0

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
# - docker run -it --rm jooby /bin/sh
66
# - /build # mvn clean package
77

8-
FROM maven:3.6.0-jdk-8-alpine as maven
8+
FROM maven:3.6.0-jdk-8 as maven
99

1010
WORKDIR /build
1111
COPY pom.xml .
1212
COPY docs/ /build/docs/
1313
COPY etc/ /build/etc/
14-
COPY examples/ /build/examples/
1514
COPY jooby/ /build/jooby/
1615
COPY modules/ /build/modules/
1716
COPY tests/ /build/tests/
18-
COPY starters/ /build/starters/
1917

2018
RUN rm -rf /build/modules/jooby-graphiql/node
2119
RUN rm -rf /build/modules/jooby-graphiql/node_modules
2220

2321
RUN rm -rf /build/modules/jooby-graphql-playground/node
2422
RUN rm -rf /build/modules/jooby-graphql-playground/node_modules
23+
24+
RUN mvn clean install -DskipTests -q

etc/travis-install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
DIR=$(cd "$(dirname "$0")"; pwd)
44

5-
sh $DIR/maven.sh clean install -q --fail-never
5+
sh $DIR/maven.sh clean install -q -DskipTests -s $DIR/travis-settings.xml

etc/travis-settings.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
4+
<mirrors>
5+
<mirror>
6+
<id>maven-central</id>
7+
<name>Maven Central</name>
8+
<url>http://repo1.maven.org/maven2</url>
9+
<mirrorOf>central</mirrorOf>
10+
</mirror>
11+
</mirrors>
12+
</settings>

etc/travis.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
DIR=$(cd "$(dirname "$0")"; pwd)
44

5-
sh $DIR/maven.sh clean checkstyle:checkstyle -P checkstyle package
5+
sh $DIR/maven.sh clean checkstyle:checkstyle -P checkstyle package -s $DIR/travis-settings.xml

jooby/src/main/java/io/jooby/Server.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import javax.annotation.Nonnull;
99
import javax.annotation.Nullable;
10+
import java.io.EOFException;
1011
import java.io.IOException;
1112
import java.nio.channels.ClosedChannelException;
1213
import java.util.List;
@@ -136,6 +137,6 @@ static boolean connectionLost(@Nullable Throwable cause) {
136137
return msg.contains("reset by peer") || msg.contains("broken pipe");
137138
}
138139
}
139-
return (cause instanceof ClosedChannelException);
140+
return (cause instanceof ClosedChannelException) || (cause instanceof EOFException);
140141
}
141142
}

jooby/src/main/java/io/jooby/ServerOptions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ public void setHost(String host) {
451451

452452
private static int randomPort() {
453453
try (ServerSocket socket = new ServerSocket(0)) {
454+
socket.setReuseAddress(true);
454455
return socket.getLocalPort();
455456
} catch (IOException x) {
456457
throw SneakyThrows.propagate(x);

modules/jooby-netty/src/main/java/io/jooby/internal/netty/NettyWebSocket.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,10 @@ boolean fireConnect(Runnable next) {
231231
next.run();
232232
}
233233
}));
234+
return true;
235+
} else {
236+
return false;
234237
}
235-
return true;
236238
} else {
237239
return false;
238240
}

tests/src/test/java/io/jooby/WebClient.java

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package io.jooby;
22

3-
import io.jooby.internal.ArrayValue;
43
import okhttp3.Headers;
54
import okhttp3.OkHttpClient;
65
import okhttp3.RequestBody;
@@ -30,6 +29,7 @@
3029
import java.util.concurrent.CountDownLatch;
3130
import java.util.concurrent.LinkedBlockingQueue;
3231
import java.util.concurrent.TimeUnit;
32+
import java.util.concurrent.atomic.AtomicBoolean;
3333
import java.util.function.BiConsumer;
3434
import java.util.function.Consumer;
3535

@@ -39,23 +39,30 @@ private class SyncWebSocketListener extends WebSocketListener {
3939

4040
private CountDownLatch opened = new CountDownLatch(1);
4141

42-
private CountDownLatch closed = new CountDownLatch(1);
43-
44-
private List<Throwable> errors = new ArrayList<>();
42+
private AtomicBoolean closed = new AtomicBoolean(false);
4543

4644
private BlockingQueue messages = new LinkedBlockingQueue();
4745

46+
private String testName;
47+
48+
public SyncWebSocketListener(String testName) {
49+
this.testName = testName;
50+
}
51+
4852
@Override public void onOpen(@NotNull WebSocket webSocket, @NotNull Response response) {
4953
opened.countDown();
5054
}
5155

5256
@Override public void onClosed(@NotNull WebSocket webSocket, int code, @NotNull String reason) {
53-
closed.countDown();
57+
closed.set(true);
5458
}
5559

5660
@Override public void onFailure(@NotNull WebSocket webSocket, @NotNull Throwable e,
5761
@Nullable Response response) {
58-
errors.add(e);
62+
if (!Server.connectionLost(e)) {
63+
System.err.println("Unexpected web socket error: " + testName);
64+
e.printStackTrace();
65+
}
5966
}
6067

6168
@Override public void onMessage(@NotNull WebSocket webSocket, @NotNull String text) {
@@ -64,7 +71,7 @@ private class SyncWebSocketListener extends WebSocketListener {
6471

6572
public String lastMessage() {
6673
try {
67-
return (String) messages.take();
74+
return (String) messages.poll(10, TimeUnit.SECONDS);
6875
} catch (Exception x) {
6976
throw SneakyThrows.propagate(x);
7077
}
@@ -95,6 +102,12 @@ public String send(String message) {
95102
ws.send(message);
96103
return listener.lastMessage();
97104
}
105+
106+
public void close() {
107+
if (listener.closed.compareAndSet(false, true)) {
108+
ws.close(WebSocketCloseStatus.NORMAL_CODE, WebSocketCloseStatus.NORMAL.getReason());
109+
}
110+
}
98111
}
99112

100113
public class Request {
@@ -218,15 +231,17 @@ public void get(String path, SneakyThrows.Consumer<Response> callback) {
218231
get(path).execute(callback);
219232
}
220233

221-
public WebSocket syncWebSocket(String path, SneakyThrows.Consumer<BlockingWebSocket> consumer) {
234+
public void syncWebSocket(String path, SneakyThrows.Consumer<BlockingWebSocket> consumer) {
222235
okhttp3.Request.Builder req = new okhttp3.Request.Builder();
223236
req.url("ws://localhost:" + port + path);
224237
setRequestHeaders(req);
225238
okhttp3.Request r = req.build();
226-
SyncWebSocketListener listener = new SyncWebSocketListener();
239+
SyncWebSocketListener listener = new SyncWebSocketListener(
240+
System.getProperty("___app_name__") + "(" + System.getProperty("___server_name__") + ")");
227241
WebSocket webSocket = client.newWebSocket(r, listener);
228-
consumer.accept(new BlockingWebSocket(webSocket, listener));
229-
return webSocket;
242+
BlockingWebSocket blockingWebSocket = new BlockingWebSocket(webSocket, listener);
243+
consumer.accept(blockingWebSocket);
244+
blockingWebSocket.close();
230245
}
231246

232247
public Request options(String path) {

0 commit comments

Comments
 (0)