Fix the build and other improvements #306
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build & Test | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
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" |