From 268ca279937b7ce2611a195d6106212601c9076b Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Mon, 13 Jun 2022 10:39:46 +0200 Subject: [PATCH] Run dart tests on M1 (#649) --- .github/workflows/ci.yml | 213 +++++--------------------- .github/workflows/prepare-release.yml | 1 - test/app_test.dart | 3 - test/configuration_test.dart | 2 - test/credentials_test.dart | 4 - test/list_test.dart | 3 - test/realm_object_test.dart | 3 - test/realm_test.dart | 2 - test/results_test.dart | 3 - test/session_test.dart | 3 - test/subscription_test.dart | 3 - test/test.dart | 20 +++ 12 files changed, 61 insertions(+), 199 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 27f0c98d6..33fd35abc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,6 +43,8 @@ jobs: package: flutter - platform: android package: flutter + - platform: macos-arm + package: dart runs-on: ubuntu-latest name: Deploy apps ${{ matrix.platform }} for ${{ matrix.package }} timeout-minutes: 20 @@ -71,14 +73,10 @@ jobs: runs-on: ubuntu-latest name: Cleanup cluster needs: - - tests-linux - - flutter-linux - - tests-macos - - flutter-macos - - tests-windows - - flutter-windows + - flutter-desktop - flutter-ios - flutter-android + - tests-dart if: always() timeout-minutes: 5 steps: @@ -247,14 +245,23 @@ jobs: librealm-android-armeabi-v7a librealm-android-arm64-v8a -# Linux jobs +# Dart jobs - tests-linux: - runs-on: ubuntu-latest - name: Tests Linux + tests-dart: + runs-on: ${{ matrix.platform == 'linux' && 'ubuntu' || matrix.platform }}-${{ matrix.architecture || 'latest' }} + name: Tests ${{ matrix.platform }} ${{ matrix.architecture }} + strategy: + fail-fast: false + matrix: + include: + - platform: macos + - platform: macos + architecture: arm + - platform: windows + - platform: linux env: BAAS_CLUSTER: ${{ needs.deploy-cluster.outputs.clusterName }} - BAAS_DIFFERENTIATOR: dart-linux + BAAS_DIFFERENTIATOR: dart-${{ matrix.platform }}${{ matrix.architecture && format('-{0}', matrix.architecture) || '' }} needs: - baas-matrix - deploy-cluster @@ -265,29 +272,39 @@ jobs: with: submodules: false + - name: Cleanup Workspace + run: git clean -fdx + - name: Fetch artifacts uses: actions/download-artifact@v2 with: - name: librealm-linux - path: binary/linux + name: librealm-${{ matrix.platform }} + path: binary/${{ matrix.platform }} - name : Setup Dart SDK uses: dart-lang/setup-dart@main with: sdk: stable + architecture: ${{ matrix.architecture == 'arm' && 'arm64' || 'x64'}} - name: Install dependencies run: dart pub get - name: Run tests - run: dart test -r expanded -j 1 --test-randomize-ordering-seed random + run: ${{ matrix.architecture == 'arm' && 'arch -arm64 ' || '' }}dart test -r expanded -j 1 --test-randomize-ordering-seed random - flutter-linux: - runs-on: ubuntu-latest - name: Flutter Tests Linux +# Flutter jobs + + flutter-desktop: + runs-on: ${{ matrix.platform == 'linux' && 'ubuntu' || matrix.platform }}-latest + strategy: + fail-fast: false + matrix: + platform: [ 'macos', 'windows', 'linux'] + name: Flutter ${{ matrix.platform }} env: BAAS_CLUSTER: ${{ needs.deploy-cluster.outputs.clusterName }} - BAAS_DIFFERENTIATOR: flutter-linux + BAAS_DIFFERENTIATOR: flutter-${{ matrix.platform }} needs: - baas-matrix - deploy-cluster @@ -299,164 +316,20 @@ jobs: submodules: false - name: Setup GTK + if: ${{ matrix.platform == 'linux' }} run: | sudo apt-get update -y sudo apt-get install -y libgtk-3-dev xvfb - name: Setup Ninja + if: ${{ matrix.platform == 'linux' }} uses: seanmiddleditch/gha-setup-ninja@master - name: Fetch artifacts uses: actions/download-artifact@v2 with: - name: librealm-linux - path: binary/linux - - - name: Setup Flutter - uses: subosito/flutter-action@v2 - with: - channel: 'stable' - - - name: Enable Flutter Desktop support - run: flutter config --enable-linux-desktop - - - name: Install dependencies - run: flutter pub get - - - name: Run tests - run: xvfb-run flutter drive -d linux --target=test_driver/app.dart --suppress-analytics --dart-entrypoint-args="" #--verbose #-a="Some test name" - working-directory: ./flutter/realm_flutter/tests - -# macOS jobs - - tests-macos: - runs-on: macos-latest - name: Tests macOS - env: - BAAS_CLUSTER: ${{ needs.deploy-cluster.outputs.clusterName }} - BAAS_DIFFERENTIATOR: dart-macos - needs: - - baas-matrix - - deploy-cluster - - build-native - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: false - - - name: Fetch artifacts - uses: actions/download-artifact@v2 - with: - name: librealm-macos - path: binary/macos - - - name : Setup Dart SDK - uses: dart-lang/setup-dart@main - with: - sdk: stable - - - name: Install dependencies - run: dart pub get - - - name: Run tests - run: dart test -r expanded -j 1 --test-randomize-ordering-seed random - - flutter-macos: - runs-on: macos-latest - name: Flutter Tests macOS - env: - BAAS_CLUSTER: ${{ needs.deploy-cluster.outputs.clusterName }} - BAAS_DIFFERENTIATOR: flutter-macos - needs: - - baas-matrix - - deploy-cluster - - build-native - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: false - - - name: Fetch artifacts - uses: actions/download-artifact@v2 - with: - name: librealm-macos - path: binary/macos - - - name: Setup Flutter - uses: subosito/flutter-action@v2 - with: - channel: 'stable' - - - name: Enable Flutter Desktop support - run: flutter config --enable-macos-desktop - - - name: Install dependencies - run: flutter pub get - - - name: Run tests - run: flutter drive -d macos --target=test_driver/app.dart --suppress-analytics --dart-entrypoint-args="" #--verbose #-a="Some test name" - working-directory: ./flutter/realm_flutter/tests - -# Windows jobs - - tests-windows: - runs-on: windows-latest - name: Tests Windows - env: - BAAS_CLUSTER: ${{ needs.deploy-cluster.outputs.clusterName }} - BAAS_DIFFERENTIATOR: dart-windows - needs: - - baas-matrix - - deploy-cluster - - build-native - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: false - - - name: Fetch artifacts - uses: actions/download-artifact@v2 - with: - name: librealm-windows - path: binary/windows - - - name : Setup Dart SDK - uses: dart-lang/setup-dart@main - with: - sdk: stable - - - name: Install dependencies - run: dart pub get - - - name: Run tests - run: | - dart test -r expanded -j 1 --test-randomize-ordering-seed random - - flutter-windows: - # TODO: build on windows-latest - runs-on: windows-2019 - name: Flutter Tests Windows - env: - BAAS_CLUSTER: ${{ needs.deploy-cluster.outputs.clusterName }} - BAAS_DIFFERENTIATOR: flutter-windows - needs: - - baas-matrix - - deploy-cluster - - build-native - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: false - - - name: Fetch artifacts - uses: actions/download-artifact@v2 - with: - name: librealm-windows - path: binary/windows + name: librealm-${{ matrix.platform }} + path: binary/${{ matrix.platform }} - name: Setup Flutter uses: subosito/flutter-action@v2 @@ -464,17 +337,15 @@ jobs: channel: 'stable' - name: Enable Flutter Desktop support - run: flutter config --enable-windows-desktop + run: flutter config --enable-${{ matrix.platform }}-desktop - name: Install dependencies run: flutter pub get - name: Run tests - run: flutter drive -d windows --target=test_driver/app.dart --suppress-analytics --dart-entrypoint-args="" #--verbose #-a="Some test name" + run: ${{ matrix.platform == 'linux' && 'xvfb-run ' || '' }}flutter drive -d ${{ matrix.platform }} --target=test_driver/app.dart --suppress-analytics --dart-entrypoint-args="" #--verbose #-a="Some test name" working-directory: ./flutter/realm_flutter/tests -# iOS jobs - flutter-ios: runs-on: macos-latest name: Flutter Tests iOS @@ -520,8 +391,6 @@ jobs: flutter drive --target=test_driver/app.dart --dart-define=testName="" --suppress-analytics working-directory: ./flutter/realm_flutter/tests -# Android jobs - flutter-android: runs-on: macos-latest name: Flutter Tests Android diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index 6820f16e1..593dc2c40 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -21,7 +21,6 @@ jobs: changelog: ${{ github.workspace }}/CHANGELOG.md version-suffix: '+beta' - - name: Update pubspec.yaml uses: jacobtomlinson/gha-find-replace@b76729678e8d52dadb12e0e16454a93e301a919d #! 2.0.0 with: diff --git a/test/app_test.dart b/test/app_test.dart index 87ad58b37..31d5957eb 100644 --- a/test/app_test.dart +++ b/test/app_test.dart @@ -28,8 +28,6 @@ import 'realm_object_test.dart'; import 'test.dart'; Future main([List? args]) async { - print("Current PID $pid"); - await setupTests(args); test('AppConfiguration can be initialized', () { @@ -184,7 +182,6 @@ Future main([List? args]) async { expect(app.users, [user1, user]); }); - baasTest('Realm.logger', (configuration) async { Realm.logger = Logger.detached(generateRandomString(10))..level = RealmLogLevel.all; configuration = AppConfiguration( diff --git a/test/configuration_test.dart b/test/configuration_test.dart index 43da31903..f7323c3a5 100644 --- a/test/configuration_test.dart +++ b/test/configuration_test.dart @@ -24,8 +24,6 @@ import '../lib/realm.dart'; import 'test.dart'; Future main([List? args]) async { - print("Current PID $pid"); - await setupTests(args); test('Configuration can be created', () { diff --git a/test/credentials_test.dart b/test/credentials_test.dart index 89cbe1bf3..716c8cf90 100644 --- a/test/credentials_test.dart +++ b/test/credentials_test.dart @@ -16,8 +16,6 @@ // //////////////////////////////////////////////////////////////////////////////// -import 'dart:io'; - import 'package:test/test.dart' hide test, throws; import '../lib/realm.dart'; import 'test.dart'; @@ -25,8 +23,6 @@ import 'test.dart'; Future main([List? args]) async { const String strongPassword = "SWV23R#@T#VFQDV"; - print("Current PID $pid"); - await setupTests(args); test('Credentials anonymous', () { diff --git a/test/list_test.dart b/test/list_test.dart index 5494a3150..cca7896e5 100644 --- a/test/list_test.dart +++ b/test/list_test.dart @@ -18,14 +18,11 @@ // ignore_for_file: unused_local_variable -import 'dart:io'; import 'package:test/test.dart' hide test, throws; import '../lib/realm.dart'; import 'test.dart'; Future main([List? args]) async { - print("Current PID $pid"); - await setupTests(args); test('Lists add object with a list property', () { diff --git a/test/realm_object_test.dart b/test/realm_object_test.dart index 999e96c5b..b89c39670 100644 --- a/test/realm_object_test.dart +++ b/test/realm_object_test.dart @@ -21,7 +21,6 @@ import 'dart:io'; import 'package:test/test.dart' hide test, throws; import '../lib/realm.dart'; -import '../lib/realm.dart'; import 'test.dart'; @@ -84,8 +83,6 @@ extension on DateTime { } Future main([List? args]) async { - print("Current PID $pid"); - await setupTests(args); test('RealmObject get property', () { diff --git a/test/realm_test.dart b/test/realm_test.dart index dafc1821f..f0dd9c653 100644 --- a/test/realm_test.dart +++ b/test/realm_test.dart @@ -25,8 +25,6 @@ import '../lib/realm.dart'; import 'test.dart'; Future main([List? args]) async { - print("Current PID $pid"); - await setupTests(args); test('Realm can be created', () { diff --git a/test/results_test.dart b/test/results_test.dart index c66e1934e..6f2c0030c 100644 --- a/test/results_test.dart +++ b/test/results_test.dart @@ -18,14 +18,11 @@ // ignore_for_file: unused_local_variable -import 'dart:io'; import 'package:test/test.dart' hide test, throws; import '../lib/realm.dart'; import 'test.dart'; Future main([List? args]) async { - print("Current PID $pid"); - await setupTests(args); test('Results all should not return null', () { diff --git a/test/session_test.dart b/test/session_test.dart index 442fe1ff2..6f59791e3 100644 --- a/test/session_test.dart +++ b/test/session_test.dart @@ -17,7 +17,6 @@ //////////////////////////////////////////////////////////////////////////////// import 'dart:async'; -import 'dart:io'; import 'package:test/test.dart' hide test, throws; import '../lib/realm.dart'; @@ -25,8 +24,6 @@ import '../lib/src/session.dart' show SessionInternal; import 'test.dart'; Future main([List? args]) async { - print("Current PID $pid"); - await setupTests(args); test('Realm.syncSession throws on wrong configuration', () { diff --git a/test/subscription_test.dart b/test/subscription_test.dart index 18b1fe890..2fa047126 100644 --- a/test/subscription_test.dart +++ b/test/subscription_test.dart @@ -26,7 +26,6 @@ import 'package:test/expect.dart'; import '../lib/realm.dart'; import '../lib/src/native/realm_core.dart'; import '../lib/src/subscription.dart'; -import '../lib/src/configuration.dart'; import 'test.dart'; @@ -48,8 +47,6 @@ void testSubscriptions(String name, FutureOr Function(Realm) tester) async } Future main([List? args]) async { - print("Current PID $pid"); - await setupTests(args); test('Get subscriptions throws on wrong configuration', () { diff --git a/test/test.dart b/test/test.dart index 0a8037c83..ec8e596c4 100644 --- a/test/test.dart +++ b/test/test.dart @@ -18,6 +18,7 @@ import 'dart:async'; import 'dart:collection'; +import 'dart:ffi'; import 'dart:io'; import 'dart:math'; import 'package:meta/meta.dart'; @@ -226,6 +227,8 @@ Future setupTests(List? args) async { } }); }); + + await _printPlatformInfo(); } Matcher throws([String? message]) => throwsA(isA().having((dynamic exception) => exception.message, 'message', contains(message ?? ''))); @@ -429,3 +432,20 @@ extension RealmObjectTest on RealmObject { } void clearCachedApps() => realmCore.clearCachedApps(); + +Future _printPlatformInfo() async { + final pointerSize = sizeOf() * 8; + final os = Platform.operatingSystem; + String? cpu; + + if (!isFlutterPlatform) { + if (Platform.isWindows) { + cpu = Platform.environment['PROCESSOR_ARCHITECTURE']; + } else { + final info = await Process.run('uname', ['-m']); + cpu = info.stdout.toString().replaceAll('\n', ''); + } + } + + print('Current PID $pid; OS $os, $pointerSize bit, CPU ${cpu ?? 'unknown'}'); +}