-
-
Notifications
You must be signed in to change notification settings - Fork 302
74 lines (71 loc) · 2.36 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: Java CI with Maven
on:
push:
branches: [ main, 2.3.x, 2.4.x, 3.0.x, 3.1.x, 3.2.x ]
pull_request:
branches: [ main, 2.3.x, 2.4.x, 3.0.x, 3.1.x, 3.2.x ]
permissions:
contents: read
jobs:
build:
name: "Test with ${{ matrix.version }}"
strategy:
matrix:
version: [ 17.0.1-tem, 21-tem ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- 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-
- name: Download ${{ matrix.version }}
uses: sdkman/sdkman-action@master
id: sdkman
with:
candidate: java
version: ${{ matrix.version }}
- name: Set up ${{ matrix.version }}
uses: actions/setup-java@v1
with:
java-version: 8
jdkFile: ${{ steps.sdkman.outputs.file }}
- name: Build with Maven
run: ./mvnw -V -B verify -Pspring
sonar:
name: "Run Sonar Analysis"
runs-on: ubuntu-latest
# Disable Sonar for foreign PRs
if: (github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository))
steps:
- uses: actions/checkout@v4
- 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-
- name: Download JDK
uses: sdkman/sdkman-action@master
id: sdkman
with:
candidate: java
version: 17.0.1-tem
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 8
jdkFile: ${{ steps.sdkman.outputs.file }}
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Build with Maven
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./mvnw -V -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Pcoverage,spring