diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ed97d2c..9bc2132 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,30 +9,59 @@ jobs: build: name: Build runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + java_version: [ '11', '16' ] steps: + # Check out the project - uses: actions/checkout@v2 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: Set up JDK 11 - uses: actions/setup-java@v2.1.0 + + # Setup the version of Java + - name: Set up JDK ${{ matrix.java_version }} + uses: actions/setup-java@v2 with: - java-version: 11 + java-version: ${{ matrix.java_version }} distribution: 'adopt' check-latest: true + + # Cache all the things - name: Cache SonarCloud packages - uses: actions/cache@v2.1.6 + uses: actions/cache@v2.1.5 + if: ${{ env.SONAR_TOKEN != null && env.SONAR_TOKEN != '' && matrix.java_version == '11' }} + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} with: path: ~/.sonar/cache key: ${{ runner.os }}-sonar restore-keys: ${{ runner.os }}-sonar + - name: Cache Maven packages - uses: actions/cache@v2.1.6 + uses: actions/cache@v2.1.5 with: path: ~/.m2 key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-m2 - - name: Build and analyze + + # Compile the project + - name: Build + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + run: mvn -B -V compile + + # Run tests when Java version > 11 (Sonar runs tests and analysis on JDK 11) + - name: Run tests + if: ${{ matrix.java_version != '11' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + run: mvn -B -V verify + + # Run Sonar Analysis (on Java version 11 only) + - name: Analyze with SonarCloud + if: ${{ env.SONAR_TOKEN != null && env.SONAR_TOKEN != '' && matrix.java_version == '11' }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: mvn -B -Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml org.jacoco:jacoco-maven-plugin:prepare-agent package org.jacoco:jacoco-maven-plugin:report org.sonarsource.scanner.maven:sonar-maven-plugin:sonar + run: mvn -B -V -Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml org.jacoco:jacoco-maven-plugin:prepare-agent verify org.jacoco:jacoco-maven-plugin:report org.sonarsource.scanner.maven:sonar-maven-plugin:sonar diff --git a/pom.xml b/pom.xml index 2d63734..eb1c959 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ 1.5.1 - 2.13.0 + 5.1.0 0.15.0 2.0.22 6.1.7.Final @@ -44,7 +44,7 @@ 0.20.0 4.1.22 4.1.22 - 3.4.14 + 3.7.0 0.19.0 @@ -254,6 +254,10 @@ org.javassist javassist + + io.dropwizard.metrics + metrics-core + org.slf4j slf4j-api diff --git a/src/test/java/org/kiwiproject/curator/listener/CuratorListenersTest.java b/src/test/java/org/kiwiproject/curator/listener/CuratorListenersTest.java index 6f650c6..a15c37c 100644 --- a/src/test/java/org/kiwiproject/curator/listener/CuratorListenersTest.java +++ b/src/test/java/org/kiwiproject/curator/listener/CuratorListenersTest.java @@ -6,7 +6,7 @@ import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.api.CuratorEvent; import org.apache.curator.framework.listen.Listenable; -import org.apache.curator.framework.listen.ListenerContainer; +import org.apache.curator.framework.listen.StandardListenerManager; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -52,13 +52,13 @@ void shouldAddLoggingCuratorListener() { startAndSleepQuietly(); } - private ListenerContainer getListenerContainer(Listenable listenable) { - assertThat(listenable).isInstanceOf(ListenerContainer.class); - return (ListenerContainer) listenable; + private StandardListenerManager getListenerContainer(Listenable listenable) { + assertThat(listenable).isInstanceOf(StandardListenerManager.class); + return (StandardListenerManager) listenable; } @Test - void shouldAddLoggingConnectionStateListener() throws Exception { + void shouldAddLoggingConnectionStateListener() { var listenable = client.getConnectionStateListenable(); var listenerContainer = getListenerContainer(listenable); var initialCount = listenerContainer.size();