-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (117 loc) · 4.15 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: build
on:
push:
branches:
- main
pull_request:
types: [ opened, synchronize, reopened ]
jobs:
build-service:
name: Build Service
runs-on: ubuntu-latest
defaults:
run:
working-directory: service
strategy:
fail-fast: false
matrix:
java_version: [ '17', '21' ]
steps:
# Check out the project
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
# Setup the version of Java
- name: Set up JDK ${{ matrix.java_version }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java_version }}
distribution: 'zulu'
check-latest: true
# Cache all the things
- name: Cache SonarCloud packages
uses: actions/cache@v4
if: ${{ env.SONAR_TOKEN != null && env.SONAR_TOKEN != '' && matrix.java_version == '17' }}
env:
SONAR_TOKEN: ${{ secrets.SERVICE_SONAR_TOKEN }}
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
# Compile the project
- name: Compile service
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
run: mvn -B -V compile
# Run the tests
- name: Run service tests
if: ${{ matrix.java_version != '17' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
run: mvn -B -V verify
# Run Sonar Analysis
- name: Analyze with SonarCloud on service
if: ${{ env.SONAR_TOKEN != null && env.SONAR_TOKEN != '' && matrix.java_version == '17' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SERVICE_SONAR_TOKEN }}
run: mvn -B -V -Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml org.jacoco:jacoco-maven-plugin:prepare-agent verify org.jacoco:jacoco-maven-plugin:report org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
build-ui:
name: Build UI
runs-on: ubuntu-latest
defaults:
run:
working-directory: ui
strategy:
fail-fast: false
matrix:
node_version: [ '18', '20' ]
steps:
# Check out the project
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
# Setup Node/JS
- uses: actions/setup-node@v4
with:
node_version: ${{ matrix.node_version }}
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
# Cache all the things
- name: Cache SonarCloud packages
uses: actions/cache@v4
if: ${{ env.SONAR_TOKEN != null && env.SONAR_TOKEN != ''&& matrix.node_version == '18' }}
env:
SONAR_TOKEN: ${{ secrets.UI_SONAR_TOKEN }}
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
# Install dependencies
- name: Install Dependencies
run: npm install
# Compile the project
- name: Build ui
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
run: npm run build
# Run the tests
- name: Run ui tests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
run: npm run test:unit
# Run Sonar Analysis
- name: SonarCloud Scan
if: ${{ env.SONAR_TOKEN != null && env.SONAR_TOKEN != '' && matrix.node_version == '18' }}
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.UI_SONAR_TOKEN }}
with:
projectBaseDir: ui