From 168bc9425c72bf2883c30e8b07ca243dfbbdf4fa Mon Sep 17 00:00:00 2001 From: "James R. Perkins" Date: Fri, 28 Jun 2024 11:32:34 -0700 Subject: [PATCH] Format the source and enable the check on CI. Signed-off-by: James R. Perkins --- .github/workflows/maven.yml | 18 +++++++++++++++++- .../testcontainers/TestContainer.java | 3 ++- .../testcontainers/TestContainerProvider.java | 2 +- .../testcontainers/TestContainersObserver.java | 7 ++++--- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 9e151a6..eab46cd 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -23,7 +23,23 @@ concurrency: cancel-in-progress: true jobs: - build-: + format-check: + runs-on: ubuntu-latest + timeout-minutes: 30 + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'temurin' + cache: 'maven' + - name: Validate Formatting + run: | + mvn -B validate -Pformat-check + build: + needs: format-check runs-on: ${{ matrix.os }} strategy: fail-fast: false diff --git a/src/main/java/org/jboss/arquillian/testcontainers/TestContainer.java b/src/main/java/org/jboss/arquillian/testcontainers/TestContainer.java index 39f04c8..690acdb 100644 --- a/src/main/java/org/jboss/arquillian/testcontainers/TestContainer.java +++ b/src/main/java/org/jboss/arquillian/testcontainers/TestContainer.java @@ -28,8 +28,9 @@ @Inherited @Documented @Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE}) +@Target({ ElementType.TYPE }) public @interface TestContainer { Class> value(); + boolean failIfNoDocker() default true; } diff --git a/src/main/java/org/jboss/arquillian/testcontainers/TestContainerProvider.java b/src/main/java/org/jboss/arquillian/testcontainers/TestContainerProvider.java index 81722d4..538e355 100644 --- a/src/main/java/org/jboss/arquillian/testcontainers/TestContainerProvider.java +++ b/src/main/java/org/jboss/arquillian/testcontainers/TestContainerProvider.java @@ -18,11 +18,11 @@ import java.lang.annotation.Annotation; +import org.jboss.arquillian.container.test.impl.enricher.resource.OperatesOnDeploymentAwareProvider; import org.jboss.arquillian.core.api.Instance; import org.jboss.arquillian.core.api.annotation.Inject; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.arquillian.test.spi.annotation.ClassScoped; -import org.jboss.arquillian.container.test.impl.enricher.resource.OperatesOnDeploymentAwareProvider; import org.testcontainers.containers.GenericContainer; public class TestContainerProvider extends OperatesOnDeploymentAwareProvider { diff --git a/src/main/java/org/jboss/arquillian/testcontainers/TestContainersObserver.java b/src/main/java/org/jboss/arquillian/testcontainers/TestContainersObserver.java index 2e1f855..8d0df51 100644 --- a/src/main/java/org/jboss/arquillian/testcontainers/TestContainersObserver.java +++ b/src/main/java/org/jboss/arquillian/testcontainers/TestContainersObserver.java @@ -18,7 +18,6 @@ import java.lang.reflect.Constructor; -import com.github.dockerjava.api.DockerClient; import org.jboss.arquillian.core.api.InstanceProducer; import org.jboss.arquillian.core.api.annotation.Inject; import org.jboss.arquillian.core.api.annotation.Observes; @@ -29,6 +28,8 @@ import org.testcontainers.DockerClientFactory; import org.testcontainers.containers.GenericContainer; +import com.github.dockerjava.api.DockerClient; + public class TestContainersObserver { @Inject @ClassScoped @@ -45,7 +46,7 @@ public void createContainer(@Observes(precedence = 500) BeforeClass beforeClass) final GenericContainer container = clazz.getConstructor().newInstance(); container.start(); containerWrapper.set(container); - } catch (Exception e) { //Clean up + } catch (Exception e) { // Clean up throw new RuntimeException(e); } } @@ -74,7 +75,7 @@ private void checkForDocker(boolean failIfNoDocker) { } private boolean isDockerAvailable() { - try(DockerClient client = DockerClientFactory.instance().client()) { + try (DockerClient client = DockerClientFactory.instance().client()) { return true; } catch (Throwable ex) { return false;