-
-
Notifications
You must be signed in to change notification settings - Fork 0
360 lines (314 loc) · 10.5 KB
/
ci.yml
File metadata and controls
360 lines (314 loc) · 10.5 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
352
353
354
355
356
357
358
359
360
name: CI - Build & Test
on:
push:
branches: [ main, development ]
paths-ignore:
- '**.md'
- 'docs/**'
- 'LICENSE'
- '.gitignore'
pull_request:
branches: [ main, development ]
paths-ignore:
- '**.md'
- 'docs/**'
- 'LICENSE'
- '.gitignore'
workflow_dispatch:
# Cancel in-progress runs for same PR/branch
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
JAVA_VERSION: '21'
JAVA_DISTRIBUTION: 'temurin'
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.parallel=true -Dorg.gradle.caching=true
jobs:
# ================== Unit Tests ==================
test-unit:
name: Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1 # Shallow clone for speed
- name: Setup JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }}
cache: gradle
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
- name: Run unit tests
run: |
./gradlew \
:pocketbase-kt-sdk:jvmTest \
:composeApp:jvmTest \
--parallel \
--build-cache \
--configuration-cache \
--no-daemon \
--stacktrace
continue-on-error: false
- name: Run shared unit tests (exclude integration)
run: |
./gradlew :shared:jvmTest \
--tests 'love.bside.app.unit.*' \
--tests 'love.bside.app.data.serialization.*' \
--tests 'love.bside.app.domain.models.*' \
--tests 'love.bside.app.domain.validation.*' \
--parallel \
--build-cache \
--no-daemon \
--stacktrace
continue-on-error: false
- name: Upload test reports
if: failure() # Only upload on failure to save storage
uses: actions/upload-artifact@v4
with:
name: test-reports-unit
path: |
**/build/reports/tests/
**/build/test-results/
retention-days: 3 # Reduced from 7 days
# ================== Android Build ==================
build-android:
name: Build Android
runs-on: ubuntu-latest
timeout-minutes: 30
needs: test-unit
if: github.event_name == 'push' || github.event.pull_request.draft == false
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }}
cache: gradle
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
- name: Build Android APK (Debug)
run: |
./gradlew \
:composeApp:assembleDebug \
--parallel \
--build-cache \
--configuration-cache \
--no-daemon \
--stacktrace
- name: Upload Android APK
uses: actions/upload-artifact@v4
with:
name: android-apk-debug
path: composeApp/build/outputs/apk/debug/*.apk
retention-days: 14 # Reduced from 30 days
compression-level: 0 # APKs are already compressed
- name: Generate APK checksums
run: |
cd composeApp/build/outputs/apk/debug
sha256sum *.apk > checksums.txt
cat checksums.txt
- name: Upload checksums
uses: actions/upload-artifact@v4
with:
name: android-checksums
path: composeApp/build/outputs/apk/debug/checksums.txt
retention-days: 14
# ================== iOS Build (macOS only) ==================
build-ios:
name: Build iOS
runs-on: macos-14 # M1 runner (faster & cheaper than macos-latest)
timeout-minutes: 30
needs: test-unit
if: github.event_name == 'push' || github.event.pull_request.draft == false
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }}
cache: gradle
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
- name: Build iOS Framework
run: |
./gradlew \
:composeApp:linkDebugFrameworkIosSimulatorArm64 \
--parallel \
--build-cache \
--configuration-cache \
--no-daemon \
--stacktrace
- name: Upload iOS Framework
uses: actions/upload-artifact@v4
with:
name: ios-framework-debug
path: composeApp/build/bin/iosSimulatorArm64/debugFramework/
retention-days: 14
# ================== Desktop Build ==================
build-desktop:
name: Build Desktop
strategy:
fail-fast: false # Continue other OS builds if one fails
matrix:
os: [ubuntu-latest, macos-14, windows-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 30
needs: test-unit
# Only build desktop on main branch or explicit request
if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }}
cache: gradle
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
- name: Build Desktop JAR
run: |
./gradlew \
:composeApp:jvmJar \
--parallel \
--build-cache \
--configuration-cache \
--no-daemon \
--stacktrace
- name: Upload Desktop Distribution
uses: actions/upload-artifact@v4
with:
name: desktop-${{ runner.os }}
path: composeApp/build/compose/binaries/main/app/
retention-days: 14
compression-level: 6 # Good balance for binaries
# ================== Web Build ==================
build-web:
name: Build Web
runs-on: ubuntu-latest
timeout-minutes: 30
needs: test-unit
if: github.event_name == 'push' || github.event.pull_request.draft == false
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }}
cache: gradle
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
- name: Build Web
run: |
./gradlew \
:composeApp:jsBrowserProductionWebpack \
--parallel \
--build-cache \
--configuration-cache \
--no-daemon \
--stacktrace
- name: Upload Web Build
uses: actions/upload-artifact@v4
with:
name: web-production
path: composeApp/build/dist/js/productionExecutable/
retention-days: 14
compression-level: 9 # Max compression for web assets
# ================== Code Quality ==================
code-quality:
name: Code Quality
runs-on: ubuntu-latest
timeout-minutes: 15
# Run in parallel with builds, don't wait for tests
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }}
cache: gradle
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
cache-read-only: true # Read-only for lint
- name: Run Lint
run: |
./gradlew \
:pocketbase-kt-sdk:lintDebug \
:shared:lintDebug \
--parallel \
--build-cache \
--configuration-cache \
--no-daemon \
--continue
- name: Upload Lint Reports
if: failure() # Only upload on failure
uses: actions/upload-artifact@v4
with:
name: lint-reports
path: |
**/build/reports/lint-results*.html
retention-days: 3
# ================== Summary ==================
ci-summary:
name: CI Summary
runs-on: ubuntu-latest
needs: [test-unit, build-android, build-ios, build-desktop, build-web, code-quality]
if: always()
steps:
- name: Check all jobs
run: |
echo "Unit Tests: ${{ needs.test-unit.result }}"
echo "Android Build: ${{ needs.build-android.result }}"
echo "iOS Build: ${{ needs.build-ios.result }}"
echo "Desktop Build: ${{ needs.build-desktop.result }}"
echo "Web Build: ${{ needs.build-web.result }}"
echo "Code Quality: ${{ needs.code-quality.result }}"
if [[ "${{ needs.test-unit.result }}" == "failure" ]] || \
[[ "${{ needs.build-android.result }}" == "failure" ]] || \
[[ "${{ needs.build-ios.result }}" == "failure" ]] || \
[[ "${{ needs.build-desktop.result }}" == "failure" ]] || \
[[ "${{ needs.build-web.result }}" == "failure" ]]; then
echo "❌ CI pipeline failed"
exit 1
else
echo "✅ CI pipeline passed"
fi