From ac8791f3f0d9ecb8be4b118a091f1d26795188d7 Mon Sep 17 00:00:00 2001 From: Chris Rohr <51920+chrisrohr@users.noreply.github.com> Date: Thu, 15 Apr 2021 08:21:40 -0400 Subject: [PATCH] Update build to support Java 11 and 16 Also add github actions to the dependabot config Closes #77 Closes #78 --- .github/dependabot.yml | 10 ++++++++ .github/workflows/build.yml | 51 +++++++++++++++++++++++++++++-------- 2 files changed, 51 insertions(+), 10 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index decc0a4..3647e7c 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -17,3 +17,13 @@ updates: - dependency-name: "org.assertj:assertj-core" - dependency-name: "org.junit.jupiter:*" - dependency-name: "org.mockito:mockito-core" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + assignees: + - "sleberknight" + - "chrisrohr" + reviewers: + - "sleberknight" + - "chrisrohr" \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9baf880..22fc24b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,28 +9,59 @@ jobs: build: name: Build runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + java_version: ['11', '16'] steps: - - uses: actions/checkout@v2 + # Check out the project + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + + # Setup the version of Java + - name: Set up JDK ${{ matrix.java_version }} + uses: actions/setup-java@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@v1 - 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@v1 + 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@v1 + 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