1
+ # Description
2
+ # ===========
3
+ # This workflow is triggered each time
4
+ # commits are pushed to GitHub or a pull request is opened.
5
+ # It launches three jobs in parallel : a build with java 8,
6
+ # a build with java 11 and a SonarCloud analysis.
7
+ ---
8
+ name : Java CI
9
+
10
+ on : [push, pull_request]
11
+
12
+ jobs :
13
+
14
+ build :
15
+ runs-on : ubuntu-latest
16
+ name : Java 11 CI
17
+ steps :
18
+ - name : Check out repository code
19
+ uses : actions/checkout@v2
20
+ with :
21
+ fetch-depth : 0
22
+ - name : Setup java
23
+ uses : actions/setup-java@v2
24
+ with :
25
+ distribution : ' adopt'
26
+ java-version : 11
27
+ - name : Cache Maven packages
28
+ uses : actions/cache@v2
29
+ with :
30
+ path : ~/.m2
31
+ key : ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
32
+ restore-keys : ${{ runner.os }}-m2
33
+ - name : Cache node_modules
34
+ uses : actions/cache@v2
35
+ with :
36
+ path : node_modules
37
+ key : ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
38
+ restore-keys : ${{ runner.os }}-yarn-
39
+ - name : Build with Maven
40
+ run : mvn -B clean test package
41
+
42
+ code-analysis :
43
+ runs-on : ubuntu-latest
44
+ name : SonarCloud Code Analysis
45
+ # It's not possible to launch an analysis on external pull requests
46
+ if : ${{ github.repository_owner == 'cnescatlab' }}
47
+ steps :
48
+ - name : Check out repository code
49
+ uses : actions/checkout@v2
50
+ with :
51
+ fetch-depth : 0 # Shallow clones should be disabled for a better relevancy of analysis
52
+ - name : Setup java
53
+ uses : actions/setup-java@v2
54
+ with :
55
+ distribution : ' adopt'
56
+ java-version : ' 11'
57
+ - name : Cache Maven packages
58
+ uses : actions/cache@v2
59
+ with :
60
+ path : ~/.m2
61
+ key : ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
62
+ restore-keys : ${{ runner.os }}-m2
63
+ - name : Cache node_modules
64
+ uses : actions/cache@v2
65
+ with :
66
+ path : node_modules
67
+ key : ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
68
+ restore-keys : ${{ runner.os }}-yarn-
69
+ - name : Cache SonarCloud packages
70
+ uses : actions/cache@v2
71
+ with :
72
+ path : ~/.sonar/cache
73
+ key : ${{ runner.os }}-sonar
74
+ restore-keys : ${{ runner.os }}-sonar
75
+ - name : Build and analyze
76
+ env :
77
+ # Needed to get some information about the pull request, if any
78
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
79
+ # SonarCloud access token should be generated from https://sonarcloud.io/account/security/
80
+ SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
81
+ run : mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.organization=lequal -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=$SONAR_TOKEN
0 commit comments