Update Android emulator #5320
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: Realm Dart CI | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
pull_request: | |
env: | |
REALM_CI: true | |
concurrency: | |
group: ${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
build-windows: | |
name: Build Windows | |
uses: ./.github/workflows/build-native.yml | |
with: | |
runner: windows-latest | |
binary: windows | |
build: '["windows"]' | |
build-macos: | |
name: Build MacOS | |
uses: ./.github/workflows/build-native.yml | |
with: | |
runner: macos-latest | |
binary: macos | |
build: '["macos"]' | |
build-linux: | |
name: Build Linux | |
uses: ./.github/workflows/build-native.yml | |
with: | |
runner: ubuntu-20.04 # Building on the lowest possible Linux (Ubuntu) version for compatibility | |
binary: linux | |
build: '["linux"]' | |
build-android: | |
name: Build Android | |
uses: ./.github/workflows/build-native.yml | |
with: | |
runner: ubuntu-20.04 | |
binary: android | |
build: '["android-x86_64", "android-armeabi-v7a", "android-arm64-v8a"]' | |
build-ios: | |
name: Build IOS | |
uses: ./.github/workflows/build-native.yml | |
with: | |
runner: macos-14 | |
binary: ios | |
build: '["ios-device", "ios-simulator"]' | |
build-android-combined: | |
name: Build combine Android | |
needs: build-android | |
uses: ./.github/workflows/binary-combine-android.yml | |
build-ios-xcframework: | |
name: Build combine iOS | |
needs: build-ios | |
uses: ./.github/workflows/binary-combine-ios.yml | |
# Dart jobs | |
deploy-cluster-dart-windows: | |
name: Deploy Cluster for Dart Windows | |
uses: ./.github/workflows/deploy-baas.yml | |
secrets: inherit | |
with: | |
differentiator: dw${{ github.run_id }}${{ github.run_attempt }} | |
dart-tests-windows: | |
name: Dart Tests Windows | |
uses: ./.github/workflows/dart-desktop-tests.yml | |
needs: | |
- build-windows | |
- deploy-cluster-dart-windows | |
secrets: inherit | |
with: | |
runner: windows-latest | |
differentiator: dw${{ github.run_id }}${{ github.run_attempt }} | |
cleanup-cluster-dart-windows: | |
name: Cleanup Cluster for Dart Windows | |
uses: ./.github/workflows/terminate-baas.yml | |
if: always() | |
needs: | |
- dart-tests-windows | |
secrets: inherit | |
with: | |
differentiator: dw${{ github.run_id }}${{ github.run_attempt }} | |
deploy-cluster-dart-macos: | |
name: Deploy Cluster for Dart MacOS | |
uses: ./.github/workflows/deploy-baas.yml | |
secrets: inherit | |
with: | |
differentiator: dm${{ github.run_id }}${{ github.run_attempt }} | |
dart-tests-macos: | |
name: Dart Tests MacOS | |
uses: ./.github/workflows/dart-desktop-tests.yml | |
needs: | |
- build-macos | |
- deploy-cluster-dart-macos | |
secrets: inherit | |
with: | |
runner: macos-13 | |
differentiator: dm${{ github.run_id }}${{ github.run_attempt }} | |
cleanup-cluster-dart-macos: | |
name: Cleanup Cluster for Dart macOS | |
uses: ./.github/workflows/terminate-baas.yml | |
if: always() | |
needs: | |
- dart-tests-macos | |
secrets: inherit | |
with: | |
differentiator: dm${{ github.run_id }}${{ github.run_attempt }} | |
deploy-cluster-dart-macos-arm: | |
name: Deploy Cluster for Dart MacOS Arm | |
uses: ./.github/workflows/deploy-baas.yml | |
secrets: inherit | |
with: | |
differentiator: dma${{ github.run_id }}${{ github.run_attempt }} | |
dart-tests-macos-arm: | |
name: Dart Tests MacOS Arm | |
uses: ./.github/workflows/dart-desktop-tests.yml | |
needs: | |
- build-macos | |
- deploy-cluster-dart-macos-arm | |
secrets: inherit | |
with: | |
runner: macos-14 | |
arch: arm64 | |
differentiator: dma${{ github.run_id }}${{ github.run_attempt }} | |
cleanup-cluster-dart-macos-arm: | |
name: Cleanup Cluster for Dart macOS Arm | |
uses: ./.github/workflows/terminate-baas.yml | |
if: always() | |
needs: | |
- dart-tests-macos-arm | |
secrets: inherit | |
with: | |
differentiator: dma${{ github.run_id }}${{ github.run_attempt }} | |
deploy-cluster-dart-linux: | |
name: Deploy Cluster for Dart Linux | |
uses: ./.github/workflows/deploy-baas.yml | |
secrets: inherit | |
with: | |
differentiator: dl${{ github.run_id }}${{ github.run_attempt }} | |
dart-tests-linux: | |
name: Dart Tests Linux | |
uses: ./.github/workflows/dart-desktop-tests.yml | |
needs: | |
- build-linux | |
- deploy-cluster-dart-linux | |
secrets: inherit | |
with: | |
runner: ubuntu-latest | |
differentiator: dl${{ github.run_id }}${{ github.run_attempt }} | |
cleanup-cluster-dart-linux: | |
name: Cleanup Cluster for Dart Linux | |
uses: ./.github/workflows/terminate-baas.yml | |
if: always() | |
needs: | |
- dart-tests-linux | |
secrets: inherit | |
with: | |
differentiator: dl${{ github.run_id }}${{ github.run_attempt }} | |
# Flutter jobs | |
deploy-cluster-flutter-windows: | |
name: Deploy Cluster for Flutter Windows | |
uses: ./.github/workflows/deploy-baas.yml | |
secrets: inherit | |
with: | |
differentiator: fw${{ github.run_id }}${{ github.run_attempt }} | |
flutter-tests-windows: | |
name: Flutter Tests Windows | |
uses: ./.github/workflows/flutter-desktop-tests.yml | |
needs: | |
- build-windows | |
- deploy-cluster-flutter-windows | |
secrets: inherit | |
with: | |
runner: windows-latest | |
differentiator: fw${{ github.run_id }}${{ github.run_attempt }} | |
cleanup-cluster-flutter-windows: | |
name: Cleanup Cluster for Flutter Windows | |
uses: ./.github/workflows/terminate-baas.yml | |
if: always() | |
needs: | |
- flutter-tests-windows | |
secrets: inherit | |
with: | |
differentiator: fw${{ github.run_id }}${{ github.run_attempt }} | |
deploy-cluster-flutter-macos: | |
name: Deploy Cluster for Flutter MacOS | |
uses: ./.github/workflows/deploy-baas.yml | |
secrets: inherit | |
with: | |
differentiator: fm${{ github.run_id }}${{ github.run_attempt }} | |
flutter-tests-macos: | |
name: Flutter Tests MacOS | |
uses: ./.github/workflows/flutter-desktop-tests.yml | |
needs: | |
- build-macos | |
- deploy-cluster-flutter-macos | |
secrets: inherit | |
with: | |
runner: macos-13 | |
differentiator: fm${{ github.run_id }}${{ github.run_attempt }} | |
cleanup-cluster-flutter-macos: | |
name: Cleanup Cluster for Flutter macOS | |
uses: ./.github/workflows/terminate-baas.yml | |
if: always() | |
needs: | |
- flutter-tests-macos | |
secrets: inherit | |
with: | |
differentiator: fm${{ github.run_id }}${{ github.run_attempt }} | |
deploy-cluster-flutter-macos-arm: | |
name: Deploy Cluster for Flutter MacOS Arm | |
uses: ./.github/workflows/deploy-baas.yml | |
secrets: inherit | |
with: | |
differentiator: fma${{ github.run_id }}${{ github.run_attempt }} | |
flutter-tests-macos-arm: | |
name: Flutter Tests MacOS Arm | |
uses: ./.github/workflows/flutter-desktop-tests.yml | |
needs: | |
- build-macos | |
- deploy-cluster-flutter-macos-arm | |
secrets: inherit | |
with: | |
runner: macos-14 | |
arch: arm64 | |
differentiator: fma${{ github.run_id }}${{ github.run_attempt }} | |
cleanup-cluster-flutter-macos-arm: | |
name: Cleanup Cluster for Flutter macOS Arm | |
uses: ./.github/workflows/terminate-baas.yml | |
if: always() | |
needs: | |
- flutter-tests-macos-arm | |
secrets: inherit | |
with: | |
differentiator: fma${{ github.run_id }}${{ github.run_attempt }} | |
deploy-cluster-flutter-linux: | |
name: Deploy Cluster for Flutter Linux | |
uses: ./.github/workflows/deploy-baas.yml | |
secrets: inherit | |
with: | |
differentiator: fl${{ github.run_id }}${{ github.run_attempt }} | |
flutter-tests-linux: | |
name: Flutter Tests Linux | |
uses: ./.github/workflows/flutter-desktop-tests.yml | |
needs: | |
- build-linux | |
- deploy-cluster-flutter-linux | |
secrets: inherit | |
with: | |
runner: ubuntu-latest | |
differentiator: fl${{ github.run_id }}${{ github.run_attempt }} | |
cleanup-cluster-flutter-linux: | |
name: Cleanup Cluster for Flutter Linux | |
uses: ./.github/workflows/terminate-baas.yml | |
if: always() | |
needs: | |
- flutter-tests-linux | |
secrets: inherit | |
with: | |
differentiator: fl${{ github.run_id }}${{ github.run_attempt }} | |
deploy-cluster-flutter-ios: | |
name: Deploy Cluster for Flutter iOS | |
uses: ./.github/workflows/deploy-baas.yml | |
secrets: inherit | |
with: | |
differentiator: fi${{ github.run_id }}${{ github.run_attempt }} | |
flutter-tests-ios: | |
runs-on: macos-14 | |
name: Flutter Tests iOS | |
timeout-minutes: 45 | |
needs: | |
- deploy-cluster-flutter-ios | |
- build-ios-xcframework | |
env: | |
BAAS_DIFFERENTIATOR: fi${{ github.run_id }}${{ github.run_attempt }} | |
BAAS_BAASAAS_API_KEY: ${{ secrets.BAASAAS_API_KEY}} | |
defaults: | |
run: | |
working-directory: packages/realm/tests | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: "recursive" | |
- name: Setup runner | |
uses: ./.github/actions/setup-runner | |
- name: Bump ulimit | |
run: | | |
ulimit -n | |
ulimit -n 10240 | |
- name: Enable ccache | |
run: echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> $GITHUB_PATH | |
- name: Fetch artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: librealm-ios | |
path: packages/realm_dart/binary/ios | |
- name: Launch Simulator | |
uses: futureware-tech/simulator-action@v3 | |
with: | |
model: "iPhone SE (3rd generation)" | |
os: "iOS" | |
os_version: ">= 14.0" | |
- name: Run tests on iOS Simulator | |
run: | | |
flutter test integration_test/all_tests.dart \ | |
--dart-define=BAAS_BAASAAS_API_KEY=$BAAS_BAASAAS_API_KEY \ | |
--dart-define=BAAS_DIFFERENTIATOR=$BAAS_DIFFERENTIATOR \ | |
--file-reporter=json:test-results.json \ | |
--suppress-analytics | |
- name: Publish Test Report | |
uses: dorny/[email protected] | |
if: success() || failure() | |
with: | |
name: Test Results Flutter iOS | |
path: test-results.json | |
reporter: dart-json | |
only-summary: true | |
working-directory: packages/realm/tests | |
cleanup-cluster-flutter-ios: | |
name: Cleanup Cluster for Flutter iOS | |
uses: ./.github/workflows/terminate-baas.yml | |
if: always() | |
needs: | |
- flutter-tests-ios | |
secrets: inherit | |
with: | |
differentiator: fi${{ github.run_id }}${{ github.run_attempt }} | |
deploy-cluster-flutter-android: | |
name: Deploy Cluster for Flutter Android | |
uses: ./.github/workflows/deploy-baas.yml | |
secrets: inherit | |
with: | |
differentiator: fa${{ github.run_id }}${{ github.run_attempt }} | |
flutter-tests-android: | |
runs-on: ubuntu-latest | |
name: Flutter Tests Android | |
timeout-minutes: 45 | |
needs: | |
- deploy-cluster-flutter-android | |
- build-android-combined | |
env: | |
BAAS_DIFFERENTIATOR: fa${{ github.run_id }}${{ github.run_attempt }} | |
BAAS_BAASAAS_API_KEY: ${{ secrets.BAASAAS_API_KEY}} | |
defaults: | |
run: | |
working-directory: packages/realm/tests | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: "recursive" | |
- 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: Setup Gradle | |
uses: gradle/actions/setup-gradle@v3 | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: "temurin" | |
java-version: 11 | |
- name: Fetch artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: librealm-android | |
path: packages/realm_dart/binary/android | |
- name: Setup Runner | |
uses: ./.github/actions/setup-runner | |
# Hack to free up space on the runner to ensure we have enough diskspace to run the emulator | |
- name: Remove unnecessary files (dotnet, etc.) | |
run: | | |
sudo rm -rf /usr/share/dotnet | |
# TODO: Move CI run tests on Android Emulator into device farm https://github.com/realm/realm-dart/issues/691 | |
- name: Setup Android Emulator cache | |
uses: actions/cache@v4 | |
id: avd-cache | |
with: | |
path: | | |
~/.android/avd/* | |
~/.android/adb* | |
key: avd-33-x86_64 | |
- name: Create Android Emulator and generate snapshot for caching | |
if: ${{ steps.avd-cache.outputs.cache-hit != 'true' }} | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
force-avd-creation: false | |
disable-animations: true | |
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
api-level: 35 | |
target: google_apis_ps16k | |
arch: x86_64 | |
ndk: 27.0.12077973 | |
cmake: 3.10.2.4988404 | |
script: echo "Generated Emulator snapshot for caching." | |
- name: Run tests on Android Emulator | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
force-avd-creation: false | |
disable-animations: true | |
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
api-level: 35 | |
target: google_apis_ps16k | |
arch: x86_64 | |
ndk: 27.0.12077973 | |
cmake: 3.10.2.4988404 | |
script: cd packages/realm/tests && flutter test integration_test/all_tests.dart --dart-define=BAAS_BAASAAS_API_KEY=$BAAS_BAASAAS_API_KEY --dart-define=BAAS_DIFFERENTIATOR=$BAAS_DIFFERENTIATOR --file-reporter=json:test-results.json --suppress-analytics | |
- name: Publish Test Report | |
uses: dorny/[email protected] | |
if: success() || failure() | |
with: | |
name: Test Results Flutter Android | |
path: test-results.json | |
reporter: dart-json | |
only-summary: true | |
working-directory: packages/realm/tests | |
cleanup-cluster-flutter-android: | |
name: Cleanup Cluster for Flutter Android | |
uses: ./.github/workflows/terminate-baas.yml | |
if: always() | |
needs: | |
- flutter-tests-android | |
secrets: inherit | |
with: | |
differentiator: fa${{ github.run_id }}${{ github.run_attempt }} | |
# Generator jobs | |
generator: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu, macos, windows] | |
defaults: | |
run: | |
shell: bash | |
working-directory: packages/realm_generator | |
runs-on: ${{ matrix.os }}-latest | |
name: Generator Tests | |
timeout-minutes: 30 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: "recursive" | |
- name: Setup Runner | |
uses: ./.github/actions/setup-runner | |
- name: Delete generated files in realm_dart | |
run: | | |
find . -name "*.g.dart" -delete | |
find . -name "*.realm.dart" -delete | |
working-directory: packages/realm_dart | |
- name: Run generator in realm_dart | |
run: | | |
dart pub get | |
dart run build_runner build --delete-conflicting-outputs | |
working-directory: packages/realm_dart | |
- name: Run generator in realm_dart/example | |
run: | | |
dart pub get | |
dart run build_runner build --delete-conflicting-outputs | |
working-directory: packages/realm_dart/example | |
- name: Run generator in realm/example | |
run: | | |
dart pub get | |
dart run build_runner build --delete-conflicting-outputs | |
working-directory: packages/realm/example | |
- name: Install LLVM | |
run: sudo apt update && sudo apt-get install -y libclang-dev | |
if: ${{ matrix.os == 'ubuntu' }} | |
- name: Run ffigen | |
run: >- | |
dart pub global activate ffigen && | |
dart pub global run ffigen --config ffigen.yaml | |
working-directory: packages/realm_dart/ | |
- name: Validate there are no uncommitted changes | |
run: | | |
changedFiles=$(git --no-pager diff -w) | |
if [ "$changedFiles" ]; then | |
git --no-pager diff -w | |
exit 1 | |
fi | |
coverage-finished: | |
needs: | |
- dart-tests-linux | |
runs-on: ubuntu-latest | |
steps: | |
- name: Coveralls Finished | |
id: publish-coverage | |
uses: coverallsapp/github-action@f350da2c033043742f89e8c0b7b5145a1616da6d | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
parallel-finished: true | |
slack-on-failure: | |
name: Report failure in main branch | |
needs: | |
- dart-tests-linux | |
- dart-tests-macos | |
- dart-tests-macos-arm | |
- dart-tests-windows | |
- flutter-tests-linux | |
- flutter-tests-macos | |
- flutter-tests-windows | |
- flutter-tests-ios | |
- flutter-tests-android | |
runs-on: ubuntu-latest | |
if: always() && github.ref == 'refs/heads/main' | |
steps: | |
# Run this action to set env.WORKFLOW_CONCLUSION | |
- uses: technote-space/workflow-conclusion-action@45ce8e0eb155657ab8ccf346ade734257fd196a5 | |
- uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f | |
if: ${{ github.ref == 'refs/heads/main' && env.WORKFLOW_CONCLUSION == 'FAILURE' }} | |
# Statuses: neutral, success, skipped, cancelled, timed_out, action_required, failure | |
with: | |
status: ${{ env.WORKFLOW_CONCLUSION }} | |
webhook-url: ${{ secrets.SLACK_DART_WEBHOOK }} | |
channel: "#realm-github-dart" | |
message: | | |
*<https://github.com/realm/realm-dart/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}|_{{workflow}}_ run id: ${{ github.run_id }} has status _{{jobStatus}}_ >* | |
<{{refUrl}}|`{{ref}}` - {{description}}> | |
{{#if description}}<{{diffUrl}}|branch: `{{diffRef}}`>{{/if}} | |
web-compile: | |
name: Compile for web | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: "recursive" | |
- name: Setup Runner | |
uses: ./.github/actions/setup-runner | |
- name: Compile to wasm | |
run: flutter build web --wasm -t integration_test/all_tests.dart | |
working-directory: packages/realm/tests/ | |
- name: Compile to js | |
run: flutter build web -t integration_test/all_tests.dart | |
working-directory: packages/realm/tests/ |