2424# This workflow will build a Java project with Maven
2525# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
2626
27+ # We are using two jobs here for testing our code on the latest JDK 11 build as well as a more satble build version of 11.0.3
28+ # You can see the full discussion here https://github.com/iluwatar/java-design-patterns/pull/1868#issue-1029459688
29+
2730name : Java CI
2831
2932on :
3336
3437jobs :
3538
36- build :
39+ # This Workflow Job will build this project and run Sonar analysis using JDK 11.0.3
40+ build-and-analyze :
3741
42+ name : Build and Run Sonar analysis on JDK 11.0.3
3843 runs-on : ubuntu-20.04
39- strategy :
40- matrix :
41- java-version : [ 11.0.3, 11 ]
4244 steps :
4345
4446 - name : Checkout Code
@@ -47,27 +49,21 @@ jobs:
4749 # Disabling shallow clone for improving relevancy of SonarQube reporting
4850 fetch-depth : 0
4951
50- - name : Set up JDK ${{ matrix.java-version }}
52+ - name : Set up JDK 11.0.3
5153 uses : actions/setup-java@v2
5254 with :
53- java-version : ${{ matrix.java-version }}
55+ java-version : 11.0.3
5456 distribution : ' zulu'
57+ cache : ' maven'
5558
59+ # Cache Sonar packages which as used to run anaylysis and collect metrics
5660 - name : Cache SonarCloud packages
5761 uses : actions/cache@v2
5862 with :
5963 path : ~/.sonar/cache
6064 key : ${{ runner.os }}-sonar
6165 restore-keys : ${{ runner.os }}-sonar
6266
63- - name : Cache Maven dependencies
64- uses : actions/cache@v2
65- with :
66- path : ~/.m2/repository
67- key : ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
68- restore-keys : |
69- ${{ runner.os }}-maven-
70-
7167 # Some tests need screen access
7268 - name : Install xvfb
7369 run : sudo apt-get install -y xvfb
7874 # These two env variables are needed for sonar analysis
7975 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
8076 SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
77+
78+
79+ # This Workflow Job is going to build the project on the latest stable JDK 11
80+ build :
81+
82+ name : Build and Test on JDK 11
83+ runs-on : ubuntu-20.04
84+ steps :
85+
86+ - name : Checkout Code
87+ uses : actions/checkout@v2
88+
89+ - name : Set up JDK 11 (Latest)
90+ uses : actions/setup-java@v2
91+ with :
92+ java-version : 11
93+ distribution : ' zulu'
94+ cache : ' maven'
95+
96+ # Some tests need screen access
97+ - name : Install xvfb
98+ run : sudo apt-get install -y xvfb
99+
100+ - name : Build with Maven
101+ run : xvfb-run ./mvnw clean verify
0 commit comments