-
Notifications
You must be signed in to change notification settings - Fork 3
356 lines (293 loc) · 9.64 KB
/
ci.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
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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
name: CI
on:
workflow_call:
pull_request:
push:
branches:
- main
- '**docker'
tags:
- '*'
env:
MOCKINGBIRD_TEST_IMAGE_JVM: "ghcr.io/leviysoft/mockingbird:${{ github.run_number }}"
MOCKINGBIRD_TEST_IMAGE_NATIVE: "ghcr.io/leviysoft/mockingbird:${{ github.run_number }}-native"
jobs:
front-build:
runs-on: ubuntu-latest
env:
PORT: 3000
APP_ID: mockingbird
NODE_ENV: production
RELATIVE_PATH: /mockingbird
ASSETS_FOLDER_NAME: /assets
ASSETS_PREFIX: /mockingbird/assets/
MOCKINGBIRD_API: /api/internal/mockingbird
MOCKINGBIRD_EXEC_API: /api/mockingbird/exec
DEBUG_PLAIN: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Build
run: |
cd frontend
rm ./env.development.js
mkdir -p ./dist/out${ASSETS_FOLDER_NAME}
npm install
npm run build
- name: Copy output
run: |
cd frontend
cp -r ./dist/static${RELATIVE_PATH}/. ./dist/out
cp -a ./dist/client/. ./dist/out${ASSETS_FOLDER_NAME}
- name: Upload output directories
uses: actions/upload-artifact@v4
with:
name: front-static
path: frontend/dist/out
back-missinglink-check:
runs-on: ubuntu-latest
env:
SBT_OPTS: >
-Xms6g
-Xmx6g
-XX:+AlwaysPreTouch
-XX:ReservedCodeCacheSize=192M
-Xss2m
-XX:+TieredCompilation
-XX:+UseParallelGC
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
check-latest: true
- name: Compile and test
run: |
cd backend
sbt "project mockingbird-api;clean;missinglinkCheck;"
back-build:
needs: [front-build]
runs-on: ubuntu-latest
outputs:
ref: ${{ steps.get-ref.outputs.tag }}
env:
SBT_OPTS: >
-Xms2048m
-Xmx2048m
-XX:+AlwaysPreTouch
-XX:ReservedCodeCacheSize=256M
-Xss2m
-XX:+TieredCompilation
-XX:+UseParallelGC
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download frontend
uses: actions/download-artifact@v4
with:
name: front-static
path: frontend/dist/out
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
check-latest: true
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
version: "25.2"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Get the Ref
id: get-ref
uses: ankitvgupta/[email protected]
with:
ref: ${{ github.ref }}
head_ref: ${{ github.head_ref }}
- name: Compile and test
run: |
cd backend
sbt "project mockingbird-api;clean;fixCheck;test;Docker / stage;"
- name: Build docker image for test
uses: docker/build-push-action@v5
with:
context: ./backend/mockingbird-api/target/docker/stage
push: false
tags: ${{ env.MOCKINGBIRD_TEST_IMAGE_JVM }}
if: ${{ ! ( github.ref_type == 'tag' || endsWith(steps.get-ref.outputs.tag, 'docker') ) }}
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
if: ${{ github.ref_type == 'tag' || endsWith(steps.get-ref.outputs.tag, 'docker') }}
- name: Build and push docker image
uses: docker/build-push-action@v5
with:
context: ./backend/mockingbird-api/target/docker/stage
push: true
tags: ghcr.io/leviysoft/mockingbird:${{ steps.get-ref.outputs.tag }}
if: ${{ github.ref_type == 'tag' || endsWith(steps.get-ref.outputs.tag, 'docker') }}
- name: Save docker image to file
run: |
docker save -o /tmp/image-jvm.tar ${{ env.MOCKINGBIRD_TEST_IMAGE_JVM }}
gzip /tmp/image-jvm.tar
if: ${{ ! ( github.ref_type == 'tag' || endsWith(steps.get-ref.outputs.tag, 'docker') ) }}
- name: Upload image with JVM mockingbird
uses: actions/upload-artifact@v4
with:
name: image-jvm
path: /tmp/image-jvm.tar.gz
if: ${{ ! ( github.ref_type == 'tag' || endsWith(steps.get-ref.outputs.tag, 'docker') ) }}
back-build-native:
needs: [front-build]
runs-on: ubuntu-22.04
outputs:
ref: ${{ steps.get-ref.outputs.tag }}
env:
CI: true
SBT_OPTS: >
-Xms512m
-Xmx2048m
-XX:+AlwaysPreTouch
-XX:ReservedCodeCacheSize=192M
-Xss2m
-XX:+TieredCompilation
-XX:+UseParallelGC
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download frontend
uses: actions/download-artifact@v4
with:
name: front-static
path: frontend/dist/out
- uses: graalvm/setup-graalvm@v1
with:
java-version: '21'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: 'true'
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
version: "25.2"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Get the Ref
id: get-ref
uses: ankitvgupta/[email protected]
with:
ref: ${{ github.ref }}
head_ref: ${{ github.head_ref }}
- name: Lint and Test
run: |
cd backend
sbt "project mockingbird-native;clean;fixCheck;test"
- name: Create native image and stage image contents
run: |
cd backend
sbt "project mockingbird-native;GraalVMNativeImage / packageBin;Docker / stage;"
- name: Build docker image for test
uses: docker/build-push-action@v5
with:
context: ./backend/mockingbird-native/target/docker/stage
push: false
tags: ${{ env.MOCKINGBIRD_TEST_IMAGE_NATIVE }}
if: ${{ ! ( github.ref_type == 'tag' || endsWith(steps.get-ref.outputs.tag, 'docker') ) }}
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
if: ${{ github.ref_type == 'tag' || endsWith(steps.get-ref.outputs.tag, 'docker') }}
- name: Build and push docker image
uses: docker/build-push-action@v5
with:
context: ./backend/mockingbird-native/target/docker/stage
push: true
tags: ghcr.io/leviysoft/mockingbird:${{ steps.get-ref.outputs.tag }}-native
if: ${{ github.ref_type == 'tag' || endsWith(steps.get-ref.outputs.tag, 'docker')}}
- name: Save docker image to file
run: |
docker save -o /tmp/image-native.tar ${{ env.MOCKINGBIRD_TEST_IMAGE_NATIVE }}
gzip /tmp/image-native.tar
if: ${{ ! ( github.ref_type == 'tag' || endsWith(steps.get-ref.outputs.tag, 'docker') ) }}
- name: Upload image with native mockingbird
uses: actions/upload-artifact@v4
with:
name: image-native
path: /tmp/image-native.tar.gz
if: ${{ ! ( github.ref_type == 'tag' || endsWith(steps.get-ref.outputs.tag, 'docker') ) }}
test-jvm-image:
needs: [back-build]
if: ${{ ! ( github.ref_type == 'tag' || endsWith(needs.back-build.outputs.ref, 'docker') ) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: image-jvm
path: /tmp
- name: Load docker image
run: |
gzip -d /tmp/image-jvm.tar.gz
docker load --input /tmp/image-jvm.tar
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
check-latest: true
- name: Test docker image
env:
MOCKINGBIRD_IMAGE: ${{ env.MOCKINGBIRD_TEST_IMAGE_JVM }}
run: |
cd backend
envsubst < compose-test.yml.jvm.tmpl > compose-test.yml
sbt "project examples; clean; fixCheck; test"
test-native-image:
needs: [back-build-native]
if: ${{ ! ( github.ref_type == 'tag' || endsWith(needs.back-build-native.outputs.ref, 'docker') ) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: image-native
path: /tmp
- name: Load docker image
run: |
gzip -d /tmp/image-native.tar.gz
docker load --input /tmp/image-native.tar
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
check-latest: true
- name: Test docker image
env:
MOCKINGBIRD_IMAGE: ${{ env.MOCKINGBIRD_TEST_IMAGE_NATIVE }}
run: |
cd backend
envsubst < compose-test.yml.native.tmpl > compose-test.yml
sbt "project examples; clean; fixCheck; test"
test-example-dsl:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
check-latest: true
- name: Run
run: |
cd backend
sbt "project edsl; clean; fixCheck; test"