From 156882a9a7e039a38cd206306e19b94eb391f948 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Fri, 1 Nov 2024 20:03:07 +0800 Subject: [PATCH 01/11] fix: pages overflow when selecting homepage --- .../pages/sites/domain/home_page_menu.dart | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/sites/domain/home_page_menu.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/sites/domain/home_page_menu.dart index 90d6b4d4b4022..f1236c1024217 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/sites/domain/home_page_menu.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/sites/domain/home_page_menu.dart @@ -65,19 +65,28 @@ class _SelectHomePageMenuState extends State { onSearch: (context, value) => _onSearch(value), ), const VSpace(10), - ...views.map( - (view) => Padding( - padding: const EdgeInsets.symmetric(vertical: 4.0), - child: PublishInfoViewItem( - publishInfoView: view, - useIntrinsicWidth: false, - onTap: () { - context.read().add( - SettingsSitesEvent.setHomePage(view.info.viewId), - ); + Expanded( + child: SingleChildScrollView( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + ...views.map( + (view) => Padding( + padding: const EdgeInsets.symmetric(vertical: 4.0), + child: PublishInfoViewItem( + publishInfoView: view, + useIntrinsicWidth: false, + onTap: () { + context.read().add( + SettingsSitesEvent.setHomePage(view.info.viewId), + ); - PopoverContainer.of(context).close(); - }, + PopoverContainer.of(context).close(); + }, + ), + ), + ), + ], ), ), ), From e1276f92d1b7a7a6cff5f21d5acd9890b33cf179 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Tue, 5 Nov 2024 10:05:43 +0800 Subject: [PATCH 02/11] feat: integrate codemagic --- codemagic.yaml | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 codemagic.yaml diff --git a/codemagic.yaml b/codemagic.yaml new file mode 100644 index 0000000000000..afb5adc9992d7 --- /dev/null +++ b/codemagic.yaml @@ -0,0 +1,50 @@ +workflows: + ios-workflow: + name: iOS Workflow + instance_type: mac_mini_m2 + max_build_duration: 30 + environment: + ios_signing: + distribution_type: development + bundle_identifier: com.appflowy.appflowy + + vars: + XCODE_WORKSPACE: "ios/Runner.xcworkspace" + XCODE_SCHEME: "Runner" + + flutter: stable + xcode: latest + cocoapods: default + + scripts: + - name: Build Flutter + script: | + cd frontend + cargo make --profile development-ios-arm64-sim appflowy-core-dev-ios + cargo make --profile development-ios-arm64-sim code_generation + + - name: Flutter analyze + script: | + flutter analyze + + - name: Build iOS + script: | + cd appflowy_flutter + flutter build ios --release --no-codesign + + - name: iOS integration tests + script: | + flutter test integration_test/runner.dart + + artifacts: + - build/ios/ipa/*.ipa + - /tmp/xcodebuild_logs/*.log + - flutter_drive.log + + publishing: + email: + recipients: + - lucas.xu@appflowy.io + notify: + success: true + failure: true From 846d41c6c6b3e7069c3b756360d1168d83b64765 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Tue, 5 Nov 2024 10:06:15 +0800 Subject: [PATCH 03/11] Revert "fix: pages overflow when selecting homepage" This reverts commit 156882a9a7e039a38cd206306e19b94eb391f948. --- codemagic.yaml | 12 +++++++ .../pages/sites/domain/home_page_menu.dart | 33 +++++++------------ 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/codemagic.yaml b/codemagic.yaml index afb5adc9992d7..44f35eecb162e 100644 --- a/codemagic.yaml +++ b/codemagic.yaml @@ -19,7 +19,19 @@ workflows: scripts: - name: Build Flutter script: | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + source "$HOME/.cargo/env" + rustc --version + cargo --version + cd frontend + + rustup target install aarch64-apple-ios-sim + cargo install cargo-make + cargo install --force duckscript_cli + cargo install cargo-lipo + + cargo make appflowy-flutter-deps-tools cargo make --profile development-ios-arm64-sim appflowy-core-dev-ios cargo make --profile development-ios-arm64-sim code_generation diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/sites/domain/home_page_menu.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/sites/domain/home_page_menu.dart index f1236c1024217..90d6b4d4b4022 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/sites/domain/home_page_menu.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/sites/domain/home_page_menu.dart @@ -65,28 +65,19 @@ class _SelectHomePageMenuState extends State { onSearch: (context, value) => _onSearch(value), ), const VSpace(10), - Expanded( - child: SingleChildScrollView( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - ...views.map( - (view) => Padding( - padding: const EdgeInsets.symmetric(vertical: 4.0), - child: PublishInfoViewItem( - publishInfoView: view, - useIntrinsicWidth: false, - onTap: () { - context.read().add( - SettingsSitesEvent.setHomePage(view.info.viewId), - ); + ...views.map( + (view) => Padding( + padding: const EdgeInsets.symmetric(vertical: 4.0), + child: PublishInfoViewItem( + publishInfoView: view, + useIntrinsicWidth: false, + onTap: () { + context.read().add( + SettingsSitesEvent.setHomePage(view.info.viewId), + ); - PopoverContainer.of(context).close(); - }, - ), - ), - ), - ], + PopoverContainer.of(context).close(); + }, ), ), ), From 265e92d62b2624869b4c87d945bd51ba2a23bdca Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Tue, 5 Nov 2024 11:26:50 +0800 Subject: [PATCH 04/11] chore: try to fix build --- codemagic.yaml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/codemagic.yaml b/codemagic.yaml index 44f35eecb162e..36b0948bfc6f3 100644 --- a/codemagic.yaml +++ b/codemagic.yaml @@ -4,14 +4,6 @@ workflows: instance_type: mac_mini_m2 max_build_duration: 30 environment: - ios_signing: - distribution_type: development - bundle_identifier: com.appflowy.appflowy - - vars: - XCODE_WORKSPACE: "ios/Runner.xcworkspace" - XCODE_SCHEME: "Runner" - flutter: stable xcode: latest cocoapods: default @@ -27,9 +19,9 @@ workflows: cd frontend rustup target install aarch64-apple-ios-sim - cargo install cargo-make + cargo install --force cargo-make cargo install --force duckscript_cli - cargo install cargo-lipo + cargo install --force cargo-lipo cargo make appflowy-flutter-deps-tools cargo make --profile development-ios-arm64-sim appflowy-core-dev-ios From 49a7105d6c9388e827499e17254dedf18bdec740 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Tue, 5 Nov 2024 11:46:56 +0800 Subject: [PATCH 05/11] chore: remove flutter analyuze --- codemagic.yaml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/codemagic.yaml b/codemagic.yaml index 36b0948bfc6f3..aa9659a72b508 100644 --- a/codemagic.yaml +++ b/codemagic.yaml @@ -27,17 +27,9 @@ workflows: cargo make --profile development-ios-arm64-sim appflowy-core-dev-ios cargo make --profile development-ios-arm64-sim code_generation - - name: Flutter analyze - script: | - flutter analyze - - - name: Build iOS - script: | - cd appflowy_flutter - flutter build ios --release --no-codesign - - name: iOS integration tests script: | + cd frontend/appflowy_flutter flutter test integration_test/runner.dart artifacts: From 569b0b9e76f63d3a3cfe5dba21a637149241653c Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Tue, 5 Nov 2024 12:22:27 +0800 Subject: [PATCH 06/11] chore: launch ios simulator --- codemagic.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/codemagic.yaml b/codemagic.yaml index aa9659a72b508..cffdd61ae2a99 100644 --- a/codemagic.yaml +++ b/codemagic.yaml @@ -30,7 +30,8 @@ workflows: - name: iOS integration tests script: | cd frontend/appflowy_flutter - flutter test integration_test/runner.dart + flutter emulators --launch apple_ios_simulator + flutter -d iPhone test integration_test/runner.dart artifacts: - build/ios/ipa/*.ipa From fc9c7014a3663f66a6808176ef2c38298967e80a Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Tue, 5 Nov 2024 12:50:37 +0800 Subject: [PATCH 07/11] fix: flutter version --- codemagic.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemagic.yaml b/codemagic.yaml index cffdd61ae2a99..3e592adb7cdc4 100644 --- a/codemagic.yaml +++ b/codemagic.yaml @@ -4,7 +4,7 @@ workflows: instance_type: mac_mini_m2 max_build_duration: 30 environment: - flutter: stable + flutter: 3.22.3 xcode: latest cocoapods: default From 79bc46541a56039761d59cf82b75cdecfe2bf07f Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Thu, 7 Nov 2024 11:13:34 +0800 Subject: [PATCH 08/11] fix: integration tests on mobile --- .../mobile/home_page/create_new_page_test.dart | 8 ++++---- .../mobile/sign_in/anonymous_sign_in_test.dart | 1 + .../{mobile_runner.dart => mobile_runner_1.dart} | 7 ++++++- .../appflowy_flutter/integration_test/runner.dart | 4 ++-- .../mobile/presentation/base/mobile_view_page.dart | 5 ++++- frontend/appflowy_flutter/pubspec.lock | 12 ++++++------ 6 files changed, 23 insertions(+), 14 deletions(-) rename frontend/appflowy_flutter/integration_test/{mobile_runner.dart => mobile_runner_1.dart} (81%) diff --git a/frontend/appflowy_flutter/integration_test/mobile/home_page/create_new_page_test.dart b/frontend/appflowy_flutter/integration_test/mobile/home_page/create_new_page_test.dart index ae4e5ddea51f5..4bb83836f013b 100644 --- a/frontend/appflowy_flutter/integration_test/mobile/home_page/create_new_page_test.dart +++ b/frontend/appflowy_flutter/integration_test/mobile/home_page/create_new_page_test.dart @@ -31,17 +31,17 @@ void main() { group('create new page', () { testWidgets('create document', (tester) async { - await tester.initializeAppFlowy( - cloudType: AuthenticatorType.local, - ); + await tester.initializeAppFlowy(); + await tester.tapAnonymousSignInButton(); // tap the create page button final createPageButton = find.byWidgetPredicate( (widget) => widget is FlowySvg && - widget.svg.path == FlowySvgs.m_home_unselected_m.path, + widget.svg.path == FlowySvgs.m_home_add_m.path, ); await tester.tapButton(createPageButton); + await tester.pumpAndSettle(); expect(find.byType(MobileDocumentScreen), findsOneWidget); }); }); diff --git a/frontend/appflowy_flutter/integration_test/mobile/sign_in/anonymous_sign_in_test.dart b/frontend/appflowy_flutter/integration_test/mobile/sign_in/anonymous_sign_in_test.dart index 427e554733bf6..647f65fa89963 100644 --- a/frontend/appflowy_flutter/integration_test/mobile/sign_in/anonymous_sign_in_test.dart +++ b/frontend/appflowy_flutter/integration_test/mobile/sign_in/anonymous_sign_in_test.dart @@ -28,6 +28,7 @@ void main() { group('anonymous sign in on mobile', () { testWidgets('anon user and then sign in', (tester) async { await tester.initializeAppFlowy(); + await tester.tapAnonymousSignInButton(); // expect to see the home page expect(find.byType(MobileHomeScreen), findsOneWidget); diff --git a/frontend/appflowy_flutter/integration_test/mobile_runner.dart b/frontend/appflowy_flutter/integration_test/mobile_runner_1.dart similarity index 81% rename from frontend/appflowy_flutter/integration_test/mobile_runner.dart rename to frontend/appflowy_flutter/integration_test/mobile_runner_1.dart index 3f47f83997a12..bf86020141c47 100644 --- a/frontend/appflowy_flutter/integration_test/mobile_runner.dart +++ b/frontend/appflowy_flutter/integration_test/mobile_runner_1.dart @@ -5,8 +5,13 @@ import 'mobile/document/page_style_test.dart' as page_style_test; import 'mobile/home_page/create_new_page_test.dart' as create_new_page_test; import 'mobile/sign_in/anonymous_sign_in_test.dart' as anonymous_sign_in_test; -Future runIntegrationOnMobile() async { +Future main() async { Log.shared.disableLog = true; + + await runIntegration1OnMobile(); +} + +Future runIntegration1OnMobile() async { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); anonymous_sign_in_test.main(); diff --git a/frontend/appflowy_flutter/integration_test/runner.dart b/frontend/appflowy_flutter/integration_test/runner.dart index d995f81f6dcfb..247c233236303 100644 --- a/frontend/appflowy_flutter/integration_test/runner.dart +++ b/frontend/appflowy_flutter/integration_test/runner.dart @@ -8,7 +8,7 @@ import 'desktop_runner_5.dart'; import 'desktop_runner_6.dart'; import 'desktop_runner_7.dart'; import 'desktop_runner_8.dart'; -import 'mobile_runner.dart'; +import 'mobile_runner_1.dart'; /// The main task runner for all integration tests in AppFlowy. /// @@ -28,7 +28,7 @@ Future main() async { await runIntegration7OnDesktop(); await runIntegration8OnDesktop(); } else if (Platform.isIOS || Platform.isAndroid) { - await runIntegrationOnMobile(); + await runIntegration1OnMobile(); } else { throw Exception('Unsupported platform'); } diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/base/mobile_view_page.dart b/frontend/appflowy_flutter/lib/mobile/presentation/base/mobile_view_page.dart index b6c23c3d8c94e..4d4eecbc1d722 100644 --- a/frontend/appflowy_flutter/lib/mobile/presentation/base/mobile_view_page.dart +++ b/frontend/appflowy_flutter/lib/mobile/presentation/base/mobile_view_page.dart @@ -65,7 +65,10 @@ class _MobileViewPageState extends State { @override void dispose() { _appBarOpacity.dispose(); - _scrollNotificationObserver?.removeListener(_onScrollNotification); + + // there's no need to remove the listener, because the observer will be disposed when the widget is unmounted. + // inside the observer, the listener will be removed automatically. + // _scrollNotificationObserver?.removeListener(_onScrollNotification); _scrollNotificationObserver = null; super.dispose(); diff --git a/frontend/appflowy_flutter/pubspec.lock b/frontend/appflowy_flutter/pubspec.lock index 27ee616618f2e..42554d59c2383 100644 --- a/frontend/appflowy_flutter/pubspec.lock +++ b/frontend/appflowy_flutter/pubspec.lock @@ -1543,10 +1543,10 @@ packages: dependency: transitive description: name: platform - sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec" + sha256: "9b71283fc13df574056616011fb138fd3b793ea47cc509c189a6c3fa5f8a1a65" url: "https://pub.dev" source: hosted - version: "3.1.4" + version: "3.1.5" plugin_platform_interface: dependency: "direct dev" description: @@ -1941,10 +1941,10 @@ packages: dependency: transitive description: name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3" url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.0" string_validator: dependency: "direct main" description: @@ -2246,10 +2246,10 @@ packages: dependency: transitive description: name: vm_service - sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" + sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" url: "https://pub.dev" source: hosted - version: "14.2.1" + version: "14.2.5" watcher: dependency: transitive description: From 2c73c7a2c9d1450c860f537720b9bb01cd78fd99 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Thu, 7 Nov 2024 13:49:25 +0800 Subject: [PATCH 09/11] fix: mobile tests --- .../integration_test/mobile/document/page_style_test.dart | 3 ++- .../mobile/home_page/create_new_page_test.dart | 5 ++--- .../mobile/sign_in/anonymous_sign_in_test.dart | 5 ++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/frontend/appflowy_flutter/integration_test/mobile/document/page_style_test.dart b/frontend/appflowy_flutter/integration_test/mobile/document/page_style_test.dart index 6e94eed1b84ab..31d302b831917 100644 --- a/frontend/appflowy_flutter/integration_test/mobile/document/page_style_test.dart +++ b/frontend/appflowy_flutter/integration_test/mobile/document/page_style_test.dart @@ -36,7 +36,7 @@ import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - group('document page style', () { + group('document page style:', () { double getCurrentEditorFontSize() { final editorPage = find .byType(AppFlowyEditorPage) @@ -93,6 +93,7 @@ void main() { ); // change line height from normal to large await tester.tapSvgButton(FlowySvgs.m_layout_large_s); + await tester.pumpAndSettle(); expect( getCurrentEditorLineHeight(), PageStyleLineHeightLayout.large.lineHeight, diff --git a/frontend/appflowy_flutter/integration_test/mobile/home_page/create_new_page_test.dart b/frontend/appflowy_flutter/integration_test/mobile/home_page/create_new_page_test.dart index 4bb83836f013b..a10052926abc1 100644 --- a/frontend/appflowy_flutter/integration_test/mobile/home_page/create_new_page_test.dart +++ b/frontend/appflowy_flutter/integration_test/mobile/home_page/create_new_page_test.dart @@ -29,10 +29,9 @@ import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - group('create new page', () { + group('create new page in home page:', () { testWidgets('create document', (tester) async { - await tester.initializeAppFlowy(); - await tester.tapAnonymousSignInButton(); + await tester.launchInAnonymousMode(); // tap the create page button final createPageButton = find.byWidgetPredicate( diff --git a/frontend/appflowy_flutter/integration_test/mobile/sign_in/anonymous_sign_in_test.dart b/frontend/appflowy_flutter/integration_test/mobile/sign_in/anonymous_sign_in_test.dart index 647f65fa89963..1a0493b6a7445 100644 --- a/frontend/appflowy_flutter/integration_test/mobile/sign_in/anonymous_sign_in_test.dart +++ b/frontend/appflowy_flutter/integration_test/mobile/sign_in/anonymous_sign_in_test.dart @@ -25,10 +25,9 @@ import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - group('anonymous sign in on mobile', () { + group('anonymous sign in on mobile:', () { testWidgets('anon user and then sign in', (tester) async { - await tester.initializeAppFlowy(); - await tester.tapAnonymousSignInButton(); + await tester.launchInAnonymousMode(); // expect to see the home page expect(find.byType(MobileHomeScreen), findsOneWidget); From a4ce015ed4d723a820a0650552a014e9a8a7654b Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Thu, 7 Nov 2024 17:06:11 +0800 Subject: [PATCH 10/11] test: fix page style test --- .../mobile/document/page_style_test.dart | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/frontend/appflowy_flutter/integration_test/mobile/document/page_style_test.dart b/frontend/appflowy_flutter/integration_test/mobile/document/page_style_test.dart index 31d302b831917..67d2b05d9d572 100644 --- a/frontend/appflowy_flutter/integration_test/mobile/document/page_style_test.dart +++ b/frontend/appflowy_flutter/integration_test/mobile/document/page_style_test.dart @@ -57,11 +57,9 @@ void main() { .single .widget as AppFlowyEditorPage; return editorPage.styleCustomizer - .style() - .textStyleConfiguration - .text - .height ?? - PageStyleLineHeightLayout.normal.lineHeight; + .style() + .textStyleConfiguration + .lineHeight; } testWidgets('change font size in page style settings', (tester) async { @@ -87,21 +85,24 @@ void main() { await tester.openPage(gettingStarted); // click the layout button await tester.tapButton(find.byType(MobileViewPageLayoutButton)); + var lineHeight = getCurrentEditorLineHeight(); expect( - getCurrentEditorLineHeight(), + lineHeight, PageStyleLineHeightLayout.normal.lineHeight, ); // change line height from normal to large await tester.tapSvgButton(FlowySvgs.m_layout_large_s); await tester.pumpAndSettle(); + lineHeight = getCurrentEditorLineHeight(); expect( - getCurrentEditorLineHeight(), + lineHeight, PageStyleLineHeightLayout.large.lineHeight, ); // change line height from large to small await tester.tapSvgButton(FlowySvgs.m_layout_small_s); + lineHeight = getCurrentEditorLineHeight(); expect( - getCurrentEditorLineHeight(), + lineHeight, PageStyleLineHeightLayout.small.lineHeight, ); }); From 94f5e51d1acaac4aa1e2e25a3820febf30fd5f42 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Fri, 8 Nov 2024 09:26:57 +0800 Subject: [PATCH 11/11] chore: enable ios ci --- .github/workflows/ios_ci.yaml | 40 ++++++------ .github/workflows/mobile_ci.yml | 108 ++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/mobile_ci.yml diff --git a/.github/workflows/ios_ci.yaml b/.github/workflows/ios_ci.yaml index a39a2704c8179..ef64a9741da84 100644 --- a/.github/workflows/ios_ci.yaml +++ b/.github/workflows/ios_ci.yaml @@ -97,21 +97,25 @@ jobs: cargo make --profile development-ios-arm64-sim appflowy-core-dev-ios cargo make --profile development-ios-arm64-sim code_generation - # - uses: futureware-tech/simulator-action@v3 - # id: simulator-action - # with: - # model: "iPhone 15" - # shutdown_after_job: false - - # - name: Run AppFlowy on simulator - # working-directory: frontend/appflowy_flutter - # run: | - # flutter run -d ${{ steps.simulator-action.outputs.udid }} & - # pid=$! - # sleep 500 - # kill $pid - # continue-on-error: true - - # - name: Run integration tests - # working-directory: frontend/appflowy_flutter - # run: flutter test integration_test/runner.dart -d ${{ steps.simulator-action.outputs.udid }} + - uses: futureware-tech/simulator-action@v3 + id: simulator-action + with: + model: "iPhone 15" + shutdown_after_job: false + + - name: Run AppFlowy on simulator + working-directory: frontend/appflowy_flutter + run: | + flutter run -d ${{ steps.simulator-action.outputs.udid }} & + pid=$! + sleep 500 + kill $pid + continue-on-error: true + + - name: Run integration tests + working-directory: frontend/appflowy_flutter + # The integration tests are flaky and sometimes fail with "Connection timed out": + # Don't block the CI. If the tests fail, the CI will still pass. + # Instead, we're using Code Magic to re-run the tests to check if they pass. + continue-on-error: true + run: flutter test integration_test/runner.dart -d ${{ steps.simulator-action.outputs.udid }} diff --git a/.github/workflows/mobile_ci.yml b/.github/workflows/mobile_ci.yml new file mode 100644 index 0000000000000..31de45ccd818a --- /dev/null +++ b/.github/workflows/mobile_ci.yml @@ -0,0 +1,108 @@ +name: Mobile-CI + +on: + workflow_dispatch: + inputs: + branch: + description: "Branch to build" + required: true + default: "main" + workflow_id: + description: "Codemagic workflow ID" + required: true + default: "ios-workflow" + type: choice + options: + - ios-workflow + - android-workflow + +env: + CODEMAGIC_API_TOKEN: 3G8VZRVsbYPb5-RuFjw-xqqlyA7y-nfue-rmybupLZw + APP_ID: "64cb77ba5da3347bf6d22fba" + +jobs: + trigger-mobile-build: + runs-on: ubuntu-latest + steps: + - name: Trigger Codemagic Build + id: trigger_build + run: | + RESPONSE=$(curl -X POST \ + --header "Content-Type: application/json" \ + --header "x-auth-token: $CODEMAGIC_API_TOKEN" \ + --data '{ + "appId": "${{ env.APP_ID }}", + "workflowId": "${{ github.event.inputs.workflow_id }}", + "branch": "${{ github.event.inputs.branch }}" + }' \ + https://api.codemagic.io/builds) + + BUILD_ID=$(echo $RESPONSE | jq -r '.buildId') + echo "build_id=$BUILD_ID" >> $GITHUB_OUTPUT + + - name: Wait for build and check status + id: check_status + run: | + while true; do + RESPONSE=$(curl -X GET \ + --header "Content-Type: application/json" \ + --header "x-auth-token: $CODEMAGIC_API_TOKEN" \ + https://api.codemagic.io/builds/${{ steps.trigger_build.outputs.build_id }}) + + STATUS=$(echo $RESPONSE | jq -r '.status') + + if [ "$STATUS" = "finished" ]; then + SUCCESS=$(echo $RESPONSE | jq -r '.success') + BUILD_URL=$(echo $RESPONSE | jq -r '.buildUrl') + echo "status=$STATUS" >> $GITHUB_OUTPUT + echo "success=$SUCCESS" >> $GITHUB_OUTPUT + echo "build_url=$BUILD_URL" >> $GITHUB_OUTPUT + break + elif [ "$STATUS" = "failed" ]; then + echo "status=failed" >> $GITHUB_OUTPUT + break + fi + + sleep 60 + done + + - name: Send Slack Notification + if: always() + run: | + BUILD_STATUS="${{ steps.check_status.outputs.status }}" + SUCCESS="${{ steps.check_status.outputs.success }}" + BUILD_URL="${{ steps.check_status.outputs.build_url }}" + + if [ "$SUCCESS" = "true" ]; then + COLOR="#36a64f" + STATUS_TEXT="✅ Success" + else + COLOR="#ff0000" + STATUS_TEXT="❌ Failed" + fi + + curl -X POST -H 'Content-type: application/json' \ + --data "{ + \"attachments\": [ + { + \"color\": \"$COLOR\", + \"blocks\": [ + { + \"type\": \"section\", + \"text\": { + \"type\": \"mrkdwn\", + \"text\": \"*Mobile CI Build Result*\n$STATUS_TEXT\" + } + }, + { + \"type\": \"section\", + \"text\": { + \"type\": \"mrkdwn\", + \"text\": \"*Branch:* ${{ github.event.inputs.branch }}\n*Workflow:* ${{ github.event.inputs.workflow_id }}\n*Build URL:* $BUILD_URL\" + } + } + ] + } + ] + }" \ + ${{ secrets.RELEASE_SLACK_WEBHOOK }}