Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port Travis to GHA #1396

Merged
merged 37 commits into from
May 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
fc3ade8
Port Swarm testing to GHA
bsideup May 22, 2020
0546ab2
fix
bsideup May 22, 2020
20401c5
do not fail fast
bsideup May 22, 2020
3a87691
remove "prepare WS"
bsideup May 22, 2020
e1f6902
Add ciMate
bsideup May 22, 2020
4056258
merge `before-install` and `mvn verify`
bsideup May 22, 2020
b66cade
Do not override the logging
bsideup May 22, 2020
230eee9
source `before-install`
bsideup May 22, 2020
cb9205a
Try `docker swarm init`
bsideup May 22, 2020
c0bad9a
Make `pushNonExistentImage` not depend on auth config
bsideup May 22, 2020
013ce98
Add ciMate to Travis
bsideup May 22, 2020
a4c1845
do not print summary from `failsafe` tests
bsideup May 22, 2020
a179725
use `mvn -q`
bsideup May 22, 2020
8c8b40c
try batch mode...
bsideup May 22, 2020
ff8263b
Redirect output...
bsideup May 22, 2020
cf98a6f
Backport more jobs
bsideup May 22, 2020
1698db2
Split Docker setup and test running
bsideup May 22, 2020
423bf9c
Remove name override
bsideup May 22, 2020
ebaefa8
pass `DOCKER_HOST` to `before-install.sh`
bsideup May 22, 2020
8fcedb9
Try Ubuntu 18, rework `before-install`
bsideup May 22, 2020
e086cd8
fix swarm installer
bsideup May 22, 2020
9c4da31
fix env name
bsideup May 22, 2020
2e087ee
Use Maven clean :D
bsideup May 22, 2020
2d6b1ca
Temporary disable custom registry
bsideup May 22, 2020
a19e4e6
debug
bsideup May 22, 2020
0149333
Delete `${HOME}/.docker-java.properties`
bsideup May 22, 2020
eeabcab
temporarily remove DOCKER_HOST
bsideup May 22, 2020
dadfcfa
debug
bsideup May 22, 2020
c9f3a92
handle empty env variables as "not set"
bsideup May 22, 2020
d86103f
fix the test
bsideup May 22, 2020
d5fba06
Do not fail on empty `latestItem`
bsideup May 23, 2020
df8f69b
Perform a smoke test after configuring Swarm
bsideup May 23, 2020
218a314
Try Docker Swarm Mode
bsideup May 23, 2020
a547193
cleanups
bsideup May 23, 2020
a3e386b
Bring back Swarm tests
bsideup May 23, 2020
ddca61c
Fix Swarm tests
bsideup May 23, 2020
764943a
Introduce `MultiNodeSwarmCmdIT`, drop "Swarm Mode" CI task
bsideup May 23, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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