Skip to content

Commit

Permalink
Port Travis to GHA (#1396)
Browse files Browse the repository at this point in the history
- removes Travis config
- adds "Docker 18.x" and "Docker over TCP" to GHA Build Matrix
- adds ciMate
- Fixes Swarm tests
  • Loading branch information
bsideup committed May 23, 2020
1 parent 3674117 commit a09fefe
Show file tree
Hide file tree
Showing 27 changed files with 338 additions and 404 deletions.
File renamed without changes.
39 changes: 39 additions & 0 deletions .ci/setup_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash

set -exu

DOCKER_VERSION="${DOCKER_VERSION:-}"
DOCKER_HOST="${DOCKER_HOST:-}"

if [[ -n $DOCKER_VERSION ]]; then
sudo -E apt-get -q -y --purge remove docker-engine docker-ce

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-cache madison docker-ce
sudo apt-get install "docker-ce=$DOCKER_VERSION"
fi

if [[ -n $DOCKER_HOST ]]; then
sudo mkdir -p /etc/systemd/system/docker.service.d/

echo "
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H $DOCKER_HOST
" | sudo tee -a /etc/systemd/system/docker.service.d/override.conf

sudo systemctl daemon-reload
sudo service docker restart || sudo journalctl -xe
sudo service docker status
fi

while (! docker ps ); do
echo "Waiting for Docker to launch..."
sleep 1
done
docker version
docker info

docker run --rm hello-world
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ ij_java_names_count_to_use_import_on_demand = 9999
[{*.pom,*.xml}]
indent_style = tab
ij_xml_attribute_wrap = off


[*.{yaml,yml}]
indent_size = 2
ij_yaml_keep_indents_on_empty_lines = false
45 changes: 34 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,41 @@
name: CI

on: [push, pull_request]
on:
pull_request: {}
push: { branches: [ master ] }

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-18.04
strategy:
fail-fast: false
matrix:
include:
- { name: "default" }
- { name: "over TCP", dockerHost: "tcp://127.0.0.1:2375" }
- { name: "Docker 18.06.3", dockerVersion: "18.06.3~ce~3-0~ubuntu" }

steps:
- uses: actions/checkout@v1
- name: Set up JDK 8
uses: actions/setup-java@v1
with:
java-version: 8
- name: Prepare ws
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"
- name: Build with Maven
run: ./mvnw --no-transfer-progress verify
- uses: actions/checkout@v1
- name: Set up JDK 8
uses: actions/setup-java@v1
with:
java-version: 8
- name: Configure Docker
env:
DOCKER_VERSION: ${{matrix.dockerVersion}}
DOCKER_HOST: ${{matrix.dockerHost}}
run: .ci/setup_docker.sh
- name: Build with Maven
env:
DOCKER_HOST: ${{matrix.dockerHost}}
run: ./mvnw --no-transfer-progress verify
- name: Aggregate test reports with ciMate
if: always()
env:
CIMATE_PROJECT_ID: lodr9d83
CIMATE_CI_KEY: "CI / ${{matrix.name}}"
run: |
wget -q https://get.cimate.io/release/linux/cimate
chmod +x cimate
./cimate "**/TEST-*.xml"
39 changes: 0 additions & 39 deletions .travis.yml

This file was deleted.

102 changes: 0 additions & 102 deletions .travis/travis-before-install.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ private void checkDockerSwarmPullSuccessful() {

private void checkDockerClientPullSuccessful() {
if (latestItem == null) {
throw new DockerClientException("Could not pull image");
} else if (!latestItem.isPullSuccessIndicated()) {
return;
}

if (!latestItem.isPullSuccessIndicated()) {
throw new DockerClientException("Could not pull image: " + messageFromPullResult(latestItem));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ public class DockerException extends RuntimeException {
private int httpStatus = 0;

public DockerException(String message, int httpStatus) {
super(message);
super(String.format("Status %d: %s", httpStatus, message));
this.httpStatus = httpStatus;
}

public DockerException(String message, int httpStatus, Throwable cause) {
super(message, cause);
super(String.format("Status %d: %s", httpStatus, message), cause);
this.httpStatus = httpStatus;
}

public int getHttpStatus() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class DefaultDockerClientConfig implements Serializable, DockerClientConf

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

private static final Properties DEFAULT_PROPERTIES = new Properties();
static final Properties DEFAULT_PROPERTIES = new Properties();

static {
CONFIG_KEYS.add(DOCKER_HOST);
Expand Down Expand Up @@ -168,13 +168,19 @@ private static Properties overrideDockerPropertiesWithEnv(Properties properties,

// special case which is a sensible default
if (env.containsKey(DOCKER_HOST)) {
overriddenProperties.setProperty(DOCKER_HOST, env.get(DOCKER_HOST));
String value = env.get(DOCKER_HOST);
if (value != null && value.trim().length() != 0) {
overriddenProperties.setProperty(DOCKER_HOST, value);
}
}

for (Map.Entry<String, String> envEntry : env.entrySet()) {
String envKey = envEntry.getKey();
if (CONFIG_KEYS.contains(envKey)) {
overriddenProperties.setProperty(envKey, envEntry.getValue());
String value = envEntry.getValue();
if (value != null && value.trim().length() != 0) {
overriddenProperties.setProperty(envKey, value);
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion docker-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@
<version>4.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>4.0.1</version>
</dependency>
</dependencies>


Expand Down Expand Up @@ -142,7 +147,6 @@
<trimStackTrace>false</trimStackTrace>
<rerunFailingTestsCount>5</rerunFailingTestsCount>
<groups>com.github.dockerjava.junit.category.Integration</groups>
<excludedGroups>com.github.dockerjava.junit.category.AuthIntegration,com.github.dockerjava.junit.category.SwarmModeIntegration</excludedGroups>
</configuration>
</plugin>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.UUID;
import java.util.concurrent.TimeUnit;

import static com.github.dockerjava.utils.TestUtils.getVersion;
Expand All @@ -30,15 +31,12 @@ public class PushImageCmdIT extends CmdIT {
@ClassRule
public static PrivateRegistryRule REGISTRY = new PrivateRegistryRule();

private String username;

@Rule
public ExpectedException exception = ExpectedException.none();
private AuthConfig authConfig;

@Before
public void beforeTest() throws Exception {
username = dockerRule.getClient().authConfig().getUsername();
authConfig = REGISTRY.getAuthConfig();
}

Expand Down Expand Up @@ -81,7 +79,7 @@ public void pushNonExistentImage() throws Exception {
exception.expect(NotFoundException.class);
}

dockerRule.getClient().pushImageCmd(username + "/xxx")
dockerRule.getClient().pushImageCmd("local/" + UUID.randomUUID().toString().replace("-", ""))
.start()
.awaitCompletion(30, TimeUnit.SECONDS); // exclude infinite await sleep

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.github.dockerjava.api.exception.DockerException;
import com.github.dockerjava.api.model.Secret;
import com.github.dockerjava.api.model.SecretSpec;
import com.github.dockerjava.api.model.SwarmSpec;
import com.google.common.collect.Lists;
import org.apache.commons.lang.RandomStringUtils;
import org.hamcrest.collection.IsCollectionWithSize;
Expand All @@ -20,15 +19,9 @@
public class CreateSecretCmdExecIT extends SwarmCmdIT {

public static final Logger LOG = LoggerFactory.getLogger(CreateSecretCmdExecIT.class);
private static final String SERVICE_NAME = "theservice";

@Test
public void testCreateSecret() throws DockerException {
dockerRule.getClient().initializeSwarmCmd(new SwarmSpec())
.withListenAddr("127.0.0.1")
.withAdvertiseAddr("127.0.0.1")
.exec();

int length = 10;
boolean useLetters = true;
boolean useNumbers = false;
Expand Down

0 comments on commit a09fefe

Please sign in to comment.