-
Notifications
You must be signed in to change notification settings - Fork 12
439 lines (401 loc) · 16.7 KB
/
build.yaml
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
name: Build & Test
on:
workflow_dispatch:
pull_request:
push:
branches-ignore:
- gh-pages
schedule:
# runs the CI everyday at 10AM
- cron: "0 10 * * *"
env:
FLUTTER_CHANNEL: beta
RUST_TOOLCHAIN: nightly
MELOS_VERSION: "3.1.0"
jobs:
# General build, check, and test steps
build_and_test:
runs-on: ubuntu-latest
strategy:
matrix:
wasm_runtime: [wasmtime, wasmi]
steps:
# Setup
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
channel: ${{ env.FLUTTER_CHANNEL }}
- run: dart pub global activate melos ${{ env.MELOS_VERSION }} && melos bs
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt, clippy
- run: cargo install cargo-wasi
- name: Configure the Rust API to use the provided WASM runtime
run: bash scripts/config_api.sh ${{ matrix.wasm_runtime }}
# Rust
- name: Check Rust format
working-directory: ./packages/wasm_run/native/src
run: rustfmt --check lib.rs
if: always()
- name: Rust code analysis
run: cargo clippy -- -D warnings
if: always()
# TODO: - name: Run Rust tests
# run: cargo test
# if: always()
- name: Build Rust code for Dart tests
run: cargo build -r
id: build_rust
if: always()
- run: melos run build:wasm_examples -- release
if: always()
# Dart/Flutter
- name: Check Dart format
run: melos run check-format --no-select
if: always()
- name: Dart code analysis
run: melos run analyze --no-select
if: always()
- id: dart_test
name: Run Dart tests
run: melos run test
if: always() && steps.build_rust.outcome == 'success'
# UPLOAD COVERAGE
- id: coverage
name: Run tests with coverage
if: always() && steps.dart_test.outcome == 'success' && matrix.wasm_runtime == 'wasmtime'
run: melos run test:coverage
- id: upload_coverage_to_coveralls
name: Upload coverage to Coveralls
uses: coverallsapp/github-action@v2
if: always() && steps.coverage.outcome == 'success'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: "./packages/wasm_run/coverage/lcov.info"
base-path: "packages/wasm_run"
- id: upload_coverage_to_coveralls2
name: Upload coverage to Coveralls
uses: coverallsapp/github-action@v1
if: always() && steps.coverage.outcome == 'success' && steps.upload_coverage_to_coveralls.outcome != 'success'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: "./packages/wasm_run/coverage/lcov.info"
base-path: "packages/wasm_run/lib"
- name: Upload coverage to Coveralls
uses: coverallsapp/github-action@v2
if: always() && steps.coverage.outcome == 'success' && steps.upload_coverage_to_coveralls.outcome != 'success' && steps.upload_coverage_to_coveralls2.outcome != 'success'
- id: upload_coverage_to_codecov
name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
if: always() && steps.coverage.outcome == 'success'
with:
fail_ci_if_error: false
verbose: true
files: ./packages/wasm_run/coverage/lcov.info
functionalities: 'search'
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
if: always() && steps.coverage.outcome == 'success' && steps.upload_coverage_to_codecov.outcome != 'success'
with:
fail_ci_if_error: false
verbose: true
files: ./packages/wasm_run/coverage/lcov.info
# Web Browser tests
- run: |
git clone https://github.com/flutter/web_installers.git
cd web_installers/packages/web_drivers
dart pub get
if: always()
# Chrome
- name: Install and run Chrome Driver
run: ${CHROMEWEBDRIVER}/chromedriver --port=4445 &
id: chromedriver
if: always()
- run: dart run test -p chrome
working-directory: packages/wasm_run
if: always() && steps.chromedriver.outcome == 'success'
- run: flutter drive --driver=test_driver/integration_test.dart --target=integration_test/main_test.dart -d web-server --browser-name=chrome --driver-port=4445
working-directory: packages/wasm_run_flutter/example
if: always() && steps.chromedriver.outcome == 'success'
# Firefox
- name: Install and run Firefox Driver
run: |
dart lib/web_driver_installer.dart firefoxdriver --install-only --driver-version="v0.26.0"
firefoxdriver/geckodriver --port=4446 &
working-directory: web_installers/packages/web_drivers
id: firefoxdriver
if: always()
- run: flutter drive --driver=test_driver/integration_test.dart --target=integration_test/main_test.dart -d web-server --browser-name=firefox --driver-port=4446
working-directory: packages/wasm_run_flutter/example
if: always() && steps.firefoxdriver.outcome == 'success'
- run: |
Xvfb :99 -screen 0 1024x768x16 &
export DISPLAY=:99
dart run test -p firefox
working-directory: packages/wasm_run
if: always() && steps.firefoxdriver.outcome == 'success'
macos_integration_test:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
channel: ${{ env.FLUTTER_CHANNEL }}
- run: dart pub global activate melos ${{ env.MELOS_VERSION }} && melos bs
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt
- name: Build the XCFramework
run: melos run build:apple -- dev
- name: Copy the XCFramework to the needed location
run: |
CURR_VERSION=wasm_run-v`awk '/^version: /{print $2}' packages/wasm_run/pubspec.yaml`
cp platform-build/WasmRun.xcframework.zip packages/wasm_run_flutter/macos/Frameworks/$CURR_VERSION.zip
echo Copied file!
- name: Build Flutter MacOS example
working-directory: packages/wasm_run_flutter/example
run: flutter build macos --target=integration_test/main_test.dart --debug
- name: Run Flutter integration tests
working-directory: packages/wasm_run_flutter/example
run: flutter test -d macos integration_test --timeout "1200s" # 20 minutes
# Web Browser tests
- run: |
git clone https://github.com/flutter/web_installers.git
cd web_installers/packages/web_drivers
dart pub get
if: always()
# Safari
- run: dart lib/web_driver_installer.dart safaridriver &
working-directory: web_installers/packages/web_drivers
id: safaridriver
if: always()
# - run: sudo safaridriver --enable
# id: safaridriver
# if: always()
- run: dart run test -p safari --timeout "600s" # 10 minutes
working-directory: packages/wasm_run
if: always() && steps.safaridriver.outcome == 'success'
- run: flutter drive --driver=test_driver/integration_test.dart --target=integration_test/main_test.dart -d web-server --browser-name=safari --driver-port=4444
working-directory: packages/wasm_run_flutter/example
if: always() && steps.safaridriver.outcome == 'success'
# Chrome
- name: Install and run Chrome Driver
run: ${CHROMEWEBDRIVER}/chromedriver --port=4445 &
id: chromedriver
if: always()
- run: dart run test -p chrome
working-directory: packages/wasm_run
if: always() && steps.chromedriver.outcome == 'success'
- run: flutter drive --driver=test_driver/integration_test.dart --target=integration_test/main_test.dart -d web-server --browser-name=chrome --driver-port=4445
working-directory: packages/wasm_run_flutter/example
if: always() && steps.chromedriver.outcome == 'success'
# Firefox
- name: Install and run Firefox Driver
run: ${GECKOWEBDRIVER}/geckodriver --port=4446 &
id: firefoxdriver
if: always()
- run: dart run test -p firefox
working-directory: packages/wasm_run
if: always() && steps.firefoxdriver.outcome == 'success'
- run: flutter drive --driver=test_driver/integration_test.dart --target=integration_test/main_test.dart -d web-server --browser-name=firefox --driver-port=4446
working-directory: packages/wasm_run_flutter/example
if: always() && steps.firefoxdriver.outcome == 'success'
windows_integration_test:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
channel: ${{ env.FLUTTER_CHANNEL }}
- run: dart pub global activate melos ${{ env.MELOS_VERSION }} && melos bs
- uses: goto-bus-stop/setup-zig@v2
- uses: KyleMayes/install-llvm-action@v1
with:
version: "15"
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt
- name: Build the binaries
run: melos run build:other -- dev
- name: Copy the binaries to the needed location
shell: bash
run: |
CURR_VERSION=wasm_run-v`awk '/^version: /{print $2}' packages/wasm_run/pubspec.yaml`
cp platform-build/other.tar.gz packages/wasm_run_flutter/windows/$CURR_VERSION.tar.gz
echo Copied file!
- name: Run Flutter integration tests
working-directory: packages/wasm_run_flutter/example
run: flutter test -d windows integration_test
linux_integration_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install dependencies for flutter integration test
run: sudo apt update && sudo apt-get install -y libglu1-mesa ninja-build clang cmake pkg-config libgtk-3-dev liblzma-dev
- uses: pyvista/setup-headless-display-action@v1
- uses: subosito/flutter-action@v2
with:
channel: ${{ env.FLUTTER_CHANNEL }}
- run: dart pub global activate melos ${{ env.MELOS_VERSION }} && melos bs
- uses: goto-bus-stop/setup-zig@v2
- uses: KyleMayes/install-llvm-action@v1
with:
version: "15"
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt
- name: Build the binaries
run: melos run build:other -- dev
- name: Copy the binaries to the needed location
run: |
CURR_VERSION=wasm_run-v`awk '/^version: /{print $2}' packages/wasm_run/pubspec.yaml`
cp platform-build/other.tar.gz packages/wasm_run_flutter/linux/$CURR_VERSION.tar.gz
echo Copied file!
- name: Run Flutter integration tests
working-directory: packages/wasm_run_flutter/example
run: flutter test -d linux integration_test
ios_integration_test:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
channel: ${{ env.FLUTTER_CHANNEL }}
- run: dart pub global activate melos ${{ env.MELOS_VERSION }} && melos bs
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt
- name: Start iOS Simulator
run: |
DEVICE_ID=$(xcrun xctrace list devices | grep iPhone | head -1 | awk '{print $NF}' | tr -d '()')
echo "DEVICE_ID=$DEVICE_ID" >> $GITHUB_ENV
xcrun simctl boot $DEVICE_ID
- name: Build the XCFramework
run: melos run build:apple -- dev
- name: Copy the XCFramework to the needed location
run: |
CURR_VERSION=wasm_run-v`awk '/^version: /{print $2}' packages/wasm_run/pubspec.yaml`
cp platform-build/WasmRun.xcframework.zip packages/wasm_run_flutter/ios/Frameworks/$CURR_VERSION.zip
echo Copied file!
- name: Run Flutter integration tests
working-directory: packages/wasm_run_flutter/example
run: flutter test -d ${{ env.DEVICE_ID }} integration_test
android_integration_test:
runs-on: macos-latest
strategy:
matrix:
arch: ["arm64-v8a", "x86_64"]
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
channel: ${{ env.FLUTTER_CHANNEL }}
- run: dart pub global activate melos ${{ env.MELOS_VERSION }} && melos bs
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt
- uses: nttld/setup-ndk@v1
with:
ndk-version: r25b
- uses: actions/setup-java@v3
with:
distribution: zulu
java-version: "11.x"
- name: Build the binaries
run: melos run build:android -- dev
- name: Copy the binaries to the needed location
run: |
CURR_VERSION=wasm_run-v`awk '/^version: /{print $2}' packages/wasm_run/pubspec.yaml`
cp platform-build/android.tar.gz packages/wasm_run_flutter/android/$CURR_VERSION.tar.gz
echo Copied file!
- name: Build Flutter Android APK example
working-directory: packages/wasm_run_flutter/example
run: flutter build apk --target=integration_test/main_test.dart --debug
- name: Run Flutter integration tests
uses: Wandalen/wretry.action@master # sometimes android tests are flaky
with:
attempt_limit: 5
action: reactivecircus/android-emulator-runner@v2
with: |
api-level: 33
target: google_apis
arch: x86_64
ram-size: 1024M
disk-size: 2048M
arch: ${{ matrix.arch }}
working-directory: packages/wasm_run_flutter/example
script: flutter test -d `flutter devices | grep android | tr ' ' '\n' | grep emulator-` integration_test
android_integration_test_cached:
runs-on: macos-latest
strategy:
matrix:
arch: ["arm64-v8a", "x86_64"]
api-level: [33]
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
channel: ${{ env.FLUTTER_CHANNEL }}
- run: dart pub global activate melos ${{ env.MELOS_VERSION }} && melos bs
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt
- uses: nttld/setup-ndk@v1
with:
ndk-version: r25b
- uses: actions/setup-java@v3
with:
distribution: zulu
java-version: "11.x"
- name: Build the binaries
run: melos run build:android -- dev
- name: Copy the binaries to the needed location
run: |
CURR_VERSION=wasm_run-v`awk '/^version: /{print $2}' packages/wasm_run/pubspec.yaml`
cp platform-build/android.tar.gz packages/wasm_run_flutter/android/$CURR_VERSION.tar.gz
echo Copied file!
- name: Gradle cache
uses: gradle/gradle-build-action@v2
- name: AVD cache
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.arch }}-${{ 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
avd-name: avd-${{ matrix.arch }}-${{ matrix.api-level }}
target: google_apis
arch: ${{ matrix.arch }}
ram-size: 1024M
disk-size: 2048M
script: echo "Generated AVD snapshot for caching."
- name: Run tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
force-avd-creation: false
# default: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
avd-name: avd-${{ matrix.arch }}-${{ matrix.api-level }}
target: google_apis
arch: ${{ matrix.arch }}
ram-size: 1024M
disk-size: 2048M
script: cd packages/wasm_run_flutter/example && flutter test -d `flutter devices | grep android | tr ' ' '\n' | grep emulator-` integration_test && echo "Finished Android integration tests"