This repository has been archived by the owner on May 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
313 lines (305 loc) · 10.3 KB
/
main.yaml
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
name: Build
on:
push:
jobs:
build:
env:
DEBIAN_FRONTEND: noninteractive
runs-on: ubuntu-latest
steps:
- name: Checkout project sources
uses: actions/checkout@v4.1.4
- name: Setup java
uses: actions/setup-java@v4.2.1
with:
distribution: temurin
java-version: "21"
check-latest: true
- name: Setup gradle
uses: gradle/actions/setup-gradle@v3.3.2
with:
cache-read-only: false
- name: Setup build cache
uses: actions/cache@v4.0.2
with:
path: "**/build/"
key: classes-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
classes-${{ github.ref_name }}-
classes-main-${{ github.event.pull_request.base.sha }}
- name: Compile project
run: ./gradlew --no-daemon --warning-mode=all --info --configuration-cache --build-cache classes testClasses integrationTestsClasses assemble
- name: Upload server jar as an artifact
uses: actions/upload-artifact@v4.3.3
with:
name: jar-${{ github.sha }}
path: |
Dockerfile
runner/build/libs/
build-container-review:
if: "!contains(github.ref, 'main')"
env:
DEBIAN_FRONTEND: noninteractive
needs: build
runs-on: ubuntu-latest
steps:
- name: Download server jar artifact
uses: actions/download-artifact@v4.1.7
with:
name: jar-${{ github.sha }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.3.0
- name: Set branch variable
shell: bash
run: echo "BRANCH=$(echo -n "${GITHUB_REF_NAME}" | sed 's~\/~\-~g')" >> $GITHUB_ENV
- name: Set tag variable
shell: bash
run: echo "TAG_NAME=$(date +'%s')" >> $GITHUB_ENV
- name: Login to container registry
uses: docker/login-action@v3.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5.3.0
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/arm64,linux/amd64
provenance: false
push: true
tags: ghcr.io/${{ github.repository }}:${{ env.BRANCH }}-${{ env.TAG_NAME }}
unit-tests:
env:
DEBIAN_FRONTEND: noninteractive
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout project sources
uses: actions/checkout@v4.1.4
- name: Setup java
uses: actions/setup-java@v4.2.1
with:
distribution: temurin
java-version: "21"
check-latest: true
- name: Setup gradle
uses: gradle/actions/setup-gradle@v3.3.2
with:
cache-read-only: false
- name: Setup build cache
uses: actions/cache@v4.0.2
with:
path: "**/build/"
key: classes-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
classes-${{ github.ref_name }}-
classes-main-${{ github.event.pull_request.base.sha }}
- name: Run unit tests
run: ./gradlew --no-daemon --warning-mode=all --info --configuration-cache --build-cache testClasses test
- name: Upload unit tests result as an artifact
uses: actions/upload-artifact@v4.3.3
with:
name: tests_unit-${{ github.sha }}
path: |
**/build/jacoco/test.exec
**/build/test-results/test/*.xml
integration-tests:
needs: build
services:
mongo:
image: mongo:7.0.9
ports:
- 27017:27017
env:
MONGO_INITDB_ROOT_USERNAME: minigames
MONGO_INITDB_ROOT_PASSWORD: example
env:
DAYLIFECRAFT_SETTINGS_MONGODB_HOSTNAME: "127.0.0.1"
DAYLIFECRAFT_SETTINGS_MONGODB_PASSWORD: example
DEBIAN_FRONTEND: noninteractive
runs-on: ubuntu-latest
steps:
- name: Checkout project sources
uses: actions/checkout@v4.1.4
- name: Setup java
uses: actions/setup-java@v4.2.1
with:
distribution: temurin
java-version: "21"
check-latest: true
- name: Setup gradle
uses: gradle/actions/setup-gradle@v3.3.2
with:
cache-read-only: false
- name: Setup build cache
uses: actions/cache@v4.0.2
with:
path: "**/build/"
key: classes-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
classes-${{ github.ref_name }}-
classes-main-${{ github.event.pull_request.base.sha }}
- name: Run integration tests
run: ./gradlew --no-daemon --warning-mode=all --info --configuration-cache --build-cache integrationTestsClasses integration-tests
- name: Upload integration tests result as an artifact
uses: actions/upload-artifact@v4.3.3
with:
name: tests_integration-${{ github.sha }}
path: |
**/build/jacoco/integration-tests.exec
**/build/test-results/integration-tests/*.xml
detekt:
env:
DEBIAN_FRONTEND: noninteractive
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout project sources
uses: actions/checkout@v4.1.4
- name: Setup java
uses: actions/setup-java@v4.2.1
with:
distribution: temurin
java-version: "21"
check-latest: true
- name: Setup gradle
uses: gradle/actions/setup-gradle@v3.3.2
with:
cache-read-only: false
- name: Setup build cache
uses: actions/cache@v4.0.2
with:
path: "**/build/"
key: classes-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
classes-${{ github.ref_name }}-
classes-main-${{ github.event.pull_request.base.sha }}
- name: Run detekt
run: ./gradlew --no-daemon --warning-mode=all --info --configuration-cache --build-cache detekt
- name: Upload detekt report as an artifact
uses: actions/upload-artifact@v4.3.3
with:
name: detekt-${{ github.sha }}
path: "**/build/reports/detekt/detekt.xml"
ktlint:
if: "!contains(github.ref, 'main')"
env:
DEBIAN_FRONTEND: noninteractive
KTLINT_VERSION: "1.2.1"
runs-on: ubuntu-latest
steps:
- name: Checkout project sources
uses: actions/checkout@v4.1.4
- name: Setup java
uses: actions/setup-java@v4.2.1
with:
distribution: temurin
java-version: "21"
check-latest: true
- name: Setup ktlint cache
uses: actions/cache@v4.0.2
with:
path: "/usr/local/bin/ktlint-${{ env.KTLINT_VERSION }}"
key: ktlint-${{ env.KTLINT_VERSION }}
- name: Download ktlint
run: |
[[ -e /usr/local/bin/ktlint-${{ env.KTLINT_VERSION }} ]] || curl -L https://github.com/pinterest/ktlint/releases/download/${{ env.KTLINT_VERSION }}/ktlint -o /usr/local/bin/ktlint-${{ env.KTLINT_VERSION }} && chmod +x /usr/local/bin/ktlint-${{ env.KTLINT_VERSION }}
- name: Run ktlint
run: ktlint-${{ env.KTLINT_VERSION }}
jacoco:
env:
DEBIAN_FRONTEND: noninteractive
needs:
- unit-tests
- integration-tests
runs-on: ubuntu-latest
steps:
- name: Checkout project sources
uses: actions/checkout@v4.1.4
- name: Setup java
uses: actions/setup-java@v4.2.1
with:
distribution: temurin
java-version: "21"
check-latest: true
- name: Setup gradle
uses: gradle/actions/setup-gradle@v3.3.2
with:
cache-read-only: false
- name: Setup build cache
uses: actions/cache@v4.0.2
with:
path: "**/build/"
key: classes-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
classes-${{ github.ref_name }}-
classes-main-${{ github.event.pull_request.base.sha }}
- name: Download unit tests artifact
uses: actions/download-artifact@v4.1.7
with:
name: tests_unit-${{ github.sha }}
- name: Download integration tests artifact
uses: actions/download-artifact@v4.1.7
with:
name: tests_integration-${{ github.sha }}
- name: Run jacoco
run: ./gradlew --no-daemon --warning-mode=all --info --configuration-cache --build-cache jacocoTestReport
- name: Upload jacoco coverage report as an artifact
uses: actions/upload-artifact@v4.3.3
with:
name: jacoco-coverage-${{ github.sha }}
path: "**/build/reports/jacoco/test/jacocoTestReport.xml"
sonar:
env:
DEBIAN_FRONTEND: noninteractive
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
needs:
- unit-tests
- integration-tests
- jacoco
- detekt
runs-on: ubuntu-latest
steps:
- name: Checkout project sources
uses: actions/checkout@v4.1.4
with:
fetch-depth: 0
- name: Setup java
uses: actions/setup-java@v4.2.1
with:
distribution: temurin
java-version: "21"
check-latest: true
- name: Setup gradle
uses: gradle/actions/setup-gradle@v3.3.2
with:
cache-read-only: false
- name: Setup build cache
uses: actions/cache@v4.0.2
with:
path: "**/build/"
key: classes-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
classes-${{ github.ref_name }}-
classes-main-${{ github.event.pull_request.base.sha }}
- name: Download unit tests artifact
uses: actions/download-artifact@v4.1.7
with:
name: tests_unit-${{ github.sha }}
- name: Download integration tests artifact
uses: actions/download-artifact@v4.1.7
with:
name: tests_integration-${{ github.sha }}
- name: Download jacoco coverage report artifact
uses: actions/download-artifact@v4.1.7
with:
name: jacoco-coverage-${{ github.sha }}
- name: Download detekt report artifact
uses: actions/download-artifact@v4.1.7
with:
name: detekt-${{ github.sha }}
- name: Run sonar scan
run: ./gradlew --no-daemon --warning-mode=all --info --configuration-cache --build-cache testClasses integrationTestsClasses sonar