-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplified workflow using matrix strategy
Implement a matrix strategy to run the builds with multiple Java versions in a single job.
- Loading branch information
1 parent
deb4289
commit 95d8078
Showing
1 changed file
with
24 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,39 @@ | ||
# this build is designed to replicate the Travis CI workflow | ||
name: Java CI with Maven | ||
name: Build with Maven | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ "master" ] | ||
branches: [ master ] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
java-8: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
java-version: [8, 11, 17] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 8 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '8' | ||
distribution: 'adopt' | ||
cache: maven | ||
- name: Build with Maven | ||
run: mvn clean install --file pom.xml | ||
|
||
java-11: | ||
|
||
runs-on: ubuntu-latest | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v3 | ||
- name: Set up JDK ${{ matrix.java-version }} | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '11' | ||
distribution: 'adopt' | ||
cache: maven | ||
- name: Build with Maven | ||
run: mvn clean install --file pom.xml | ||
java-version: ${{ matrix.java-version }} | ||
distribution: 'temurin' | ||
|
||
java-17: | ||
- name: Cache local Maven repository | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: | | ||
${{ runner.os }}-maven- | ||
runs-on: ubuntu-latest | ||
- name: Install dependencies | ||
run: mvn clean install -DskipTests=true -Dmaven.javadoc.skip=true --batch-mode --show-version --file pom.xml | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'adopt' | ||
cache: maven | ||
- name: Build with Maven | ||
run: mvn clean install --file pom.xml | ||
run: mvn test --batch-mode --file pom.xml |