-
Notifications
You must be signed in to change notification settings - Fork 344
559 lines (479 loc) · 19.7 KB
/
build-all-test.yml
File metadata and controls
559 lines (479 loc) · 19.7 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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
name: Build All (Test)
# =============================================================================
# Comprehensive Build Verification Workflow
#
# Manually-triggered workflow with checkboxes for each build target.
# Select what you want to build and hit "Run workflow".
#
# Targets:
# - C++ Android Backends (arm64-v8a, armeabi-v7a, x86_64)
# - C++ iOS Backends (XCFramework)
# - Kotlin SDK (JVM + Android)
# - Swift SDK (iOS/macOS)
# - Web SDK (TypeScript)
# - Flutter SDK (Dart analyze)
# - React Native SDK (TypeScript)
# - Android Example Apps
# - IntelliJ Plugin
# =============================================================================
on:
workflow_dispatch:
inputs:
build_cpp_android:
description: 'C++ Android Backends (arm64-v8a, armeabi-v7a, x86_64)'
required: false
default: true
type: boolean
build_cpp_ios:
description: 'C++ iOS Backends (XCFramework)'
required: false
default: true
type: boolean
build_kotlin_sdk:
description: 'Kotlin SDK (JVM + Android)'
required: false
default: true
type: boolean
build_swift_sdk:
description: 'Swift SDK (iOS/macOS)'
required: false
default: true
type: boolean
build_web_sdk:
description: 'Web SDK (TypeScript)'
required: false
default: true
type: boolean
build_flutter_sdk:
description: 'Flutter SDK (Dart)'
required: false
default: true
type: boolean
build_react_native_sdk:
description: 'React Native SDK (TypeScript)'
required: false
default: true
type: boolean
build_android_apps:
description: 'Android Example Apps'
required: false
default: true
type: boolean
build_intellij_plugin:
description: 'IntelliJ Plugin'
required: false
default: true
type: boolean
permissions:
contents: read
env:
COMMONS_DIR: sdk/runanywhere-commons
jobs:
# ===========================================================================
# C++ Android Backends (Matrix: arm64-v8a, armeabi-v7a, x86_64)
# ===========================================================================
cpp-android:
name: C++ Android (${{ matrix.abi }})
if: ${{ inputs.build_cpp_android }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
abi: [arm64-v8a, armeabi-v7a, x86_64]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Setup NDK
run: |
NDK_VERSION="27.0.12077973"
echo "y" | sdkmanager --install "ndk;${NDK_VERSION}" --sdk_root=${ANDROID_SDK_ROOT}
echo "ANDROID_NDK_HOME=${ANDROID_SDK_ROOT}/ndk/${NDK_VERSION}" >> $GITHUB_ENV
- name: Setup Development Config
working-directory: ${{ env.COMMONS_DIR }}
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
run: |
CONFIG_FILE="src/infrastructure/network/development_config.cpp"
CLEAN_URL=$(printf '%s' "${SUPABASE_URL:-https://placeholder.supabase.co}" | tr -d '\n\r')
CLEAN_KEY=$(printf '%s' "${SUPABASE_ANON_KEY:-placeholder_key}" | tr -d '\n\r')
CLEAN_TOKEN=$(printf '%s' "${BUILD_TOKEN:-bt_test_build}" | tr -d '\n\r')
cat > "$CONFIG_FILE" << CONFIGEOF
#include <cstring>
#include "rac/core/rac_logger.h"
#include "rac/infrastructure/network/rac_dev_config.h"
namespace {
constexpr const char* SUPABASE_URL = "${CLEAN_URL}";
constexpr const char* SUPABASE_ANON_KEY = "${CLEAN_KEY}";
constexpr const char* BUILD_TOKEN = "${CLEAN_TOKEN}";
constexpr const char* SENTRY_DSN = nullptr;
}
extern "C" {
bool rac_dev_config_is_available(void) {
if (SUPABASE_URL == nullptr || SUPABASE_ANON_KEY == nullptr) return false;
if (std::strlen(SUPABASE_URL) == 0 || std::strlen(SUPABASE_ANON_KEY) == 0) return false;
if (std::strstr(SUPABASE_URL, "YOUR_") != nullptr) return false;
if (std::strstr(SUPABASE_ANON_KEY, "YOUR_") != nullptr) return false;
return true;
}
const char* rac_dev_config_get_supabase_url(void) { return SUPABASE_URL; }
const char* rac_dev_config_get_supabase_key(void) { return SUPABASE_ANON_KEY; }
const char* rac_dev_config_get_build_token(void) { return BUILD_TOKEN; }
const char* rac_dev_config_get_sentry_dsn(void) { return SENTRY_DSN; }
bool rac_dev_config_has_supabase(void) { return rac_dev_config_is_available(); }
bool rac_dev_config_has_build_token(void) { return BUILD_TOKEN != nullptr && std::strlen(BUILD_TOKEN) > 0; }
}
CONFIGEOF
- name: Download Dependencies
working-directory: ${{ env.COMMONS_DIR }}
run: |
chmod +x scripts/android/download-sherpa-onnx.sh
rm -rf third_party/sherpa-onnx-android
./scripts/android/download-sherpa-onnx.sh
- name: Build C++ Android ${{ matrix.abi }}
working-directory: ${{ env.COMMONS_DIR }}
run: |
chmod +x scripts/build-android.sh
./scripts/build-android.sh all ${{ matrix.abi }}
- name: List Build Output
working-directory: ${{ env.COMMONS_DIR }}
run: |
echo "=== Build Artifacts ==="
find dist/android -name "*.so" -type f 2>/dev/null | head -30 || echo "No .so files found"
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: cpp-android-${{ matrix.abi }}
path: ${{ env.COMMONS_DIR }}/dist/android/
retention-days: 7
# ===========================================================================
# C++ iOS Backends (XCFramework)
# ===========================================================================
cpp-ios:
name: C++ iOS (XCFramework)
if: ${{ inputs.build_cpp_ios }}
runs-on: macos-14
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.4'
- name: Install Dependencies
run: brew install cmake ninja
- name: Setup Development Config
working-directory: ${{ env.COMMONS_DIR }}
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
run: |
CONFIG_FILE="src/infrastructure/network/development_config.cpp"
CLEAN_URL=$(printf '%s' "${SUPABASE_URL:-https://placeholder.supabase.co}" | tr -d '\n\r')
CLEAN_KEY=$(printf '%s' "${SUPABASE_ANON_KEY:-placeholder_key}" | tr -d '\n\r')
CLEAN_TOKEN=$(printf '%s' "${BUILD_TOKEN:-bt_test_build}" | tr -d '\n\r')
cat > "$CONFIG_FILE" << CONFIGEOF
#include <cstring>
#include "rac/core/rac_logger.h"
#include "rac/infrastructure/network/rac_dev_config.h"
namespace {
constexpr const char* SUPABASE_URL = "${CLEAN_URL}";
constexpr const char* SUPABASE_ANON_KEY = "${CLEAN_KEY}";
constexpr const char* BUILD_TOKEN = "${CLEAN_TOKEN}";
constexpr const char* SENTRY_DSN = nullptr;
}
extern "C" {
bool rac_dev_config_is_available(void) {
if (SUPABASE_URL == nullptr || SUPABASE_ANON_KEY == nullptr) return false;
if (std::strlen(SUPABASE_URL) == 0 || std::strlen(SUPABASE_ANON_KEY) == 0) return false;
if (std::strstr(SUPABASE_URL, "YOUR_") != nullptr) return false;
if (std::strstr(SUPABASE_ANON_KEY, "YOUR_") != nullptr) return false;
return true;
}
const char* rac_dev_config_get_supabase_url(void) { return SUPABASE_URL; }
const char* rac_dev_config_get_supabase_key(void) { return SUPABASE_ANON_KEY; }
const char* rac_dev_config_get_build_token(void) { return BUILD_TOKEN; }
const char* rac_dev_config_get_sentry_dsn(void) { return SENTRY_DSN; }
bool rac_dev_config_has_supabase(void) { return rac_dev_config_is_available(); }
bool rac_dev_config_has_build_token(void) { return BUILD_TOKEN != nullptr && std::strlen(BUILD_TOKEN) > 0; }
}
CONFIGEOF
- name: Download iOS Dependencies
working-directory: ${{ env.COMMONS_DIR }}
run: |
chmod +x scripts/ios/download-sherpa-onnx.sh
chmod +x scripts/ios/download-onnx.sh
./scripts/ios/download-sherpa-onnx.sh
./scripts/ios/download-onnx.sh
- name: Build RACommons + All Backends (iOS)
working-directory: ${{ env.COMMONS_DIR }}
run: |
chmod +x scripts/build-ios.sh
./scripts/build-ios.sh --backend all --release --package
- name: List Build Output
working-directory: ${{ env.COMMONS_DIR }}
run: |
echo "=== Build Artifacts ==="
ls -la dist/
[ -d dist/RACommons.xcframework ] && echo "RACommons.xcframework" || echo "RACommons.xcframework MISSING"
[ -d dist/RABackendLLAMACPP.xcframework ] && echo "RABackendLLAMACPP.xcframework" || echo "RABackendLLAMACPP.xcframework MISSING"
[ -d dist/RABackendONNX.xcframework ] && echo "RABackendONNX.xcframework" || echo "RABackendONNX.xcframework MISSING"
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: cpp-ios-xcframeworks
path: |
${{ env.COMMONS_DIR }}/dist/RACommons.xcframework
${{ env.COMMONS_DIR }}/dist/RABackendLLAMACPP.xcframework
${{ env.COMMONS_DIR }}/dist/RABackendONNX.xcframework
retention-days: 7
# ===========================================================================
# Kotlin SDK (JVM + Android)
# ===========================================================================
kotlin-sdk:
name: Kotlin SDK (JVM + Android)
if: ${{ inputs.build_kotlin_sdk }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Setup local.properties
working-directory: sdk/runanywhere-kotlin
run: echo "sdk.dir=${ANDROID_SDK_ROOT}" > local.properties
- name: Build JVM JAR
working-directory: sdk/runanywhere-kotlin
run: |
chmod +x gradlew
./gradlew jvmJar -Prunanywhere.testLocal=false
- name: Build Android AAR (Debug)
working-directory: sdk/runanywhere-kotlin
run: ./gradlew assembleDebug -Prunanywhere.testLocal=false
continue-on-error: true
- name: Build Backend Modules
working-directory: sdk/runanywhere-kotlin
run: |
./gradlew :modules:runanywhere-core-llamacpp:assembleDebug -Prunanywhere.testLocal=false || true
./gradlew :modules:runanywhere-core-onnx:assembleDebug -Prunanywhere.testLocal=false || true
continue-on-error: true
- name: Publish to Maven Local
working-directory: sdk/runanywhere-kotlin
run: ./gradlew publishToMavenLocal -Prunanywhere.testLocal=false
continue-on-error: true
# ===========================================================================
# Swift SDK (iOS/macOS)
# ===========================================================================
swift-sdk:
name: Swift SDK
if: ${{ inputs.build_swift_sdk }}
runs-on: macos-14
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Swift Build (remote XCFrameworks)
run: swift build
- name: Swift Test
run: swift test
continue-on-error: true
# ===========================================================================
# Web SDK (TypeScript)
# ===========================================================================
web-sdk:
name: Web SDK (TypeScript)
if: ${{ inputs.build_web_sdk }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Dependencies
working-directory: sdk/runanywhere-web
run: npm install
- name: TypeScript Typecheck
working-directory: sdk/runanywhere-web/packages/core
run: npx tsc --noEmit
- name: TypeScript Build
working-directory: sdk/runanywhere-web/packages/core
run: npx tsc
# ===========================================================================
# Flutter SDK (Dart)
# ===========================================================================
flutter-sdk:
name: Flutter SDK (Dart)
if: ${{ inputs.build_flutter_sdk }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.27.x'
channel: 'stable'
- name: Install Melos
run: dart pub global activate melos
- name: Bootstrap Packages
working-directory: sdk/runanywhere-flutter
run: melos bootstrap
- name: Analyze All Packages
working-directory: sdk/runanywhere-flutter
run: melos run analyze || dart analyze packages/runanywhere packages/runanywhere_llamacpp packages/runanywhere_onnx
continue-on-error: true
- name: Run Tests
working-directory: sdk/runanywhere-flutter
run: melos run test || true
continue-on-error: true
# ===========================================================================
# React Native SDK (TypeScript)
# ===========================================================================
react-native-sdk:
name: React Native SDK (TypeScript)
if: ${{ inputs.build_react_native_sdk }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Dependencies
working-directory: sdk/runanywhere-react-native
run: yarn install --frozen-lockfile || npm install
- name: TypeScript Typecheck
working-directory: sdk/runanywhere-react-native
run: npx tsc --noEmit -p tsconfig.base.json
continue-on-error: true
- name: Build Packages
working-directory: sdk/runanywhere-react-native
run: npx lerna run build || true
continue-on-error: true
# ===========================================================================
# Android Example Apps
# ===========================================================================
android-apps:
name: Android Example Apps
if: ${{ inputs.build_android_apps }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Setup local.properties
run: |
echo "sdk.dir=${ANDROID_SDK_ROOT}" > examples/android/RunAnywhereAI/local.properties
echo "sdk.dir=${ANDROID_SDK_ROOT}" > examples/android/RunAnyWhereLora/local.properties
echo "sdk.dir=${ANDROID_SDK_ROOT}" > sdk/runanywhere-kotlin/local.properties
- name: Build RunAnywhereAI
working-directory: examples/android/RunAnywhereAI
run: |
chmod +x gradlew
./gradlew assembleDebug -Prunanywhere.testLocal=false
continue-on-error: true
- name: Build RunAnyWhereLora
working-directory: examples/android/RunAnyWhereLora
run: |
chmod +x gradlew
./gradlew assembleDebug -Prunanywhere.testLocal=false
continue-on-error: true
# ===========================================================================
# IntelliJ Plugin
# ===========================================================================
intellij-plugin:
name: IntelliJ Plugin
if: ${{ inputs.build_intellij_plugin }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Setup local.properties
run: echo "sdk.dir=${ANDROID_SDK_ROOT}" > sdk/runanywhere-kotlin/local.properties
- name: Publish SDK to Maven Local
working-directory: sdk/runanywhere-kotlin
run: |
chmod +x gradlew
./gradlew publishToMavenLocal -Prunanywhere.testLocal=false
- name: Build IntelliJ Plugin
working-directory: examples/intellij-plugin-demo/plugin
run: |
chmod +x gradlew
./gradlew buildPlugin
# ===========================================================================
# Build Summary
# ===========================================================================
summary:
name: Build Summary
needs:
- cpp-android
- cpp-ios
- kotlin-sdk
- swift-sdk
- web-sdk
- flutter-sdk
- react-native-sdk
- android-apps
- intellij-plugin
if: always()
runs-on: ubuntu-latest
steps:
- name: Build Results
run: |
echo "## Build All (Test) Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Target | Status |" >> $GITHUB_STEP_SUMMARY
echo "|--------|--------|" >> $GITHUB_STEP_SUMMARY
# Helper: map job result to display string
status() {
case "$1" in
success) echo "Pass" ;;
skipped) echo "Skipped (unchecked)" ;;
failure) echo "FAILED" ;;
cancelled) echo "Cancelled" ;;
*) echo "$1" ;;
esac
}
echo "| C++ Android Backends | $(status '${{ needs.cpp-android.result }}') |" >> $GITHUB_STEP_SUMMARY
echo "| C++ iOS Backends | $(status '${{ needs.cpp-ios.result }}') |" >> $GITHUB_STEP_SUMMARY
echo "| Kotlin SDK (JVM + Android) | $(status '${{ needs.kotlin-sdk.result }}') |" >> $GITHUB_STEP_SUMMARY
echo "| Swift SDK | $(status '${{ needs.swift-sdk.result }}') |" >> $GITHUB_STEP_SUMMARY
echo "| Web SDK (TypeScript) | $(status '${{ needs.web-sdk.result }}') |" >> $GITHUB_STEP_SUMMARY
echo "| Flutter SDK (Dart) | $(status '${{ needs.flutter-sdk.result }}') |" >> $GITHUB_STEP_SUMMARY
echo "| React Native SDK | $(status '${{ needs.react-native-sdk.result }}') |" >> $GITHUB_STEP_SUMMARY
echo "| Android Example Apps | $(status '${{ needs.android-apps.result }}') |" >> $GITHUB_STEP_SUMMARY
echo "| IntelliJ Plugin | $(status '${{ needs.intellij-plugin.result }}') |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "---" >> $GITHUB_STEP_SUMMARY
echo "Triggered by: **${{ github.actor }}**" >> $GITHUB_STEP_SUMMARY
echo "Commit: \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY
echo "Branch: \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY