-
Notifications
You must be signed in to change notification settings - Fork 300
534 lines (468 loc) · 15.8 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
532
533
534
name: CI
on:
push:
paths-ignore:
- "docs/**"
- "**/*.md"
pull_request:
paths-ignore:
- "docs/**"
- "**/*.md"
workflow_dispatch: {}
env:
CARGO_TERM_COLOR: always
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
# -------------------------- test --------------------------
dart_test_valgrind:
name: Dart test with Valgrind
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.68.0
components: rustfmt
- uses: dart-lang/setup-dart@v1
with:
sdk: stable
architecture: x64
- uses: actions/setup-python@v2
with:
python-version: "3.x"
- uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: just ci_valgrind
# ref https://medium.com/flutter-community/run-flutter-driver-tests-on-github-actions-13c639c7e4ab
flutter_test_ios:
name: Flutter integration test on iOS
strategy:
matrix:
device:
- "iPad (9th generation) Simulator (16.2)"
- "iPhone 12 Pro Max Simulator (16.2)"
fail-fast: false
runs-on: macos-latest
steps:
- name: "List all simulators"
run: "xcrun xctrace list devices"
- name: "Start Simulator"
run: |
# the extra "(" is to avoid matching things like "iPhone 12 Pro Max Simulator (16.2) + Apple Watch Series 5 - 44mm (8.0)"
UDID=$(xcrun xctrace list devices | grep '${{ matrix.device }} (' | awk '{print $NF}' | tr -d '()')
echo UDID=$UDID
xcrun simctl boot "${UDID:?No Simulator with this name found}"
- uses: actions/checkout@v2
id: checkout
- uses: subosito/flutter-action@v2
with:
cache: true
channel: "stable"
flutter-version: 3.10.0
architecture: x64
- id: cache-deps
uses: ./.github/actions/setup
with:
cache-key: "$${{ steps.rust-toolchain.outputs.cachekey }}"
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.68.0
- name: Add Rust targets
run: rustup target add aarch64-apple-ios x86_64-apple-ios
- uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install `cargo-lipo`
run: just install_lipo
- name: Install Flutter dependencies
working-directory: ./frb_example/with_flutter
run: flutter pub get
- name: Build Rust lib
working-directory: ./frb_example/with_flutter/rust
# note the "-i '' -e" is a bug of sed specific to MacOS https://stackoverflow.com/questions/19456518
run: |
sed -i '' -e 's/"cdylib"/"staticlib"/g' Cargo.toml
cargo lipo
cp ../../../target/universal/debug/libflutter_rust_bridge_example.a ../ios/Runner
- name: Run Flutter integration tests
working-directory: ./frb_example/with_flutter
run: flutter test integration_test/main.dart --verbose
# ref https://betterprogramming.pub/test-flutter-apps-on-android-with-github-actions-abdba2137b4
flutter_test_android:
name: Flutter integration test on Android
runs-on: macos-latest
strategy:
matrix:
device:
- "pixel"
- "Nexus 6"
api-level: [29]
fail-fast: false
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v2
with:
cache: true
channel: "stable"
flutter-version: 3.10.0
architecture: x64
- id: checkout
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.68.0
- uses: actions/setup-java@v1
with:
java-version: "11.x" # "betterprogramming.pub" says must be java "8"
- uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# #499, https://github.com/actions/virtual-environments/issues/5595
- name: Configure ndk
run: just configure_ndk
- id: cache-deps
uses: ./.github/actions/setup
with:
cache-key: "${{ steps.rust-toolchain.outputs.cachekey }}"
cache-platform: "${{ matrix.device }}"
- name: Add Rust targets
run: rustup target add x86_64-linux-android
- name: Install `cargo-ndk`
run: just install_ndk
- name: Install Flutter dependencies
working-directory: ./frb_example/with_flutter
run: flutter pub get
- name: Build Rust lib
working-directory: ./frb_example/with_flutter/rust
# NOTE since run on simulator, need -t to be x86_64. For real devices, of course arm-like ones.
run: cargo ndk --bindgen -t x86_64 -o ../android/app/src/main/jniLibs build
- name: Gradle cache
uses: gradle/[email protected]
- name: AVD cache
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-api-level-${{ matrix.api-level }}
- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."
# it would success if timeout...
- name: Run Flutter integration tests
continue-on-error: true
timeout-minutes: 20
uses: Wandalen/[email protected]
with:
action: reactivecircus/android-emulator-runner@v2
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim
with: |
api-level: ${{ matrix.api-level }}
arch: x86_64
profile: ${{ matrix.device }}
script: cd frb_example/with_flutter && flutter test integration_test/main.dart --verbose
flutter_test_windows:
name: Flutter integration test on Windows
runs-on: windows-2019
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v2
with:
cache: true
channel: "stable"
flutter-version: 3.10.0
architecture: x64
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.68.0
- uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1
with:
version: "10.0"
directory: ${{ runner.temp }}/llvm
- run: just flutter_example_with_flutter_integration_test
- name: Install Corrosion
run: |
cd ..
git clone https://github.com/corrosion-rs/corrosion.git
cmake -Scorrosion -Bbuild -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release
cmake --install build --config Release
echo "C:\Program Files (x86)\Corrosion" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Run Flutter integration tests explicitly requiring Corrosion
working-directory: ./frb_example/with_flutter
run: |
mv -Force windows/rust.require.cmake windows/rust.cmake
just flutter_example_with_flutter_integration_test
flutter_test_macos:
name: Flutter integration test on MacOS
runs-on: macos-11
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v2
with:
channel: "stable"
cache: true
# TODO should be 3.7.3 but has a weird bug currently
# https://github.com/fzyzcjy/flutter_rust_bridge/pull/1023#issuecomment-1415852845
flutter-version: 3.10.0
architecture: x64
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.68.0
- uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: just flutter_example_with_flutter_integration_test
flutter_test_linux:
name: Flutter integration test on Linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v2
with:
cache: true
channel: "stable"
flutter-version: 3.10.0
architecture: x64
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.68.0
- name: Setup headless display
uses: pyvista/setup-headless-display-action@v1
- uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: just install_prerequisite_for_integration_test_linux
- run: just flutter_example_with_flutter_integration_test
- run: just install_corrosion_linux
- name: Run Flutter integration tests explicitly requiring Corrosion
working-directory: ./frb_example/with_flutter
run: |
set -euxo pipefail
mv linux/rust.require.cmake linux/rust.cmake
just flutter_example_with_flutter_integration_test
dart_test_web:
name: Dart test on Web
runs-on: ubuntu-latest
strategy:
matrix:
include:
- features: []
- features: [wasm-start]
steps:
- uses: actions/checkout@v2
- uses: dart-lang/setup-dart@v1
with:
sdk: 3.0.0
architecture: x64
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
target: wasm32-unknown-unknown
components: rust-src,rustfmt
- uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: just install_ffigen
- name: Cache dependencies
id: test-cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
frb_codegen/target
frb_example/pure_dart/rust/target/
frb_example/pure_dart/dart/.local-chromium
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install crates
if: steps.test-cache.outputs.cache-hit != 'true'
run: |
sh -c "$(curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf)" '' -f
- name: Setup Dart dependencies
run: dart pub get
working-directory: frb_dart
- name: Run unit tests
run: just dart_test_web_unit
- name: Run integration tests
timeout-minutes: 20
uses: Wandalen/[email protected]
with:
command: just dart_test_web_integration "${{ join(matrix.features, ',') }}"
current_path: frb_example/pure_dart/dart
dart_test_vm_service:
name: Dart test with vm service
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.68.0
components: rustfmt
- uses: dart-lang/setup-dart@v1
with:
sdk: 3.0.0
architecture: x64
- uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: just install_ffigen_dependency
- run: just dart_test_vm_service
rust_build_and_test:
name: Rust build and test
runs-on: ${{ matrix.image }}
strategy:
fail-fast: false
matrix:
image:
- macos-11
- windows-2019
- ubuntu-latest
steps:
- uses: actions/checkout@v2
- id: rust-toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.68.0
components: rustfmt
- uses: dart-lang/setup-dart@v1
with:
sdk: 3.0.0
architecture: x64
- uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: just install_ffigen_dependency
- run: just dart_pub_get dart_only
- run: just rust_build_and_test
# -------------------------- linter --------------------------
rust_linter:
name: Rust linter
runs-on: ubuntu-latest
strategy:
matrix:
cargo_toolchain_version:
- 1.68.0
steps:
- uses: actions/checkout@v2
- id: rust-toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.cargo_toolchain_version }}
components: rustfmt, clippy
- uses: dart-lang/setup-dart@v1
with:
sdk: 3.0.0
architecture: x64
- uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: just install_ffigen_dependency
- run: just rust_linter
dart_linter:
name: Dart linter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dart-lang/setup-dart@v1
with:
sdk: 3.0.0
architecture: x64
- uses: subosito/flutter-action@v2
with:
cache: true
channel: "stable"
flutter-version: 3.10.0
- uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: just dart_linter
# -------------------------- codegen --------------------------
codegen:
name: Codegen
runs-on: ${{ matrix.image }}
strategy:
fail-fast: false
matrix:
image:
- macos-11
- windows-2019
- ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.68.0
components: rustfmt, clippy
- uses: subosito/flutter-action@v2
with:
cache: true
channel: "stable"
flutter-version: 3.10.0
architecture: x64
- uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: just ci_codegen
msrv:
name: test MSRV and specific problematic versions
runs-on: ubuntu-latest # as of now, there is no real reason to test on multiple OSs
strategy:
matrix:
rust_version:
- nightly # latest nightly
- nightly-2023-06-28 # pre https://github.com/rust-lang/rust/issues/113152
- nightly-2023-07-26 # post https://github.com/rust-lang/rust/issues/113152
#
# DO NOT EDIT BELOW THIS LINE
#
- nightly-2022-07-15 ### nightly MSRV (DO NOT EDIT THIS LINE):
- 1.64 ### stable MSRV (DO NOT EDIT THIS LINE):
#
# DO NOT EDIT ABOVE THIS LINE
#
steps:
- uses: actions/checkout@v2
# cache cargo and rustup to reduce future build times as much as possible
- name: cache
uses: actions/cache@v3
with:
path: |
~/.cargo
~/.rustup
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
# Check cache, then insdtall if not found
- if: steps.cache.outputs.cache-hit != 'true'
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust_version }}
components: rustfmt, clippy
- uses: subosito/flutter-action@v2
with:
cache: true
channel: "stable"
flutter-version: 3.10.0
architecture: x64
- uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: just install_ffigen_dependency
- run: just dart_pub_get dart_only
- run: just rust_build_and_test