diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 100e678..2aaf2eb 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -23,7 +23,23 @@ concurrency: cancel-in-progress: true jobs: + 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 -ntp validate -Pformat-check build: + needs: format-check runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -47,6 +63,7 @@ jobs: name: surefire-reports-${{ matrix.os }}-${{ matrix.java }} path: '**/surefire-reports/*' test-java11: + needs: format-check runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -69,4 +86,4 @@ jobs: if: failure() with: name: surefire-reports-${{ matrix.os }}-${{ matrix.java }} - path: '**/surefire-reports/*' \ No newline at end of file + path: '**/surefire-reports/*' 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;