24
24
# This workflow will build a Java project with Maven
25
25
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
26
26
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
+
27
30
name : Java CI
28
31
29
32
on :
33
36
34
37
jobs :
35
38
36
- build :
39
+ # This Workflow Job will build this project and run Sonar analysis using JDK 11.0.3
40
+ build-and-analyze :
37
41
42
+ name : Build and Run Sonar analysis on JDK 11.0.3
38
43
runs-on : ubuntu-20.04
39
- strategy :
40
- matrix :
41
- java-version : [ 11.0.3, 11 ]
42
44
steps :
43
45
44
46
- name : Checkout Code
@@ -47,27 +49,21 @@ jobs:
47
49
# Disabling shallow clone for improving relevancy of SonarQube reporting
48
50
fetch-depth : 0
49
51
50
- - name : Set up JDK ${{ matrix.java-version }}
52
+ - name : Set up JDK 11.0.3
51
53
uses : actions/setup-java@v2
52
54
with :
53
- java-version : ${{ matrix.java-version }}
55
+ java-version : 11.0.3
54
56
distribution : ' zulu'
57
+ cache : ' maven'
55
58
59
+ # Cache Sonar packages which as used to run anaylysis and collect metrics
56
60
- name : Cache SonarCloud packages
57
61
uses : actions/cache@v2
58
62
with :
59
63
path : ~/.sonar/cache
60
64
key : ${{ runner.os }}-sonar
61
65
restore-keys : ${{ runner.os }}-sonar
62
66
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
-
71
67
# Some tests need screen access
72
68
- name : Install xvfb
73
69
run : sudo apt-get install -y xvfb
78
74
# These two env variables are needed for sonar analysis
79
75
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
80
76
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