Skip to content

Commit a09fefe

Browse files
authored
Port Travis to GHA (docker-java#1396)
- removes Travis config - adds "Docker 18.x" and "Docker over TCP" to GHA Build Matrix - adds ciMate - Fixes Swarm tests
1 parent 3674117 commit a09fefe

27 files changed

+338
-404
lines changed

.ci/setup_docker.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
3+
set -exu
4+
5+
DOCKER_VERSION="${DOCKER_VERSION:-}"
6+
DOCKER_HOST="${DOCKER_HOST:-}"
7+
8+
if [[ -n $DOCKER_VERSION ]]; then
9+
sudo -E apt-get -q -y --purge remove docker-engine docker-ce
10+
11+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
12+
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
13+
sudo apt-get update
14+
sudo apt-cache madison docker-ce
15+
sudo apt-get install "docker-ce=$DOCKER_VERSION"
16+
fi
17+
18+
if [[ -n $DOCKER_HOST ]]; then
19+
sudo mkdir -p /etc/systemd/system/docker.service.d/
20+
21+
echo "
22+
[Service]
23+
ExecStart=
24+
ExecStart=/usr/bin/dockerd -H $DOCKER_HOST
25+
" | sudo tee -a /etc/systemd/system/docker.service.d/override.conf
26+
27+
sudo systemctl daemon-reload
28+
sudo service docker restart || sudo journalctl -xe
29+
sudo service docker status
30+
fi
31+
32+
while (! docker ps ); do
33+
echo "Waiting for Docker to launch..."
34+
sleep 1
35+
done
36+
docker version
37+
docker info
38+
39+
docker run --rm hello-world

.editorconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,8 @@ ij_java_names_count_to_use_import_on_demand = 9999
1616
[{*.pom,*.xml}]
1717
indent_style = tab
1818
ij_xml_attribute_wrap = off
19+
20+
21+
[*.{yaml,yml}]
22+
indent_size = 2
23+
ij_yaml_keep_indents_on_empty_lines = false

.github/workflows/ci.yml

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,41 @@
11
name: CI
22

3-
on: [push, pull_request]
3+
on:
4+
pull_request: {}
5+
push: { branches: [ master ] }
46

57
jobs:
68
build:
7-
runs-on: ubuntu-latest
9+
runs-on: ubuntu-18.04
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
include:
14+
- { name: "default" }
15+
- { name: "over TCP", dockerHost: "tcp://127.0.0.1:2375" }
16+
- { name: "Docker 18.06.3", dockerVersion: "18.06.3~ce~3-0~ubuntu" }
817

918
steps:
10-
- uses: actions/checkout@v1
11-
- name: Set up JDK 8
12-
uses: actions/setup-java@v1
13-
with:
14-
java-version: 8
15-
- name: Prepare ws
16-
run: rm -f "docker-java/src/test/resources/logback.xml" && mv "docker-java/src/test/resources/travis-logback.xml" "docker-java/src/test/resources/logback-test.xml"
17-
- name: Build with Maven
18-
run: ./mvnw --no-transfer-progress verify
19+
- uses: actions/checkout@v1
20+
- name: Set up JDK 8
21+
uses: actions/setup-java@v1
22+
with:
23+
java-version: 8
24+
- name: Configure Docker
25+
env:
26+
DOCKER_VERSION: ${{matrix.dockerVersion}}
27+
DOCKER_HOST: ${{matrix.dockerHost}}
28+
run: .ci/setup_docker.sh
29+
- name: Build with Maven
30+
env:
31+
DOCKER_HOST: ${{matrix.dockerHost}}
32+
run: ./mvnw --no-transfer-progress verify
33+
- name: Aggregate test reports with ciMate
34+
if: always()
35+
env:
36+
CIMATE_PROJECT_ID: lodr9d83
37+
CIMATE_CI_KEY: "CI / ${{matrix.name}}"
38+
run: |
39+
wget -q https://get.cimate.io/release/linux/cimate
40+
chmod +x cimate
41+
./cimate "**/TEST-*.xml"

.travis.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

.travis/travis-before-install.sh

Lines changed: 0 additions & 102 deletions
This file was deleted.

docker-java-api/src/main/java/com/github/dockerjava/api/command/PullImageResultCallback.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ private void checkDockerSwarmPullSuccessful() {
9090

9191
private void checkDockerClientPullSuccessful() {
9292
if (latestItem == null) {
93-
throw new DockerClientException("Could not pull image");
94-
} else if (!latestItem.isPullSuccessIndicated()) {
93+
return;
94+
}
95+
96+
if (!latestItem.isPullSuccessIndicated()) {
9597
throw new DockerClientException("Could not pull image: " + messageFromPullResult(latestItem));
9698
}
9799
}

docker-java-api/src/main/java/com/github/dockerjava/api/exception/DockerException.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ public class DockerException extends RuntimeException {
1313
private int httpStatus = 0;
1414

1515
public DockerException(String message, int httpStatus) {
16-
super(message);
16+
super(String.format("Status %d: %s", httpStatus, message));
1717
this.httpStatus = httpStatus;
1818
}
1919

2020
public DockerException(String message, int httpStatus, Throwable cause) {
21-
super(message, cause);
21+
super(String.format("Status %d: %s", httpStatus, message), cause);
22+
this.httpStatus = httpStatus;
2223
}
2324

2425
public int getHttpStatus() {

docker-java-core/src/main/java/com/github/dockerjava/core/DefaultDockerClientConfig.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class DefaultDockerClientConfig implements Serializable, DockerClientConf
5656

5757
private static final Set<String> CONFIG_KEYS = new HashSet<>();
5858

59-
private static final Properties DEFAULT_PROPERTIES = new Properties();
59+
static final Properties DEFAULT_PROPERTIES = new Properties();
6060

6161
static {
6262
CONFIG_KEYS.add(DOCKER_HOST);
@@ -168,13 +168,19 @@ private static Properties overrideDockerPropertiesWithEnv(Properties properties,
168168

169169
// special case which is a sensible default
170170
if (env.containsKey(DOCKER_HOST)) {
171-
overriddenProperties.setProperty(DOCKER_HOST, env.get(DOCKER_HOST));
171+
String value = env.get(DOCKER_HOST);
172+
if (value != null && value.trim().length() != 0) {
173+
overriddenProperties.setProperty(DOCKER_HOST, value);
174+
}
172175
}
173176

174177
for (Map.Entry<String, String> envEntry : env.entrySet()) {
175178
String envKey = envEntry.getKey();
176179
if (CONFIG_KEYS.contains(envKey)) {
177-
overriddenProperties.setProperty(envKey, envEntry.getValue());
180+
String value = envEntry.getValue();
181+
if (value != null && value.trim().length() != 0) {
182+
overriddenProperties.setProperty(envKey, value);
183+
}
178184
}
179185
}
180186

docker-java/pom.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@
111111
<version>4.13</version>
112112
<scope>test</scope>
113113
</dependency>
114+
<dependency>
115+
<groupId>org.awaitility</groupId>
116+
<artifactId>awaitility</artifactId>
117+
<version>4.0.1</version>
118+
</dependency>
114119
</dependencies>
115120

116121

@@ -142,7 +147,6 @@
142147
<trimStackTrace>false</trimStackTrace>
143148
<rerunFailingTestsCount>5</rerunFailingTestsCount>
144149
<groups>com.github.dockerjava.junit.category.Integration</groups>
145-
<excludedGroups>com.github.dockerjava.junit.category.AuthIntegration,com.github.dockerjava.junit.category.SwarmModeIntegration</excludedGroups>
146150
</configuration>
147151
</plugin>
148152

0 commit comments

Comments
 (0)