Skip to content

Commit

Permalink
add GitHub Actions workflow to verify builds and pull requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Okeanos committed Oct 16, 2022
1 parent 7414e90 commit 4fb1cb8
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 3 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -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/
48 changes: 45 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,26 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<version>3.10.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<source>1.6</source>
<target>1.6</target>
<toolchains>
<jdk>
<version>[1.6,)</version>
</jdk>
</toolchains>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -115,6 +131,32 @@
</distributionManagement>

<profiles>
<profile>
<id>java-6</id>
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
</profile>
<profile>
<id>legacy-java</id>
<activation>
<jdk>(,8]</jdk>
</activation>
<properties>
<maven.compiler.source>${java.specification.version}</maven.compiler.source>
<maven.compiler.target>${java.specification.version}</maven.compiler.target>
</properties>
</profile>
<profile>
<id>modern-java</id>
<activation>
<jdk>[9,)</jdk>
</activation>
<properties>
<maven.compiler.release>${java.specification.version}</maven.compiler.release>
</properties>
</profile>
<profile>
<id>release-sign-artifacts</id>
<activation>
Expand Down

0 comments on commit 4fb1cb8

Please sign in to comment.