-
Notifications
You must be signed in to change notification settings - Fork 21
351 lines (290 loc) · 10.9 KB
/
build-and-test.yml
File metadata and controls
351 lines (290 loc) · 10.9 KB
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
name: Build and Test
on:
merge_group:
types: [ checks_requested ]
pull_request:
branches:
- main
push:
branches:
- main
env:
GRADLE_OPTS: -Dorg.gradle.daemon=false
jobs:
build:
runs-on: ubuntu-24.04
steps:
- name: Checkout Repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Setup Gradle
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
- name: Build all classes
run: ./gradlew --stacktrace classes
build-cli:
strategy:
matrix:
target:
- name: 'Linux x64'
os: ubuntu-24.04
task: 'linkReleaseExecutableLinuxX64'
artifact: 'osc-cli-linux-x64'
buildPath: 'cli/build/bin/linuxX64/releaseExecutable/osc.kexe'
binName: 'osc'
- name: 'macOS arm64'
os: macos-15
task: 'linkReleaseExecutableMacosArm64'
artifact: 'osc-cli-macos-arm64'
buildPath: 'cli/build/bin/macosArm64/releaseExecutable/osc.kexe'
binName: 'osc'
- name: 'macOS x64'
os: macos-15-intel
task: 'linkReleaseExecutableMacosX64'
artifact: 'osc-cli-macos-x64'
buildPath: 'cli/build/bin/macosX64/releaseExecutable/osc.kexe'
binName: 'osc'
- name: 'Windows x64'
os: windows-2025
task: 'linkReleaseExecutableMingwX64'
artifact: 'osc-cli-windows-x64'
buildPath: 'cli/build/bin/mingwX64/releaseExecutable/osc.exe'
binName: 'osc.exe'
name: Build ${{ matrix.target.name }} CLI
runs-on: ${{ matrix.target.os }}
steps:
- name: Checkout Repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Setup Java
if: runner.os == 'Windows'
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
distribution: temurin
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
- name: Get the Kotlin version
id: get-kotlin-plugin-info
shell: bash
run: echo "info=$(./gradlew -q :cli:properties | grep kotlin.plugin.loaded.in.projects)" >> $GITHUB_OUTPUT
- name: Cache the .konan directory
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/.konan
key: ${{ steps.get-kotlin-plugin-info.outputs.info }}
- name: Build CLI - ${{ matrix.target.name }}
run: ./gradlew --scan --stacktrace cli:${{ matrix.target.task }}
- name: Rename CLI binary
shell: bash
run: |
mkdir -p ${{ matrix.target.artifact }}
mv ${{ matrix.target.buildPath }} ${{ matrix.target.artifact }}/${{ matrix.target.binName }}
- name: Run CLI binary
run: ./${{ matrix.target.artifact }}/${{ matrix.target.binName }} --version
- name: Upload CLI binary
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ matrix.target.artifact }}
path: ${{ matrix.target.artifact }}/${{ matrix.target.binName }}
retention-days: 7
build-ui:
runs-on: ubuntu-24.04
steps:
- name: Checkout Repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Setup Gradle
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
- name: Generate OpenAPI spec
run: ./gradlew --stacktrace :core:generateOpenApiSpec
- name: Install Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 24
cache-dependency-path: ui/pnpm-lock.yaml
- name: Enable Corepack
run: corepack enable
- name: Install dependencies
working-directory: ui
run: pnpm install
- name: Build UI
working-directory: ui
run: pnpm build
- name: Test UI
working-directory: ui
run: pnpm test
test:
needs: build
runs-on: ubuntu-24.04
steps:
- name: Checkout Repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Setup Gradle
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
- name: Run tests
run: ./gradlew --scan test allTests -Dkotest.tags='!Authorization & !Integration'
- name: Create Test Summary
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4
with:
paths: "**/test-results/**/TEST-*.xml"
if: success() || failure()
- name: Upload test results
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: success() || failure()
with:
name: test-results
path: "**/build/reports/tests"
retention-days: 7
authorization-test:
needs: build
runs-on: ubuntu-24.04
steps:
- name: Checkout Repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Setup Gradle
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
- name: Run authorization tests
run: ./gradlew --scan test allTests -Dkotest.tags='Authorization'
- name: Create Test Summary
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4
with:
paths: "**/test-results/**/TEST-*.xml"
if: success() || failure()
- name: Upload test results
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: success() || failure()
with:
name: authorization-test-results
path: "**/build/reports/tests"
retention-days: 7
integration-test:
needs: build
runs-on: ubuntu-24.04
steps:
- name: Checkout Repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Setup Gradle
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
- name: Run integration tests
run: ./gradlew --scan test allTests -Dkotest.tags='Integration'
- name: Create Test Summary
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4
with:
paths: "**/test-results/**/TEST-*.xml"
if: success() || failure()
- name: Upload test results
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: success() || failure()
with:
name: integration-test-results
path: "**/build/reports/tests"
retention-days: 7
publication-test:
needs: build
runs-on: ubuntu-24.04
steps:
- name: Checkout Repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Setup Gradle
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
- name: Publish to local Maven repository
run: ./gradlew publishToMavenLocal
test-ui-e2e:
runs-on: ubuntu-24.04
steps:
- name: Checkout Repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Setup Gradle
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
- name: Generate OpenAPI spec
run: ./gradlew --stacktrace :core:generateOpenApiSpec
- name: Install Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 24
cache-dependency-path: ui/pnpm-lock.yaml
- name: Enable Corepack
run: corepack enable
- name: Install dependencies
working-directory: ui
run: pnpm install
- name: Generate API client and routes
working-directory: ui
run: pnpm generate:api && pnpm generate:routes
- name: Install Playwright Browsers
working-directory: ui
run: pnpm exec playwright install --with-deps
- name: Start core services
run: docker compose up -d core
- name: Wait for core readiness
run: |
echo "Waiting for core liveness endpoint..."
for i in {1..60}; do
if curl -fsS http://127.0.0.1:8080/api/v1/liveness >/dev/null; then
echo "Core liveness endpoint is available."
break
fi
if [ $i -eq 60 ]; then
echo "Core failed to report healthy within 120 seconds" >&2
docker compose logs core
exit 1
fi
sleep 2
done
- name: Run Playwright tests
env:
VITE_UI_URL: http://127.0.0.1:8082/
VITE_CLIENT_ID: ort-server-ui
working-directory: ui
run: |
# Exit on error, undefined variables, and pipe failures
set -euo pipefail
# Start the Vite dev server in the background
# The dev server is needed because Playwright tests run against a live server
pnpm dev --host 0.0.0.0 --port 8082 > ui-dev.log 2>&1 &
UI_DEV_PID=$!
# Set up cleanup to ensure the background dev server process is killed on exit
# This prevents process leaks even if the workflow fails or is cancelled
cleanup() {
if ps -p $UI_DEV_PID > /dev/null 2>&1; then
kill $UI_DEV_PID || true
fi
}
trap cleanup EXIT
echo "Waiting for UI dev server to be ready on http://localhost:8082 ..."
for i in {1..60}; do
# Fail fast if the dev server crashes - this provides better error messages
# than waiting for the timeout with no logs
if ! ps -p $UI_DEV_PID > /dev/null 2>&1; then
echo "UI dev server process exited unexpectedly. Recent logs:"
tail -n 200 ui-dev.log || true
exit 1
fi
# Check if Vite has finished building by looking for the ready message in the log
if grep -q "ready in" ui-dev.log 2>/dev/null; then
# Also verify the server actually returns HTML content
if curl -fsS http://127.0.0.1:8082 2>/dev/null | grep -q "<html"; then
echo "UI dev server is ready."
break
fi
fi
if [ $i -eq 60 ]; then
echo "UI dev server failed to become ready within 120 seconds" >&2
echo "Last 200 lines of UI dev log:"
tail -n 200 ui-dev.log || true
exit 1
fi
sleep 2
done
pnpm test:e2e
- name: Upload UI dev log
if: success() || failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ui-dev-log
path: ui-dev.log
retention-days: 7
- name: Upload Playwright report
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: success() || failure()
with:
name: playwright-report
path: ui/playwright-report
retention-days: 7