From 6ab63eb0abe5ca8940341cacad6ba90174de98cd Mon Sep 17 00:00:00 2001 From: Midori Date: Wed, 27 Mar 2024 19:12:47 +0900 Subject: [PATCH 01/15] Update ci.yml --- .github/workflows/ci.yml | 74 ++++++++++++++++++++++++++++++++++------ 1 file changed, 64 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 705508f..ff6b497 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,9 +11,11 @@ on: jobs: set-up: runs-on: ubuntu-latest + permissions: + actions: write steps: - - name: Cancel - uses: styfle/cancel-workflow-action@0.12.1 + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action with: access_token: ${{ github.token }} @@ -22,9 +24,9 @@ jobs: timeout-minutes: 60 strategy: matrix: - ios-version: [16,17] + ios-version: [17] fail-fast: false - runs-on: macos-13 + runs-on: macos-14 steps: - name: Check out uses: actions/checkout@v4 @@ -38,15 +40,67 @@ jobs: - name: Boot ios simulator uses: futureware-tech/simulator-action@v3 with: - model: iPhone 14 Pro Max + os: iOS + model: 'iPhone 15' os_version: ^${{ matrix.ios-version }} - - name: Build example + - name: Flutter Run timeout-minutes: 20 run: | cd example - flutter build ios --no-codesign + flutter run - #TODO: Integration tests - - #TODO: Android \ No newline at end of file + + android: + needs: set-up + timeout-minutes: 60 + runs-on: macos-14 + strategy: + matrix: + api-level: [34,33,32,31,30,29,28,27,26,25,24,23,22,21] + fail-fast: false + steps: + - name: Check out + uses: actions/checkout@v4 + + - name: Setup Flutter SDK + uses: subosito/flutter-action@v2 + with: + channel: beta + + - name: Install Flutter dependencies + run: flutter pub get ./example + + - name: Set up JDK + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: temurin + + - name: Cache Gradle + uses: actions/cache@v4 + with: + path: ~/.gradle/caches + key: gradle + + - name: Cache AVD + uses: actions/cache@v4 + id: cache-avd + with: + path: | + ~/.android/avd/* + ~/.android/adb* + key: avd-${{ matrix.api-level }} + + - name: Flutter Run + timeout-minutes: 20 + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: ${{ matrix.api-level }} + working-directory: ./example + arch: x86_64 + emulator-boot-timeout: 200 + disable-spellchecker: true + force-avd-creation: false + emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -camera-front none + script: flutter run \ No newline at end of file From efc9ca54a011ff8bfc8137a9c669c061a9870c22 Mon Sep 17 00:00:00 2001 From: Midori Date: Wed, 27 Mar 2024 19:17:38 +0900 Subject: [PATCH 02/15] Update cancel-workflow-action version --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ff6b497..05b1aa0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: actions: write steps: - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action + uses: styfle/cancel-workflow-action@v0.12 with: access_token: ${{ github.token }} From d8b1bc1e7b1d0ec57bcc0f13a7c1ad87143f5d59 Mon Sep 17 00:00:00 2001 From: Midori Date: Wed, 27 Mar 2024 19:18:55 +0900 Subject: [PATCH 03/15] Update cancel-workflow-action version --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 05b1aa0..e4d5e66 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: actions: write steps: - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@v0.12 + uses: styfle/cancel-workflow-action@0.12.1 with: access_token: ${{ github.token }} From 40fbe4c0bc0023a66688e09f21916f2a24e27ae2 Mon Sep 17 00:00:00 2001 From: Midori Date: Thu, 28 Mar 2024 12:11:45 +0900 Subject: [PATCH 04/15] Update runs-on in ci.yml to macos-13 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e4d5e66..4a4d32c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,7 +54,7 @@ jobs: android: needs: set-up timeout-minutes: 60 - runs-on: macos-14 + runs-on: macos-13 strategy: matrix: api-level: [34,33,32,31,30,29,28,27,26,25,24,23,22,21] From 0637bc74f230a13b8b493d009be39a537ca2df98 Mon Sep 17 00:00:00 2001 From: Midori Date: Thu, 28 Mar 2024 15:58:42 +0900 Subject: [PATCH 05/15] Add Integration test --- .github/workflows/ci.yml | 8 +++---- .../integration_test/integration_test.dart | 21 +++++++++++++++++++ example/ios/Podfile.lock | 12 ++++++++--- example/pubspec.yaml | 4 ++++ 4 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 example/integration_test/integration_test.dart diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4a4d32c..8dcddb0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,11 +44,11 @@ jobs: model: 'iPhone 15' os_version: ^${{ matrix.ios-version }} - - name: Flutter Run + - name: Run Integration Tests timeout-minutes: 20 run: | cd example - flutter run + flutter test integration_test/integration_test.dart android: @@ -92,7 +92,7 @@ jobs: ~/.android/adb* key: avd-${{ matrix.api-level }} - - name: Flutter Run + - name: Run Integration Tests timeout-minutes: 20 uses: reactivecircus/android-emulator-runner@v2 with: @@ -103,4 +103,4 @@ jobs: disable-spellchecker: true force-avd-creation: false emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -camera-front none - script: flutter run \ No newline at end of file + script: flutter test integration_test/integration_test.dart \ No newline at end of file diff --git a/example/integration_test/integration_test.dart b/example/integration_test/integration_test.dart new file mode 100644 index 0000000..a8fadea --- /dev/null +++ b/example/integration_test/integration_test.dart @@ -0,0 +1,21 @@ +import 'dart:io' show Platform; + +import 'package:compassx_example/main.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Test', (tester) async { + await tester.pumpWidget(const App()); + + /// Wait while data is being acquired and the + /// [CircularProgressIndicator] is displayed. + await tester.pumpAndSettle(); + + // On Android, the Heading can be obtained.but on the + // on iOS simulator, the Heading sensor is not available, + // so the [CompassXException] is confirmed to be Throw. + final pattern = Platform.isAndroid ? 'Heading' : 'CompassXException'; + + expect(find.textContaining(pattern), findsOneWidget); + }); +} diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 9e6a8c4..3e9f6be 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -2,12 +2,15 @@ PODS: - compassx (0.0.1): - Flutter - Flutter (1.0.0) - - permission_handler_apple (9.1.1): + - integration_test (0.0.1): + - Flutter + - permission_handler_apple (9.3.0): - Flutter DEPENDENCIES: - compassx (from `.symlinks/plugins/compassx/ios`) - Flutter (from `Flutter`) + - integration_test (from `.symlinks/plugins/integration_test/ios`) - permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`) EXTERNAL SOURCES: @@ -15,14 +18,17 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/compassx/ios" Flutter: :path: Flutter + integration_test: + :path: ".symlinks/plugins/integration_test/ios" permission_handler_apple: :path: ".symlinks/plugins/permission_handler_apple/ios" SPEC CHECKSUMS: compassx: 6abaa865a6241ed744ad53aec8d9241c6719ec60 Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 - permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6 + integration_test: 13825b8a9334a850581300559b8839134b124670 + permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2 PODFILE CHECKSUM: 4e8f8b2be68aeea4c0d5beb6ff1e79fface1d048 -COCOAPODS: 1.14.2 +COCOAPODS: 1.15.2 diff --git a/example/pubspec.yaml b/example/pubspec.yaml index e3b8d81..69b2cd2 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -16,5 +16,9 @@ dependencies: dev_dependencies: flutter_lints: ^3.0.1 + flutter_test: + sdk: flutter + integration_test: + sdk: flutter flutter: uses-material-design: true From 1c053fb4f59d38657b4a2c97d44e5d7f0eca9ca2 Mon Sep 17 00:00:00 2001 From: Midori Date: Thu, 28 Mar 2024 15:58:45 +0900 Subject: [PATCH 06/15] Update project.pbxproj --- example/ios/Runner.xcodeproj/project.pbxproj | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 0fae688..7d6d2d6 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -139,6 +139,7 @@ 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, B65040550A890F3C5201C442 /* [CP] Embed Pods Frameworks */, + FF05EE77FFD71AC4D683A00D /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -268,6 +269,23 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; + FF05EE77FFD71AC4D683A00D /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ From 8b29732a5776301fa37a2e09d60bcabf5091ebfc Mon Sep 17 00:00:00 2001 From: Midori Date: Thu, 28 Mar 2024 17:28:51 +0900 Subject: [PATCH 07/15] Update ci.yml --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8dcddb0..bb0d6cb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: timeout-minutes: 60 strategy: matrix: - ios-version: [17] + ios-version: [17.2] fail-fast: false runs-on: macos-14 steps: @@ -57,7 +57,7 @@ jobs: runs-on: macos-13 strategy: matrix: - api-level: [34,33,32,31,30,29,28,27,26,25,24,23,22,21] + api-level: [34,33,32,31,30,29,28,27,26,25,24,23] fail-fast: false steps: - name: Check out From a7be6a922cd6680d159867774410279756fe1979 Mon Sep 17 00:00:00 2001 From: Midori Date: Thu, 28 Mar 2024 17:59:27 +0900 Subject: [PATCH 08/15] Update integration_test --- example/integration_test/integration_test.dart | 15 ++++++++------- example/pubspec.yaml | 1 + 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/example/integration_test/integration_test.dart b/example/integration_test/integration_test.dart index a8fadea..c9a6a2f 100644 --- a/example/integration_test/integration_test.dart +++ b/example/integration_test/integration_test.dart @@ -1,21 +1,22 @@ import 'dart:io' show Platform; import 'package:compassx_example/main.dart'; +import 'package:device_info_plus/device_info_plus.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Test', (tester) async { await tester.pumpWidget(const App()); - /// Wait while data is being acquired and the + /// Wait while data is being acquired and the /// [CircularProgressIndicator] is displayed. await tester.pumpAndSettle(); - // On Android, the Heading can be obtained.but on the - // on iOS simulator, the Heading sensor is not available, - // so the [CompassXException] is confirmed to be Throw. - final pattern = Platform.isAndroid ? 'Heading' : 'CompassXException'; - - expect(find.textContaining(pattern), findsOneWidget); + /// Ensure that the Android SDK 23 and lower emulators and the iOS + /// simulator do not have a heading sensor, so that an Exception is Throw. + Platform.isAndroid && + (await DeviceInfoPlugin().androidInfo).version.sdkInt > 23 + ? expect(find.textContaining('Heading'), findsOneWidget) + : expect(find.textContaining('CompassXException'), findsOneWidget); }); } diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 69b2cd2..2c866ea 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -20,5 +20,6 @@ dev_dependencies: sdk: flutter integration_test: sdk: flutter + device_info_plus: ^10.0.1 flutter: uses-material-design: true From 25c419b015daf70cde7cc9a8f337bc86fa65163e Mon Sep 17 00:00:00 2001 From: Midori Date: Thu, 28 Mar 2024 18:27:16 +0900 Subject: [PATCH 09/15] Update ci.yml --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bb0d6cb..6743f71 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: timeout-minutes: 60 strategy: matrix: - ios-version: [17.2] + ios-version: [17.0] fail-fast: false runs-on: macos-14 steps: @@ -58,6 +58,7 @@ jobs: strategy: matrix: api-level: [34,33,32,31,30,29,28,27,26,25,24,23] + target: [google_apis] fail-fast: false steps: - name: Check out From 69eaa1d3f0df3020d152441bd44a38a7ae94d6ca Mon Sep 17 00:00:00 2001 From: Midori Date: Thu, 28 Mar 2024 18:27:22 +0900 Subject: [PATCH 10/15] Refactor --- example/integration_test/integration_test.dart | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/example/integration_test/integration_test.dart b/example/integration_test/integration_test.dart index c9a6a2f..b950b26 100644 --- a/example/integration_test/integration_test.dart +++ b/example/integration_test/integration_test.dart @@ -12,10 +12,11 @@ void main() { /// [CircularProgressIndicator] is displayed. await tester.pumpAndSettle(); - /// Ensure that the Android SDK 23 and lower emulators and the iOS + /// Ensure that the Android SDK 23 and lower emulators and the iOS /// simulator do not have a heading sensor, so that an Exception is Throw. - Platform.isAndroid && - (await DeviceInfoPlugin().androidInfo).version.sdkInt > 23 + final hasSensor = Platform.isAndroid && + (await DeviceInfoPlugin().androidInfo).version.sdkInt > 23; + hasSensor ? expect(find.textContaining('Heading'), findsOneWidget) : expect(find.textContaining('CompassXException'), findsOneWidget); }); From 68f2049d0fd756173d1a25ef820c560ed8d897ce Mon Sep 17 00:00:00 2001 From: Midori Date: Thu, 28 Mar 2024 19:21:47 +0900 Subject: [PATCH 11/15] Update ci.yml --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6743f71..4688f0b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,7 +58,6 @@ jobs: strategy: matrix: api-level: [34,33,32,31,30,29,28,27,26,25,24,23] - target: [google_apis] fail-fast: false steps: - name: Check out From c970ff854be928d7e675c905326a5852ef2ae8ca Mon Sep 17 00:00:00 2001 From: Midori Date: Thu, 28 Mar 2024 19:27:57 +0900 Subject: [PATCH 12/15] Update ci.yml --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4688f0b..4516e3f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: timeout-minutes: 60 strategy: matrix: - ios-version: [17.0] + ios-version: [17] fail-fast: false runs-on: macos-14 steps: @@ -54,7 +54,7 @@ jobs: android: needs: set-up timeout-minutes: 60 - runs-on: macos-13 + runs-on: macos-14 strategy: matrix: api-level: [34,33,32,31,30,29,28,27,26,25,24,23] From 4e6c722e1e9a1044b47d4a75f7a592231569b743 Mon Sep 17 00:00:00 2001 From: Midori Date: Thu, 28 Mar 2024 19:37:07 +0900 Subject: [PATCH 13/15] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4516e3f..6f81517 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: matrix: ios-version: [17] fail-fast: false - runs-on: macos-14 + runs-on: macos-latest steps: - name: Check out uses: actions/checkout@v4 From 7b83e233d10a004e3baae14863ab2a17ad77a4f2 Mon Sep 17 00:00:00 2001 From: Midori Date: Thu, 28 Mar 2024 19:39:45 +0900 Subject: [PATCH 14/15] Update ci.yml --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6f81517..675ab84 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: matrix: ios-version: [17] fail-fast: false - runs-on: macos-latest + runs-on: macos-14 steps: - name: Check out uses: actions/checkout@v4 @@ -54,7 +54,7 @@ jobs: android: needs: set-up timeout-minutes: 60 - runs-on: macos-14 + runs-on: macos-latest strategy: matrix: api-level: [34,33,32,31,30,29,28,27,26,25,24,23] From 7544e120d1436d0dd07c2767e29f913181d0f468 Mon Sep 17 00:00:00 2001 From: Midori Date: Thu, 28 Mar 2024 20:12:59 +0900 Subject: [PATCH 15/15] Update ci.yml --- .github/workflows/ci.yml | 43 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 675ab84..505ceea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,10 +54,11 @@ jobs: android: needs: set-up timeout-minutes: 60 - runs-on: macos-latest + runs-on: macos-13 strategy: matrix: - api-level: [34,33,32,31,30,29,28,27,26,25,24,23] + # Api 33 is [currently not available on the macos-13 runner](https://github.com/ReactiveCircus/android-emulator-runner/issues/340) + api-level: [34,32,31,30,29,28,27,26,25,24,23] fail-fast: false steps: - name: Check out @@ -93,6 +94,8 @@ jobs: key: avd-${{ matrix.api-level }} - name: Run Integration Tests + id: Run-Integration-Tests + continue-on-error: true timeout-minutes: 20 uses: reactivecircus/android-emulator-runner@v2 with: @@ -103,4 +106,38 @@ jobs: disable-spellchecker: true force-avd-creation: false emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -camera-front none - script: flutter test integration_test/integration_test.dart \ No newline at end of file + script: flutter test integration_test/integration_test.dart + + - name: Retry Integration Tests + id: Retry-Integration-Tests + if: steps.Run-Integration-Tests.outcome == 'failure' + continue-on-error: true + timeout-minutes: 20 + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: ${{ matrix.api-level }} + working-directory: ./example + arch: x86_64 + emulator-boot-timeout: 200 + disable-spellchecker: true + force-avd-creation: false + emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -camera-front none + script: | + flutter clean && flutter pub get + flutter test integration_test/integration_test.dart + + - name: Re:Retry Integration Tests + if: steps.Retry-integration-tests.outcome == 'failure' + timeout-minutes: 20 + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: ${{ matrix.api-level }} + working-directory: ./example + arch: x86_64 + emulator-boot-timeout: 200 + disable-spellchecker: true + force-avd-creation: false + emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -camera-front none + script: | + flutter clean && flutter pub get + flutter test integration_test/integration_test.dart \ No newline at end of file