-
Notifications
You must be signed in to change notification settings - Fork 10
531 lines (448 loc) · 17 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
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
name: CI
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
env:
CARGO_TERM_COLOR: always
CARGO_MAKE_TOOLCHAIN: stable
CARGO_MAKE_CI: true
ANDROID_API: 34
ANDROID_NDK_VERSION: 26.3.11579264
HOMEBREW_NO_AUTO_UPDATE: 1
# https://doc.rust-lang.org/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci
CARGO_CACHE_PATH: |
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
jobs:
fmt:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.CARGO_MAKE_TOOLCHAIN }}
components: rustfmt
- name: Cargo fmt
run: cargo fmt --all -- --check
typos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@v2
with:
tool: typos-cli
- name: run typos
run: typos
- name: Typos info
if: failure()
run: |
echo 'To fix typos, please run `typos -w`'
echo 'To check for a diff, run `typos`'
echo 'You can find typos here: https://crates.io/crates/typos'
wasm:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.CARGO_MAKE_TOOLCHAIN }}
targets: wasm32-unknown-unknown
- name: Build wasm
run: cargo build --target wasm32-unknown-unknown -p liveview_native_core_wasm
- uses: taiki-e/install-action@v2
with:
tool: wasm-pack
- uses: taiki-e/install-action@v2
with:
tool: wasm-bindgen
- name: Build wasm for nodesjs
working-directory: ./crates/wasm
run: ./scripts/build.sh nodejs
- name: Build wasm for web
working-directory: ./crates/wasm
run: ./scripts/build.sh web
- name: Run Jest tests with wasm artifacts
working-directory: ./crates/wasm
run: |
if ./scripts/jest_tests.sh; then
echo "The wasm tests should not yet be passing."
echo "If core is now compliant, then remove this conditional."
exit 1
else
exit 0
fi
clippy:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.CARGO_MAKE_TOOLCHAIN }}
components: clippy
- name: Cargo fmt
run: cargo clippy -- -Dwarnings
kotiln_integration_tests:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-15, ubuntu-24.04]
steps:
- uses: actions/checkout@v4
- uses: ./tests/support/test_server/
if: ${{ matrix.os == 'macos-15' }}
- name: Install Rust Nightly
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.CARGO_MAKE_TOOLCHAIN }}
targets: armv7-linux-androideabi
aarch64-linux-android
i686-linux-android
x86_64-linux-android
x86_64-unknown-linux-gnu
aarch64-apple-darwin
x86_64-apple-darwin
- name: Cache
uses: actions/cache@v4
with:
path: ${{ env.CARGO_CACHE_PATH }}
key: cargo-${{ github.workflow }}-${{ github.job }}-${{runner.os}}-${{runner.arch}}-${{ hashFiles('**/Cargo.toml') }}
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "temurin"
- name: Install gradle
uses: gradle/actions/setup-gradle@v4
# https://github.com/actions/runner-images/blob/5a9870800dc54127d22ee36c303b47314d231c69/images/macos/macos-15-arm64-Readme.md
# Python is required to build OpenSSL but there's no python in the m1
# macos runners.
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Run build with Gradle wrapper
if: ${{ matrix.os == 'macos-15' }}
working-directory: ./crates/core/liveview-native-core-jetpack/
env:
RANLIB: "${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-ranlib"
run: ./gradlew build --scan
- name: Run build with Gradle wrapper
if: ${{ matrix.os == 'ubuntu-24.04' }}
working-directory: ./crates/core/liveview-native-core-jetpack/
env:
RANLIB: "${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib"
run: ./gradlew build --scan -x test
swift_build_xcframework:
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- name: Install Rust Nightly
uses: dtolnay/rust-toolchain@master
with:
# nightly needed for t3
toolchain: nightly
components: rust-src
targets: aarch64-apple-ios-sim
aarch64-apple-ios
x86_64-apple-ios
aarch64-apple-darwin
x86_64-apple-darwin
- uses: taiki-e/install-action@v2
with:
tool: cargo-make
- name: Cache
uses: actions/cache@v4
with:
path: ${{ env.CARGO_CACHE_PATH }}
key: cargo-${{ github.workflow }}-${{ github.job }}-${{runner.os}}-${{runner.arch}}-${{ hashFiles('**/Cargo.toml') }}
- name: Generate the swift package
run: cargo make uniffi-swift-package
- uses: actions/upload-artifact@v4
with:
retention-days: 2
name: LiveViewNativeCore-Source
path: ./crates/core/liveview-native-core-swift/Sources/LiveViewNativeCore
- name: Test swift package
run: cargo make uniffi-xcframework
- uses: actions/upload-artifact@v4
with:
retention-days: 2
name: liveview_native_core.xcframework
path: ./target/uniffi/swift/liveview_native_core.xcframework
swift_integration_tests:
runs-on: macos-15
needs:
- swift_build_xcframework
strategy:
matrix:
swift-test: ["package", "tvos", "watchos", "macos", "ios", "visionos"]
steps:
- uses: actions/checkout@v4
- uses: ./tests/support/test_server/
- uses: actions/download-artifact@v4
with:
name: liveview_native_core.xcframework
path: ./target/uniffi/swift/liveview_native_core.xcframework
- uses: actions/download-artifact@v4
with:
name: LiveViewNativeCore-Source
path: ./crates/core/liveview-native-core-swift/Sources/LiveViewNativeCore
- name: Check artifact downloads
run: |
ls ./target/uniffi/swift/ ./target/uniffi/swift/liveview_native_core.xcframework ./crates/core/liveview-native-core-swift/Sources/LiveViewNativeCore/ ./crates/core/liveview-native-core-swift/Sources/LiveViewNativeCore/*
- uses: taiki-e/install-action@v2
with:
tool: cargo-make
- name: Cache xcode builds for ${{matrix.swift-test}}
uses: actions/cache@v4
id: xcode-build-cache
with:
path: |
xcode-build/
key: xcode-build-${{ github.workflow }}-${{ github.job }}-${{ runner.os }}-${{runner.arch}}-${{matrix.swift-test}}
- name: Test swift package
run: cargo make uniffi-swift-test-${{matrix.swift-test}}
- name: Upload Test Results
if: ${{ failure() && matrix.swift-test != 'package' }}
uses: actions/upload-artifact@v4
with:
name: xcode-test-results-${{ matrix.swift-test }}
path: xcode-build/Logs/Test/
- name: Phx server logs
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: phx-server-stdout-${{ matrix.swift-test }}
path: |
tests/support/test_server/server.stdout.txt
tests/support/test_server/server.stderr.txt
- name: Show Test Coverage
if: ${{ matrix.swift-test == 'package' }}
run: |
xcrun llvm-cov report -instr-profile .build/arm64-apple-macosx/debug/codecov/default.profdata .build/arm64-apple-macosx/debug/LiveViewNativeCorePackageTests.xctest/Contents/MacOS/LiveViewNativeCorePackageTests
xcrun llvm-cov export -instr-profile .build/arm64-apple-macosx/debug/codecov/default.profdata .build/arm64-apple-macosx/debug/LiveViewNativeCorePackageTests.xctest/Contents/MacOS/LiveViewNativeCorePackageTests --format lcov > ./swift-lcov.info
- uses: actions/upload-artifact@v4
if: ${{ matrix.swift-test == 'package' }}
with:
retention-days: 2
name: swift-lcov.info
path: swift-lcov.info
coverage_report:
runs-on: ubuntu-24.04
needs:
- swift_integration_tests
- integration_tests
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: LiveViewNativeCore-Source
path: ./crates/core/liveview-native-core-swift/Sources/LiveViewNativeCore
- uses: actions/download-artifact@v4
with:
name: swift-lcov.info
- uses: actions/download-artifact@v4
with:
name: rust-lcov.info
- name: Check artifact downloads
run: |
ls $PWD/crates/core/liveview-native-core-swift/Sources/LiveViewNativeCore/ $PWD/crates/core/liveview-native-core-swift/Sources/LiveViewNativeCore/*
- name: Install lcov
run: sudo apt-get -y install lcov
- name: Merge coverage files
run: lcov -a rust-lcov.info -a swift-lcov.info -o merged-lcov.info
- uses: livewing/[email protected]
with:
lcov: merged-lcov.info
integration_tests:
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- uses: ./tests/support/test_server/
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.CARGO_MAKE_TOOLCHAIN }}
- name: Cache
uses: actions/cache@v4
with:
path: ${{ env.CARGO_CACHE_PATH }}
key: cargo-${{ github.workflow }}-${{ github.job }}-${{runner.os}}-${{runner.arch}}-${{ hashFiles('**/Cargo.toml') }}
- name: Get the JNA jar for testing kotlin.
run: wget 'https://repo1.maven.org/maven2/net/java/dev/jna/jna/5.14.0/jna-5.14.0.jar'
- name: Build tests
run: cargo test --no-run
- name: Run Tests
timeout-minutes: 5
run: cargo test
env:
# This is required for the kotlin uniffi tests
CLASSPATH: "/Users/runner/work/liveview-native-core/liveview-native-core/jna-5.14.0.jar:/opt/homebrew/opt/kotlin/libexec/lib/kotlinx-coroutines-core-jvm.jar"
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Test Coverage
timeout-minutes: 5
run: |
cargo llvm-cov
cargo llvm-cov report --lcov --output-path ./rust-lcov.info
env:
# This is required for the kotlin uniffi tests
CLASSPATH: "/Users/runner/work/liveview-native-core/liveview-native-core/jna-5.14.0.jar:/opt/homebrew/opt/kotlin/libexec/lib/kotlinx-coroutines-core-jvm.jar"
- uses: actions/upload-artifact@v4
with:
retention-days: 2
name: rust-lcov.info
path: rust-lcov.info
- name: Phx server logs
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: phx-server-stdout-${{ github.job }}-${{ runner.os }}
path: |
tests/support/test_server/server.stdout.txt
tests/support/test_server/server.stderr.txt
apple_simulator_tests:
# rust cross-compilation
runs-on: macos-15
strategy:
fail-fast: false
matrix:
toolchain: ["stable"]
rust-target: ["aarch64-apple-ios-sim"]
apple-sim: ["iPhone 16"]
build-std: [""]
include:
- rust-target: "aarch64-apple-tvos-sim"
apple-sim: "Apple TV 4K (3rd generation)"
build-std: "-Zbuild-std"
toolchain: "nightly"
- rust-target: "aarch64-apple-watchos-sim"
apple-sim: "Apple Watch Ultra 2 (49mm)"
build-std: "-Zbuild-std"
toolchain: "nightly"
steps:
- uses: actions/checkout@v4
- name: Start Simulator
run: |
xcrun simctl list devices available
xcrun simctl boot "${{ matrix.apple-sim }}"
- uses: dtolnay/rust-toolchain@master
with:
toolchain: "${{matrix.toolchain}}"
components: rust-src
targets: aarch64-apple-ios-sim
- name: Cargo Cache
uses: actions/cache@v4
with:
path: ${{ env.CARGO_CACHE_PATH }}
key: cargo-${{ github.workflow }}-${{ runner.os }}-${{ runner.arch }}-${{ github.job }}-${{ hashFiles('**/Cargo.toml') }}
- uses: taiki-e/install-action@v2
with:
tool: [email protected]
- uses: ./tests/support/test_server/
- name: Build tests
run: cargo ${{ matrix.build-std }} test --target ${{ matrix.rust-target }} --no-run
- name: Run Rust tests on simulator for ${{ matrix.rust-target }}
env:
DINGHY_LOG: debug
SIMCTL_CHILD_RUST_LOG: trace
SIMCTL_CHILD_RUST_BACKTRACE: full
timeout-minutes: 30
run: |
cargo ${{ matrix.build-std }} test --target ${{ matrix.rust-target }} -- --test-threads 1
- name: Phx server logs
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: ${{ github.job }}-${{ matrix.rust-target }}
path: |
tests/support/test_server/server.stdout.txt
tests/support/test_server/server.stderr.txt
/Users/runner/Library/Developer/CoreSimulator/Devices/*/data/Containers/Bundle/Application/*/Dinghy.app/stdout
android_simulator_tests:
# rust cross-compilation
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.CARGO_MAKE_TOOLCHAIN }}
target: x86_64-linux-android
- name: Cargo Cache
uses: actions/cache@v4
with:
path: ${{ env.CARGO_CACHE_PATH }}
key: cargo-${{ github.workflow }}-${{ runner.os }}-${{ runner.arch }}-${{ github.job }}-${{ hashFiles('**/Cargo.toml') }}
- uses: taiki-e/install-action@v2
with:
tool: [email protected]
- uses: ./tests/support/test_server/
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: "temurin"
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Gradle cache
uses: gradle/actions/setup-gradle@v4
- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ env.ANDROID_API }}-${{ github.workflow }}-${{ github.job }}-${{ runner.os }}-${{runner.arch}}
- name: Create directory for avd
# This shouldn't be necesary but this is a work around for
# https://github.com/ReactiveCircus/android-emulator-runner/issues/197
if: steps.avd-cache.outputs.cache-hit != 'true'
run: mkdir -p ~/.android/avd
- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/[email protected]
with:
api-level: ${{ env.ANDROID_API }}
ndk: ${{ env.ANDROID_NDK_VERSION }}
force-avd-creation: false
target: google_apis
arch: x86_64
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."
- name: Run tests in android emulator
uses: reactivecircus/[email protected]
env:
RANLIB: "${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib"
with:
api-level: ${{ env.ANDROID_API }}
ndk: ${{ env.ANDROID_NDK_VERSION }}
target: google_apis
arch: x86_64
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: |
cargo dinghy all-platforms
cargo dinghy all-devices
cargo dinghy -p auto-android-x86_64-api${ANDROID_API} test -- --test-threads 1
- name: Phx server logs
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: phx-server-stdout-${{ github.job }}-${{ runner.os }}
path: |
tests/support/test_server/server.stdout.txt
tests/support/test_server/server.stderr.txt