From 73c012f86b0ca6e9f5b0a4ef3a194a2e024df57e Mon Sep 17 00:00:00 2001 From: "James R. Perkins" Date: Fri, 28 Jun 2024 11:30:06 -0700 Subject: [PATCH 1/2] Enable automatic source formatting via Maven plugins. Signed-off-by: James R. Perkins --- .github/workflows/maven.yml | 30 +++++++++-- pom.xml | 103 ++++++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+), 3 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 9e151a6..100e678 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -23,13 +23,13 @@ concurrency: cancel-in-progress: true jobs: - build-: + build: runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-latest, windows-latest ] - java: ['11', '17', '21'] + java: ['17', '21'] steps: - uses: actions/checkout@v4 @@ -40,7 +40,31 @@ jobs: distribution: 'temurin' cache: 'maven' - name: Build with Maven Java ${{ matrix.java }} - run: mvn -B clean verify + run: mvn -B -ntp clean verify + - uses: actions/upload-artifact@v4 + if: failure() + with: + name: surefire-reports-${{ matrix.os }}-${{ matrix.java }} + path: '**/surefire-reports/*' + test-java11: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest ] + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK ${{ matrix.java }} + uses: actions/setup-java@v4 + with: + java-version: | + 11 + 17 + distribution: 'temurin' + cache: 'maven' + - name: Build with Maven Java ${{ matrix.java }} + run: mvn -B -ntp clean verify '-Djava11.home="${{env.JAVA_HOME_11_X64}}"' - uses: actions/upload-artifact@v4 if: failure() with: diff --git a/pom.xml b/pom.xml index de129d1..8fef7ba 100644 --- a/pom.xml +++ b/pom.xml @@ -65,8 +65,20 @@ + 11 + 17 + + 1.8.0.Final 1.19.8 + + + 2.23.0 + 1.11.0 + + + false + true @@ -124,7 +136,98 @@ true + + + net.revelc.code.formatter + formatter-maven-plugin + ${version.formatter.maven.plugin} + + + org.wildfly.tools + ide-config + 1.0.4.Final + + + + + .cache + eclipse-code-formatter.xml + wildfly-xml.properties + LF + true + true + ${skipFormatting} + + + + format + + format + + process-sources + + + + + net.revelc.code + impsort-maven-plugin + ${version.impsort.maven.plugin} + + + .cache + java.,javax.,jakarta.,org.,com. + * + ${skipFormatting} + true + + + + sort-imports + + sort + + process-sources + + + + + + + format-check + + + + + net.revelc.code.formatter + formatter-maven-plugin + + + validate-format + validate + + validate + + + + + + net.revelc.code + impsort-maven-plugin + + + check-import-sort + validate + + check + + + + + + + + From a0a5e885ee4f7f70b9d9b0521c4bee2ae8d680fe Mon Sep 17 00:00:00 2001 From: "James R. Perkins" Date: Fri, 28 Jun 2024 11:32:34 -0700 Subject: [PATCH 2/2] Format the source and enable the check on CI. Signed-off-by: James R. Perkins --- .github/workflows/maven.yml | 19 ++++++++++++++++++- .../testcontainers/TestContainer.java | 3 ++- .../testcontainers/TestContainerProvider.java | 2 +- .../TestContainersObserver.java | 7 ++++--- 4 files changed, 25 insertions(+), 6 deletions(-) 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;