From 4fb1cb87682d695b4f83907be7808141e1e35522 Mon Sep 17 00:00:00 2001 From: Nikolas Grottendieck Date: Sat, 15 Oct 2022 17:55:31 +0200 Subject: [PATCH] add GitHub Actions workflow to verify builds and pull requests --- .github/workflows/main.yml | 94 ++++++++++++++++++++++++++++++++++++++ pom.xml | 48 +++++++++++++++++-- 2 files changed, 139 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..cf235a56 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,94 @@ +# This workflow will build a Java project with Maven +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven + +name: Java CI with Maven + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +permissions: + contents: read + +jobs: + build-6: + runs-on: ubuntu-latest + name: Java 6 + steps: + - name: Check out Git repository + uses: actions/checkout@v3 + - name: Set up JDK + uses: actions/setup-java@master + with: + distribution: zulu + java-version: | + 6 + 11 + - name: Setup Maven + run: | + mkdir -p .mvn + echo "-B" > .mvn/maven.config + - name: Compile with Java 6 + run: mvn clean compile -Dmaven.toolchains.jdk.id=zulu_6 -P java-6,!legacy-java,!modern-java + - name: Run Tests with Java 6 + run: mvn test -Dmaven.toolchains.jdk.id=zulu_6 -P java-6,!legacy-java,!modern-java + - name: Build Test Report for Java 6 + if: ${{ always() }} + run: | + mvn surefire-report:report-only + mvn site -DgenerateReports=false + - name: Upload Test Results for Java 6 + if: ${{ always() }} + uses: actions/upload-artifact@v3 + with: + name: Test Results for Java 6 + path: target/surefire-reports/ + - name: Upload Test Report 6 + if: ${{ always() }} + uses: actions/upload-artifact@v3 + with: + name: Test Report for Java 6 + path: target/site/ + + build: + runs-on: ubuntu-latest + strategy: + matrix: + java: [ 8, 11, 17 ] + name: Java ${{ matrix.java }} + steps: + - name: Check out Git repository + uses: actions/checkout@v3 + # Set up an alternative JDK to be used with Maven; using master to support Toolchains Output + - name: Set up JDK + uses: actions/setup-java@master + with: + distribution: zulu + java-version: ${{ matrix.java }} + - name: Setup Maven + run: | + mkdir -p .mvn + echo "-B" > .mvn/maven.config + - name: Compile with Java ${{ matrix.java }} + run: mvn clean compile + - name: Run Tests with Java ${{ matrix.java }} + run: mvn test + - name: Build Test Report for Java ${{ matrix.java }} + if: ${{ always() }} + run: | + mvn surefire-report:report-only + mvn site -DgenerateReports=false + - name: Upload Test Results for Java ${{ matrix.java }} + if: ${{ always() }} + uses: actions/upload-artifact@v3 + with: + name: Test Results for Java ${{ matrix.java }} + path: target/surefire-reports/ + - name: Upload Test Report ${{ matrix.java }} + if: ${{ always() }} + uses: actions/upload-artifact@v3 + with: + name: Test Report for Java ${{ matrix.java }} + path: target/site/ diff --git a/pom.xml b/pom.xml index 19b055c2..644244e4 100644 --- a/pom.xml +++ b/pom.xml @@ -67,10 +67,26 @@ org.apache.maven.plugins maven-compiler-plugin - 2.3.1 + 3.10.1 + + + org.apache.maven.plugins + maven-toolchains-plugin + 3.1.0 + + + validate + + toolchain + + + - 1.6 - 1.6 + + + [1.6,) + + @@ -115,6 +131,32 @@ + + java-6 + + 1.6 + 1.6 + + + + legacy-java + + (,8] + + + ${java.specification.version} + ${java.specification.version} + + + + modern-java + + [9,) + + + ${java.specification.version} + + release-sign-artifacts