From 4c2510c36fba809f9f2be1a4def23797b5d63b6a Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Fri, 24 Oct 2025 10:58:16 -0700 Subject: [PATCH 1/8] updated threading --- .../ios/Classes/SwiftAmplifyDataStorePlugin.swift | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/amplify_datastore/ios/Classes/SwiftAmplifyDataStorePlugin.swift b/packages/amplify_datastore/ios/Classes/SwiftAmplifyDataStorePlugin.swift index a3e7e341f0b..0aa89d50eac 100644 --- a/packages/amplify_datastore/ios/Classes/SwiftAmplifyDataStorePlugin.swift +++ b/packages/amplify_datastore/ios/Classes/SwiftAmplifyDataStorePlugin.swift @@ -652,13 +652,15 @@ public class SwiftAmplifyDataStorePlugin: NSObject, FlutterPlugin, NativeAmplify return DataStoreSyncExpression.syncExpression(modelSchema!) { var resolvedQueryPredicate = queryPredicate let semaphore = DispatchSemaphore(value: 0) - self.channel!.invokeMethod("resolveQueryPredicate", arguments: id) { result in - do { - resolvedQueryPredicate = try QueryPredicateBuilder.fromSerializedMap(result as? [String: Any]) - } catch { - print("Failed to resolve query predicate. Reverting to original query predicate.") + DispatchQueue.main.async { + self.channel!.invokeMethod("resolveQueryPredicate", arguments: id) { result in + do { + resolvedQueryPredicate = try QueryPredicateBuilder.fromSerializedMap(result as? [String: Any]) + } catch { + print("Failed to resolve query predicate. Reverting to original query predicate.") + } + semaphore.signal() } - semaphore.signal() } semaphore.wait() return resolvedQueryPredicate From 4a8bdef21110bb353bb0ec5e0173032bf3d0a2bc Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Fri, 24 Oct 2025 11:51:17 -0700 Subject: [PATCH 2/8] Revert "updated threading" This reverts commit 4c2510c36fba809f9f2be1a4def23797b5d63b6a. --- .../ios/Classes/SwiftAmplifyDataStorePlugin.swift | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/amplify_datastore/ios/Classes/SwiftAmplifyDataStorePlugin.swift b/packages/amplify_datastore/ios/Classes/SwiftAmplifyDataStorePlugin.swift index 0aa89d50eac..a3e7e341f0b 100644 --- a/packages/amplify_datastore/ios/Classes/SwiftAmplifyDataStorePlugin.swift +++ b/packages/amplify_datastore/ios/Classes/SwiftAmplifyDataStorePlugin.swift @@ -652,15 +652,13 @@ public class SwiftAmplifyDataStorePlugin: NSObject, FlutterPlugin, NativeAmplify return DataStoreSyncExpression.syncExpression(modelSchema!) { var resolvedQueryPredicate = queryPredicate let semaphore = DispatchSemaphore(value: 0) - DispatchQueue.main.async { - self.channel!.invokeMethod("resolveQueryPredicate", arguments: id) { result in - do { - resolvedQueryPredicate = try QueryPredicateBuilder.fromSerializedMap(result as? [String: Any]) - } catch { - print("Failed to resolve query predicate. Reverting to original query predicate.") - } - semaphore.signal() + self.channel!.invokeMethod("resolveQueryPredicate", arguments: id) { result in + do { + resolvedQueryPredicate = try QueryPredicateBuilder.fromSerializedMap(result as? [String: Any]) + } catch { + print("Failed to resolve query predicate. Reverting to original query predicate.") } + semaphore.signal() } semaphore.wait() return resolvedQueryPredicate From f99e368c6972cc4833e7dbf40048bca75ac0b33f Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Fri, 24 Oct 2025 12:47:23 -0700 Subject: [PATCH 3/8] Reapply "updated threading" This reverts commit 4a8bdef21110bb353bb0ec5e0173032bf3d0a2bc. --- .../ios/Classes/SwiftAmplifyDataStorePlugin.swift | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/amplify_datastore/ios/Classes/SwiftAmplifyDataStorePlugin.swift b/packages/amplify_datastore/ios/Classes/SwiftAmplifyDataStorePlugin.swift index a3e7e341f0b..0aa89d50eac 100644 --- a/packages/amplify_datastore/ios/Classes/SwiftAmplifyDataStorePlugin.swift +++ b/packages/amplify_datastore/ios/Classes/SwiftAmplifyDataStorePlugin.swift @@ -652,13 +652,15 @@ public class SwiftAmplifyDataStorePlugin: NSObject, FlutterPlugin, NativeAmplify return DataStoreSyncExpression.syncExpression(modelSchema!) { var resolvedQueryPredicate = queryPredicate let semaphore = DispatchSemaphore(value: 0) - self.channel!.invokeMethod("resolveQueryPredicate", arguments: id) { result in - do { - resolvedQueryPredicate = try QueryPredicateBuilder.fromSerializedMap(result as? [String: Any]) - } catch { - print("Failed to resolve query predicate. Reverting to original query predicate.") + DispatchQueue.main.async { + self.channel!.invokeMethod("resolveQueryPredicate", arguments: id) { result in + do { + resolvedQueryPredicate = try QueryPredicateBuilder.fromSerializedMap(result as? [String: Any]) + } catch { + print("Failed to resolve query predicate. Reverting to original query predicate.") + } + semaphore.signal() } - semaphore.signal() } semaphore.wait() return resolvedQueryPredicate From a053c3f8b3c5403d1df0abfd5318b6d3857e6067 Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Fri, 24 Oct 2025 13:01:25 -0700 Subject: [PATCH 4/8] remove semaphore --- .../Classes/SwiftAmplifyDataStorePlugin.swift | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/packages/amplify_datastore/ios/Classes/SwiftAmplifyDataStorePlugin.swift b/packages/amplify_datastore/ios/Classes/SwiftAmplifyDataStorePlugin.swift index 0aa89d50eac..acbc3e62bb0 100644 --- a/packages/amplify_datastore/ios/Classes/SwiftAmplifyDataStorePlugin.swift +++ b/packages/amplify_datastore/ios/Classes/SwiftAmplifyDataStorePlugin.swift @@ -645,25 +645,11 @@ public class SwiftAmplifyDataStorePlugin: NSObject, FlutterPlugin, NativeAmplify private func createSyncExpressions(syncExpressionList: [[String: Any]]) throws -> [DataStoreSyncExpression] { return try syncExpressionList.map { syncExpression in - let id = syncExpression["id"] as! String let modelName = syncExpression["modelName"] as! String let queryPredicate = try QueryPredicateBuilder.fromSerializedMap(syncExpression["queryPredicate"] as? [String: Any]) let modelSchema = modelSchemaRegistry.modelSchemas[modelName] return DataStoreSyncExpression.syncExpression(modelSchema!) { - var resolvedQueryPredicate = queryPredicate - let semaphore = DispatchSemaphore(value: 0) - DispatchQueue.main.async { - self.channel!.invokeMethod("resolveQueryPredicate", arguments: id) { result in - do { - resolvedQueryPredicate = try QueryPredicateBuilder.fromSerializedMap(result as? [String: Any]) - } catch { - print("Failed to resolve query predicate. Reverting to original query predicate.") - } - semaphore.signal() - } - } - semaphore.wait() - return resolvedQueryPredicate + return queryPredicate } } } From feec3f45c91dc24a6ccf5a9883baae2f2afd1d4d Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Tue, 28 Oct 2025 16:16:02 -0700 Subject: [PATCH 5/8] abc --- .../Classes/SwiftAmplifyDataStorePlugin.swift | 73 ++++++++++++++++--- 1 file changed, 63 insertions(+), 10 deletions(-) diff --git a/packages/amplify_datastore/ios/Classes/SwiftAmplifyDataStorePlugin.swift b/packages/amplify_datastore/ios/Classes/SwiftAmplifyDataStorePlugin.swift index acbc3e62bb0..020bf3ec15d 100644 --- a/packages/amplify_datastore/ios/Classes/SwiftAmplifyDataStorePlugin.swift +++ b/packages/amplify_datastore/ios/Classes/SwiftAmplifyDataStorePlugin.swift @@ -14,6 +14,7 @@ public class SwiftAmplifyDataStorePlugin: NSObject, FlutterPlugin, NativeAmplify private let nativeSubscriptionEventBus = PassthroughSubject() private var channel: FlutterMethodChannel? private var observeSubscription: AnyCancellable? + private var syncExpressionPredicates: [String: [String: Any]] = [:] private let nativeAuthPlugin: NativeAuthPlugin private let nativeApiPlugin: NativeApiPlugin private let cognitoPlugin: CognitoPlugin @@ -340,7 +341,14 @@ public class SwiftAmplifyDataStorePlugin: NSObject, FlutterPlugin, NativeAmplify try Amplify.add(plugin: dataStorePlugin) Amplify.Logging.logLevel = .info - print("Amplify configured with DataStore plugin") + print("[DataStore] Amplify configured with DataStore plugin") + print("[DataStore] Sync expressions count: \(syncExpressions.count)") + + // Listen to Hub events for debugging + _ = Amplify.Hub.listen(to: .dataStore) { payload in + print("[DataStore] Hub event: \(payload.eventName)") + } + result(true) } catch ModelSchemaError.parse(let className, let fieldName, let desiredType) { FlutterDataStoreErrorHandler.handleDataStoreError( @@ -528,22 +536,25 @@ public class SwiftAmplifyDataStorePlugin: NSObject, FlutterPlugin, NativeAmplify public func onSetUpObserve(flutterResult: @escaping FlutterResult) { do { + print("[DataStore] Setting up observe subscription. Current subscription exists: \(observeSubscription != nil)") observeSubscription = try observeSubscription ?? bridge.onObserve().sink { completion in switch completion { case .failure(let error): + print("[DataStore] Observe subscription failed: \(error)") let flutterError = FlutterError(code: "DataStoreException", message: ErrorMessages.defaultFallbackErrorMessage, details: FlutterDataStoreErrorHandler.createSerializedError(error: error)) self.dataStoreObserveEventStreamHandler?.sendError(flutterError: flutterError) case .finished: - print("finished") + print("[DataStore] Observe subscription finished") } } receiveValue: { mutationEvent in + print("[DataStore] Received mutation event: \(mutationEvent.mutationType) for model: \(mutationEvent.modelName)") do { let serializedEvent = try mutationEvent.decodeModel(as: FlutterSerializedModel.self) guard let eventType = EventType(rawValue: mutationEvent.mutationType) else { - print("Received mutation event for an unknown mutation type \(mutationEvent.mutationType).") + print("[DataStore] Unknown mutation type: \(mutationEvent.mutationType)") return } let flutterSubscriptionEvent = FlutterSubscriptionEvent.init( @@ -556,14 +567,15 @@ public class SwiftAmplifyDataStorePlugin: NSObject, FlutterPlugin, NativeAmplify modelName: mutationEvent.modelName ) ) + print("[DataStore] Successfully sent event to Flutter") } catch { - print("Failed to parse the event \(error)") - // TODO communicate using datastore error handler? + print("[DataStore] Failed to parse event: \(error)") } } + print("[DataStore] Observe subscription setup complete") flutterResult(true) } catch { - print("Failed to get the datastore plugin \(error)") + print("[DataStore] Failed to setup observe: \(error)") flutterResult(false) } } @@ -599,8 +611,31 @@ public class SwiftAmplifyDataStorePlugin: NSObject, FlutterPlugin, NativeAmplify error: error, flutterResult: flutterResult) case .success(): - print("Successfully started datastore cloud syncing") - flutterResult(nil) + print("[DataStore] Successfully started datastore cloud syncing") + print("[DataStore] Resetting observe subscription to reconnect with active publisher") + self.observeSubscription?.cancel() + self.observeSubscription = nil + + // Wait for DataStore to be fully ready before completing + var hasCompleted = false + let readyToken = Amplify.Hub.listen(to: .dataStore) { payload in + if payload.eventName == HubPayload.EventName.DataStore.ready && !hasCompleted { + print("[DataStore] DataStore ready event received") + hasCompleted = true + Amplify.Hub.removeListener(readyToken) + flutterResult(nil) + } + } + + // Fallback timeout in case ready event doesn't fire + DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) { + if !hasCompleted { + print("[DataStore] Ready event timeout, completing anyway") + hasCompleted = true + Amplify.Hub.removeListener(readyToken) + flutterResult(nil) + } + } } } } catch { @@ -644,12 +679,30 @@ public class SwiftAmplifyDataStorePlugin: NSObject, FlutterPlugin, NativeAmplify } private func createSyncExpressions(syncExpressionList: [[String: Any]]) throws -> [DataStoreSyncExpression] { + // Store predicates as instance variables to ensure they remain valid + for syncExpression in syncExpressionList { + let modelName = syncExpression["modelName"] as! String + if let queryPredicateMap = syncExpression["queryPredicate"] as? [String: Any] { + syncExpressionPredicates[modelName] = queryPredicateMap + } + } + return try syncExpressionList.map { syncExpression in let modelName = syncExpression["modelName"] as! String - let queryPredicate = try QueryPredicateBuilder.fromSerializedMap(syncExpression["queryPredicate"] as? [String: Any]) let modelSchema = modelSchemaRegistry.modelSchemas[modelName] return DataStoreSyncExpression.syncExpression(modelSchema!) { - return queryPredicate + guard let predicateMap = self.syncExpressionPredicates[modelName] else { + print("[DataStore] No predicate found for \(modelName), using .all") + return QueryPredicateConstant.all + } + do { + let predicate = try QueryPredicateBuilder.fromSerializedMap(predicateMap) + print("[DataStore] Sync expression evaluated for \(modelName)") + return predicate + } catch { + print("[DataStore] Failed to build predicate for \(modelName): \(error)") + return QueryPredicateConstant.all + } } } } From 180e36f39c60e46f82e0a30efd595141f5c795c5 Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Tue, 4 Nov 2025 18:10:27 -0800 Subject: [PATCH 6/8] main thread all --- .../Classes/SwiftAmplifyDataStorePlugin.swift | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/packages/amplify_datastore/ios/Classes/SwiftAmplifyDataStorePlugin.swift b/packages/amplify_datastore/ios/Classes/SwiftAmplifyDataStorePlugin.swift index 020bf3ec15d..3abd457d177 100644 --- a/packages/amplify_datastore/ios/Classes/SwiftAmplifyDataStorePlugin.swift +++ b/packages/amplify_datastore/ios/Classes/SwiftAmplifyDataStorePlugin.swift @@ -14,7 +14,6 @@ public class SwiftAmplifyDataStorePlugin: NSObject, FlutterPlugin, NativeAmplify private let nativeSubscriptionEventBus = PassthroughSubject() private var channel: FlutterMethodChannel? private var observeSubscription: AnyCancellable? - private var syncExpressionPredicates: [String: [String: Any]] = [:] private let nativeAuthPlugin: NativeAuthPlugin private let nativeApiPlugin: NativeApiPlugin private let cognitoPlugin: CognitoPlugin @@ -679,28 +678,21 @@ public class SwiftAmplifyDataStorePlugin: NSObject, FlutterPlugin, NativeAmplify } private func createSyncExpressions(syncExpressionList: [[String: Any]]) throws -> [DataStoreSyncExpression] { - // Store predicates as instance variables to ensure they remain valid - for syncExpression in syncExpressionList { - let modelName = syncExpression["modelName"] as! String - if let queryPredicateMap = syncExpression["queryPredicate"] as? [String: Any] { - syncExpressionPredicates[modelName] = queryPredicateMap - } - } - return try syncExpressionList.map { syncExpression in let modelName = syncExpression["modelName"] as! String let modelSchema = modelSchemaRegistry.modelSchemas[modelName] + + // Capture the predicate map at configuration time + let predicateMap = syncExpression["queryPredicate"] as? [String: Any] + return DataStoreSyncExpression.syncExpression(modelSchema!) { - guard let predicateMap = self.syncExpressionPredicates[modelName] else { - print("[DataStore] No predicate found for \(modelName), using .all") - return QueryPredicateConstant.all - } + // Build predicate synchronously from captured map + // This predicate is evaluated at sync time, not configuration time do { - let predicate = try QueryPredicateBuilder.fromSerializedMap(predicateMap) - print("[DataStore] Sync expression evaluated for \(modelName)") - return predicate + return try QueryPredicateBuilder.fromSerializedMap(predicateMap) } catch { - print("[DataStore] Failed to build predicate for \(modelName): \(error)") + print("[DataStore] Error building sync expression predicate: \(error)") + print("[DataStore] Falling back to .all for model \(modelName)") return QueryPredicateConstant.all } } From 2a6bbea62f52931b0347711415b5927e2dbe730b Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Tue, 4 Nov 2025 21:01:05 -0800 Subject: [PATCH 7/8] updated reconciliation queue to avoid client side filtering on recieve --- ...comingAsyncSubscriptionEventPublisher.swift | 2 ++ .../AWSModelReconciliationQueue.swift | 5 ----- .../GraphQLRequest+AnyModelWithSync.swift | 18 ++++++++++++++---- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/packages/amplify_datastore/ios/internal/AWSDataStorePlugin/Sync/SubscriptionSync/IncomingAsyncSubscriptionEventPublisher.swift b/packages/amplify_datastore/ios/internal/AWSDataStorePlugin/Sync/SubscriptionSync/IncomingAsyncSubscriptionEventPublisher.swift index 8ce0e56fb3b..765b4d34722 100644 --- a/packages/amplify_datastore/ios/internal/AWSDataStorePlugin/Sync/SubscriptionSync/IncomingAsyncSubscriptionEventPublisher.swift +++ b/packages/amplify_datastore/ios/internal/AWSDataStorePlugin/Sync/SubscriptionSync/IncomingAsyncSubscriptionEventPublisher.swift @@ -44,6 +44,7 @@ final class IncomingAsyncSubscriptionEventPublisher: AmplifyCancellable { private let consistencyQueue: DispatchQueue private let taskQueue: TaskQueue private let modelName: ModelName + private let modelPredicate: QueryPredicate? init(modelSchema: ModelSchema, api: APICategoryGraphQLBehavior, @@ -59,6 +60,7 @@ final class IncomingAsyncSubscriptionEventPublisher: AmplifyCancellable { ) self.taskQueue = TaskQueue() self.modelName = modelSchema.name + self.modelPredicate = modelPredicate self.connectionStatusQueue = OperationQueue() connectionStatusQueue.name diff --git a/packages/amplify_datastore/ios/internal/AWSDataStorePlugin/Sync/SubscriptionSync/ReconcileAndLocalSave/AWSModelReconciliationQueue.swift b/packages/amplify_datastore/ios/internal/AWSDataStorePlugin/Sync/SubscriptionSync/ReconcileAndLocalSave/AWSModelReconciliationQueue.swift index 58ac4ecf7ce..76af702b9b3 100644 --- a/packages/amplify_datastore/ios/internal/AWSDataStorePlugin/Sync/SubscriptionSync/ReconcileAndLocalSave/AWSModelReconciliationQueue.swift +++ b/packages/amplify_datastore/ios/internal/AWSDataStorePlugin/Sync/SubscriptionSync/ReconcileAndLocalSave/AWSModelReconciliationQueue.swift @@ -180,11 +180,6 @@ final class AWSModelReconciliationQueue: ModelReconciliationQueue { private func receive(_ receive: IncomingSubscriptionEventPublisherEvent) { switch receive { case .mutationEvent(let remoteModel): - if let predicate = modelPredicate { - guard predicate.evaluate(target: remoteModel.model.instance) else { - return - } - } incomingSubscriptionEventQueue.addOperation(CancelAwareBlockOperation { [weak self] in self?.enqueue([remoteModel]) }) diff --git a/packages/amplify_datastore/ios/internal/AWSPluginsCore/Model/GraphQLRequest/GraphQLRequest+AnyModelWithSync.swift b/packages/amplify_datastore/ios/internal/AWSPluginsCore/Model/GraphQLRequest/GraphQLRequest+AnyModelWithSync.swift index 301134b1d13..cae29671041 100644 --- a/packages/amplify_datastore/ios/internal/AWSPluginsCore/Model/GraphQLRequest/GraphQLRequest+AnyModelWithSync.swift +++ b/packages/amplify_datastore/ios/internal/AWSPluginsCore/Model/GraphQLRequest/GraphQLRequest+AnyModelWithSync.swift @@ -37,12 +37,14 @@ protocol ModelSyncGraphQLRequestFactory { static func subscription(to modelSchema: ModelSchema, subscriptionType: GraphQLSubscriptionType, - authType: AWSAuthorizationType?) -> GraphQLRequest + authType: AWSAuthorizationType?, + filter: QueryPredicate?) -> GraphQLRequest static func subscription(to modelSchema: ModelSchema, subscriptionType: GraphQLSubscriptionType, claims: IdentityClaimsDictionary, - authType: AWSAuthorizationType?) -> GraphQLRequest + authType: AWSAuthorizationType?, + filter: QueryPredicate?) -> GraphQLRequest static func syncQuery(modelSchema: ModelSchema, where predicate: QueryPredicate?, @@ -169,12 +171,16 @@ extension GraphQLRequest: ModelSyncGraphQLRequestFactory { public static func subscription(to modelSchema: ModelSchema, subscriptionType: GraphQLSubscriptionType, - authType: AWSAuthorizationType? = nil) -> GraphQLRequest { + authType: AWSAuthorizationType? = nil, + filter: QueryPredicate? = nil) -> GraphQLRequest { var documentBuilder = ModelBasedGraphQLDocumentBuilder(modelSchema: modelSchema, operationType: .subscription, primaryKeysOnly: true) documentBuilder.add(decorator: DirectiveNameDecorator(type: subscriptionType)) + if let predicate = filter { + documentBuilder.add(decorator: FilterDecorator(filter: predicate.graphQLFilter(for: modelSchema))) + } documentBuilder.add(decorator: ConflictResolutionDecorator(graphQLType: .subscription, primaryKeysOnly: true)) documentBuilder.add(decorator: AuthRuleDecorator(.subscription(subscriptionType, nil), authType: authType)) let document = documentBuilder.build() @@ -191,12 +197,16 @@ extension GraphQLRequest: ModelSyncGraphQLRequestFactory { public static func subscription(to modelSchema: ModelSchema, subscriptionType: GraphQLSubscriptionType, claims: IdentityClaimsDictionary, - authType: AWSAuthorizationType? = nil) -> GraphQLRequest { + authType: AWSAuthorizationType? = nil, + filter: QueryPredicate? = nil) -> GraphQLRequest { var documentBuilder = ModelBasedGraphQLDocumentBuilder(modelSchema: modelSchema, operationType: .subscription, primaryKeysOnly: true) documentBuilder.add(decorator: DirectiveNameDecorator(type: subscriptionType)) + if let predicate = filter { + documentBuilder.add(decorator: FilterDecorator(filter: predicate.graphQLFilter(for: modelSchema))) + } documentBuilder.add(decorator: ConflictResolutionDecorator(graphQLType: .subscription, primaryKeysOnly: true)) documentBuilder.add(decorator: AuthRuleDecorator(.subscription(subscriptionType, claims), authType: authType)) let document = documentBuilder.build() From e2ff5d5824fbf0abb1c71b48528a5e317292d8ab Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Mon, 1 Dec 2025 16:43:41 -0800 Subject: [PATCH 8/8] updated main canaries workflow and added auxiliary canaries for main packages --- .../amplify_analytics_pinpoint_canary.yaml | 95 +++++++ .github/workflows/amplify_api_canary.yaml | 168 +++++++++++++ .../amplify_auth_cognito_canary.yaml | 233 ++++++++++++++++++ .github/workflows/amplify_canaries.yaml | 4 +- .../workflows/amplify_datastore_canary.yaml | 168 +++++++++++++ .../workflows/amplify_storage_s3_canary.yaml | 168 +++++++++++++ 6 files changed, 834 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/amplify_analytics_pinpoint_canary.yaml create mode 100644 .github/workflows/amplify_api_canary.yaml create mode 100644 .github/workflows/amplify_auth_cognito_canary.yaml create mode 100644 .github/workflows/amplify_datastore_canary.yaml create mode 100644 .github/workflows/amplify_storage_s3_canary.yaml diff --git a/.github/workflows/amplify_analytics_pinpoint_canary.yaml b/.github/workflows/amplify_analytics_pinpoint_canary.yaml new file mode 100644 index 00000000000..e4cc4d59a90 --- /dev/null +++ b/.github/workflows/amplify_analytics_pinpoint_canary.yaml @@ -0,0 +1,95 @@ +# CANARY WORKFLOW +# This is a minimal weekly test for Analytics (Pinpoint). +# Runs every Monday at 6am PST. +# For comprehensive testing, see amplify_analytics_pinpoint_example.yaml +# Platform coverage: Android 35 only (stable channel only) +name: Analytics Canary +on: + pull_request: + paths: + - ".github/workflows/amplify_analytics_pinpoint_canary.yaml" + schedule: + # Weekly on Monday at 6am PST (13:00 UTC) + - cron: "0 13 * * 1" + workflow_dispatch: + +# These permissions are needed to interact with GitHub's OIDC Token endpoint. +permissions: + id-token: write + contents: read + +# Cancels in-progress job when there is another push to same ref. +# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + e2e-android: + runs-on: ubuntu-latest + # These permissions are needed to interact with GitHub's OIDC Token endpoint. + permissions: + id-token: write + contents: read + strategy: + fail-fast: false + matrix: + channel: + - "stable" + flutter-version: + - "any" # latest + steps: + - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # 4.0.0 + with: + persist-credentials: false + submodules: true + + - name: Install dependencies + uses: ./.github/composite_actions/install_dependencies + with: + channel: ${{ matrix.channel }} + flutter-version: ${{ matrix.flutter-version }} + + - uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # 5.0.0 + with: + distribution: "corretto" # Amazon Corretto Build of OpenJDK + java-version: "17" + + # Must be run before `fetch_backends` so that `pubspec.lock` is present. + - name: Pub Upgrade + working-directory: canaries + run: flutter pub upgrade + + - name: Fetch Amplify backend configurations + uses: ./.github/composite_actions/fetch_backends + with: + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws-region: ${{ secrets.AWS_REGION }} + scope: amplified_todo + secret-identifier: ${{ secrets.AWS_SECRET_IDENTIFIER }} + + - name: Run Analytics Canary (Android) + timeout-minutes: 45 + uses: ./.github/composite_actions/launch_android_emulator + with: + # Perform a build to reduce startup time of `flutter test` and prevent timeout + script: cd canaries && flutter build apk --debug && flutter test -d emulator-5554 integration_test/main_test.dart + + - name: Log success/failure + if: always() + uses: ./.github/composite_actions/log_cw_metric_wrapper + with: + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws-region: ${{ secrets.AWS_REGION }} + + job-status: ${{ job.status }} + github-token: ${{ secrets.GITHUB_TOKEN }} + + test-type: canary + working-directory: canaries + + framework: flutter + flutter-dart-channel: ${{ matrix.channel }} + flutter-version: ${{ matrix.flutter-version }} + platform: android + platform-version: "35" diff --git a/.github/workflows/amplify_api_canary.yaml b/.github/workflows/amplify_api_canary.yaml new file mode 100644 index 00000000000..19a57abffd5 --- /dev/null +++ b/.github/workflows/amplify_api_canary.yaml @@ -0,0 +1,168 @@ +# CANARY WORKFLOW +# This is a minimal weekly test for API (GraphQL and REST). +# Runs every Monday at 6am PST. +# For comprehensive testing, see amplify_api_example.yaml +# Platform coverage: iOS 17.5, Android 35 (stable channel only) +name: API Canary +on: + pull_request: + paths: + - ".github/workflows/amplify_api_canary.yaml" + schedule: + # Weekly on Monday at 6am PST (13:00 UTC) + - cron: "0 13 * * 1" + workflow_dispatch: + +# These permissions are needed to interact with GitHub's OIDC Token endpoint. +permissions: + id-token: write + contents: read + +# Cancels in-progress job when there is another push to same ref. +# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + e2e-android: + runs-on: ubuntu-latest + # These permissions are needed to interact with GitHub's OIDC Token endpoint. + permissions: + id-token: write + contents: read + strategy: + fail-fast: false + matrix: + channel: + - "stable" + flutter-version: + - "any" # latest + steps: + - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # 4.0.0 + with: + persist-credentials: false + submodules: true + + - name: Install dependencies + uses: ./.github/composite_actions/install_dependencies + with: + channel: ${{ matrix.channel }} + flutter-version: ${{ matrix.flutter-version }} + + - uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # 5.0.0 + with: + distribution: "corretto" # Amazon Corretto Build of OpenJDK + java-version: "17" + + # Must be run before `fetch_backends` so that `pubspec.lock` is present. + - name: Pub Upgrade + working-directory: canaries + run: flutter pub upgrade + + - name: Fetch Amplify backend configurations + uses: ./.github/composite_actions/fetch_backends + with: + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws-region: ${{ secrets.AWS_REGION }} + scope: amplified_todo + secret-identifier: ${{ secrets.AWS_SECRET_IDENTIFIER }} + + - name: Run API Canary (Android) + timeout-minutes: 45 + uses: ./.github/composite_actions/launch_android_emulator + with: + # Perform a build to reduce startup time of `flutter test` and prevent timeout + script: cd canaries && flutter build apk --debug && flutter test -d emulator-5554 integration_test/main_test.dart + + - name: Log success/failure + if: always() + uses: ./.github/composite_actions/log_cw_metric_wrapper + with: + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws-region: ${{ secrets.AWS_REGION }} + + job-status: ${{ job.status }} + github-token: ${{ secrets.GITHUB_TOKEN }} + + test-type: canary + working-directory: canaries + + framework: flutter + flutter-dart-channel: ${{ matrix.channel }} + flutter-version: ${{ matrix.flutter-version }} + platform: android + platform-version: "35" + + e2e-ios: + runs-on: macos-14-xlarge + # These permissions are needed to interact with GitHub's OIDC Token endpoint. + permissions: + id-token: write + contents: read + strategy: + fail-fast: false + matrix: + channel: + - "stable" + flutter-version: + - "any" # latest + ios-version: + - "17.5" + steps: + - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # 4.0.0 + with: + persist-credentials: false + submodules: true + + - name: Install dependencies + uses: ./.github/composite_actions/install_dependencies + with: + channel: ${{ matrix.channel }} + flutter-version: ${{ matrix.flutter-version }} + + # Must be run before `fetch_backends` so that `pubspec.lock` is present. + - name: Pub Upgrade + working-directory: canaries + run: flutter pub upgrade + + - name: Fetch Amplify backend configurations + uses: ./.github/composite_actions/fetch_backends + with: + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws-region: ${{ secrets.AWS_REGION }} + scope: amplified_todo + secret-identifier: ${{ secrets.AWS_SECRET_IDENTIFIER }} + + - name: Launch iOS simulator + uses: ./.github/composite_actions/launch_ios_simulator + timeout-minutes: 20 + with: + ios-version: ${{ matrix.ios-version }} + + - name: Run API Canary (iOS) + timeout-minutes: 45 + working-directory: canaries + run: | + # Perform a build to reduce startup time of `flutter test` and prevent timeout + flutter build ios --simulator --target=integration_test/main_test.dart + flutter test -d test integration_test/main_test.dart --verbose + + - name: Log success/failure + if: always() + uses: ./.github/composite_actions/log_cw_metric_wrapper + with: + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws-region: ${{ secrets.AWS_REGION }} + + job-status: ${{ job.status }} + github-token: ${{ secrets.GITHUB_TOKEN }} + + test-type: canary + working-directory: canaries + + framework: flutter + flutter-dart-channel: ${{ matrix.channel }} + flutter-version: ${{ matrix.flutter-version }} + platform: ios + platform-version: ${{ matrix.ios-version }} diff --git a/.github/workflows/amplify_auth_cognito_canary.yaml b/.github/workflows/amplify_auth_cognito_canary.yaml new file mode 100644 index 00000000000..b9650ac8294 --- /dev/null +++ b/.github/workflows/amplify_auth_cognito_canary.yaml @@ -0,0 +1,233 @@ +# CANARY WORKFLOW +# This is a minimal weekly test for Auth (Cognito). +# Runs every Monday at 6am PST. +# For comprehensive testing, see amplify_auth_cognito_example.yaml +# Platform coverage: iOS 17.5, Android 35, Web (stable channel only) +name: Auth Canary +on: + pull_request: + paths: + - ".github/workflows/amplify_auth_cognito_canary.yaml" + schedule: + # Weekly on Monday at 6am PST (13:00 UTC) + - cron: "0 13 * * 1" + workflow_dispatch: + +# These permissions are needed to interact with GitHub's OIDC Token endpoint. +permissions: + id-token: write + contents: read + +# Cancels in-progress job when there is another push to same ref. +# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + e2e-android: + runs-on: ubuntu-latest + # These permissions are needed to interact with GitHub's OIDC Token endpoint. + permissions: + id-token: write + contents: read + strategy: + fail-fast: false + matrix: + channel: + - "stable" + flutter-version: + - "any" # latest + steps: + - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # 4.0.0 + with: + persist-credentials: false + submodules: true + + - name: Install dependencies + uses: ./.github/composite_actions/install_dependencies + with: + channel: ${{ matrix.channel }} + flutter-version: ${{ matrix.flutter-version }} + + - uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # 5.0.0 + with: + distribution: "corretto" # Amazon Corretto Build of OpenJDK + java-version: "17" + + # Must be run before `fetch_backends` so that `pubspec.lock` is present. + - name: Pub Upgrade + working-directory: canaries + run: flutter pub upgrade + + - name: Fetch Amplify backend configurations + uses: ./.github/composite_actions/fetch_backends + with: + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws-region: ${{ secrets.AWS_REGION }} + scope: amplified_todo + secret-identifier: ${{ secrets.AWS_SECRET_IDENTIFIER }} + + - name: Run Auth Canary (Android) + timeout-minutes: 45 + uses: ./.github/composite_actions/launch_android_emulator + with: + # Perform a build to reduce startup time of `flutter test` and prevent timeout + script: cd canaries && flutter build apk --debug && flutter test -d emulator-5554 integration_test/main_test.dart + + - name: Log success/failure + if: always() + uses: ./.github/composite_actions/log_cw_metric_wrapper + with: + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws-region: ${{ secrets.AWS_REGION }} + + job-status: ${{ job.status }} + github-token: ${{ secrets.GITHUB_TOKEN }} + + test-type: canary + working-directory: canaries + + framework: flutter + flutter-dart-channel: ${{ matrix.channel }} + flutter-version: ${{ matrix.flutter-version }} + platform: android + platform-version: "35" + + e2e-ios: + runs-on: macos-14-xlarge + # These permissions are needed to interact with GitHub's OIDC Token endpoint. + permissions: + id-token: write + contents: read + strategy: + fail-fast: false + matrix: + channel: + - "stable" + flutter-version: + - "any" # latest + ios-version: + - "17.5" + steps: + - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # 4.0.0 + with: + persist-credentials: false + submodules: true + + - name: Install dependencies + uses: ./.github/composite_actions/install_dependencies + with: + channel: ${{ matrix.channel }} + flutter-version: ${{ matrix.flutter-version }} + + # Must be run before `fetch_backends` so that `pubspec.lock` is present. + - name: Pub Upgrade + working-directory: canaries + run: flutter pub upgrade + + - name: Fetch Amplify backend configurations + uses: ./.github/composite_actions/fetch_backends + with: + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws-region: ${{ secrets.AWS_REGION }} + scope: amplified_todo + secret-identifier: ${{ secrets.AWS_SECRET_IDENTIFIER }} + + - name: Launch iOS simulator + uses: ./.github/composite_actions/launch_ios_simulator + timeout-minutes: 20 + with: + ios-version: ${{ matrix.ios-version }} + + - name: Run Auth Canary (iOS) + timeout-minutes: 45 + working-directory: canaries + run: | + # Perform a build to reduce startup time of `flutter test` and prevent timeout + flutter build ios --simulator --target=integration_test/main_test.dart + flutter test -d test integration_test/main_test.dart --verbose + + - name: Log success/failure + if: always() + uses: ./.github/composite_actions/log_cw_metric_wrapper + with: + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws-region: ${{ secrets.AWS_REGION }} + + job-status: ${{ job.status }} + github-token: ${{ secrets.GITHUB_TOKEN }} + + test-type: canary + working-directory: canaries + + framework: flutter + flutter-dart-channel: ${{ matrix.channel }} + flutter-version: ${{ matrix.flutter-version }} + platform: ios + platform-version: ${{ matrix.ios-version }} + + e2e-web: + runs-on: ubuntu-latest + # These permissions are needed to interact with GitHub's OIDC Token endpoint. + permissions: + id-token: write + contents: read + strategy: + fail-fast: false + matrix: + channel: + - "stable" + flutter-version: + - "any" # latest + steps: + - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # 4.0.0 + with: + persist-credentials: false + submodules: true + + - name: Install dependencies + uses: ./.github/composite_actions/install_dependencies + with: + channel: ${{ matrix.channel }} + flutter-version: ${{ matrix.flutter-version }} + + # Must be run before `fetch_backends` so that `pubspec.lock` is present. + - name: Pub Upgrade + working-directory: canaries + run: flutter pub upgrade + + - name: Fetch Amplify backend configurations + uses: ./.github/composite_actions/fetch_backends + with: + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws-region: ${{ secrets.AWS_REGION }} + scope: amplified_todo + secret-identifier: ${{ secrets.AWS_SECRET_IDENTIFIER }} + + - uses: ./.github/composite_actions/setup_chromedriver + + - name: Run Auth Canary (Web) + timeout-minutes: 45 + working-directory: canaries + run: | + chromedriver --port=4444 & + flutter test -d web-server integration_test/main_test.dart + + - name: Log success/failure + if: always() + uses: ./.github/composite_actions/log_cw_metric_wrapper + with: + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws-region: ${{ secrets.AWS_REGION }} + + job-status: ${{ job.status }} + github-token: ${{ secrets.GITHUB_TOKEN }} + + test-type: canary + working-directory: canaries + + framework: flutter + flutter-dart-channel: ${{ matrix.channel }} + flutter-version: ${{ matrix.flutter-version }} + platform: web diff --git a/.github/workflows/amplify_canaries.yaml b/.github/workflows/amplify_canaries.yaml index c92ac9666d9..70a51683ac5 100644 --- a/.github/workflows/amplify_canaries.yaml +++ b/.github/workflows/amplify_canaries.yaml @@ -4,8 +4,8 @@ on: paths: - ".github/workflows/amplify_canaries.yaml" schedule: - # 6am pacific time daily, only runs on default branch - - cron: "0 13 * * *" + # 6am pacific time weekly (Monday), only runs on default branch + - cron: "0 13 * * 1" # Cancels in-progress job when there is another push to same ref. # https://docs.github.com/en/actions/using-jobs/using-concurrency#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow diff --git a/.github/workflows/amplify_datastore_canary.yaml b/.github/workflows/amplify_datastore_canary.yaml new file mode 100644 index 00000000000..4e34da41813 --- /dev/null +++ b/.github/workflows/amplify_datastore_canary.yaml @@ -0,0 +1,168 @@ +# CANARY WORKFLOW +# This is a minimal weekly test for DataStore. +# Runs every Monday at 6am PST. +# For comprehensive testing, see amplify_datastore_example.yaml +# Platform coverage: iOS 17.5, Android 35 (stable channel only) +name: DataStore Canary +on: + pull_request: + paths: + - ".github/workflows/amplify_datastore_canary.yaml" + schedule: + # Weekly on Monday at 6am PST (13:00 UTC) + - cron: "0 13 * * 1" + workflow_dispatch: + +# These permissions are needed to interact with GitHub's OIDC Token endpoint. +permissions: + id-token: write + contents: read + +# Cancels in-progress job when there is another push to same ref. +# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + e2e-android: + runs-on: ubuntu-latest + # These permissions are needed to interact with GitHub's OIDC Token endpoint. + permissions: + id-token: write + contents: read + strategy: + fail-fast: false + matrix: + channel: + - "stable" + flutter-version: + - "any" # latest + steps: + - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # 4.0.0 + with: + persist-credentials: false + submodules: true + + - name: Install dependencies + uses: ./.github/composite_actions/install_dependencies + with: + channel: ${{ matrix.channel }} + flutter-version: ${{ matrix.flutter-version }} + + - uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # 5.0.0 + with: + distribution: "corretto" # Amazon Corretto Build of OpenJDK + java-version: "17" + + # Must be run before `fetch_backends` so that `pubspec.lock` is present. + - name: Pub Upgrade + working-directory: canaries + run: flutter pub upgrade + + - name: Fetch Amplify backend configurations + uses: ./.github/composite_actions/fetch_backends + with: + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws-region: ${{ secrets.AWS_REGION }} + scope: amplified_todo + secret-identifier: ${{ secrets.AWS_SECRET_IDENTIFIER }} + + - name: Run DataStore Canary (Android) + timeout-minutes: 45 + uses: ./.github/composite_actions/launch_android_emulator + with: + # Perform a build to reduce startup time of `flutter test` and prevent timeout + script: cd canaries && flutter build apk --debug && flutter test -d emulator-5554 integration_test/main_test.dart + + - name: Log success/failure + if: always() + uses: ./.github/composite_actions/log_cw_metric_wrapper + with: + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws-region: ${{ secrets.AWS_REGION }} + + job-status: ${{ job.status }} + github-token: ${{ secrets.GITHUB_TOKEN }} + + test-type: canary + working-directory: canaries + + framework: flutter + flutter-dart-channel: ${{ matrix.channel }} + flutter-version: ${{ matrix.flutter-version }} + platform: android + platform-version: "35" + + e2e-ios: + runs-on: macos-14-xlarge + # These permissions are needed to interact with GitHub's OIDC Token endpoint. + permissions: + id-token: write + contents: read + strategy: + fail-fast: false + matrix: + channel: + - "stable" + flutter-version: + - "any" # latest + ios-version: + - "17.5" + steps: + - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # 4.0.0 + with: + persist-credentials: false + submodules: true + + - name: Install dependencies + uses: ./.github/composite_actions/install_dependencies + with: + channel: ${{ matrix.channel }} + flutter-version: ${{ matrix.flutter-version }} + + # Must be run before `fetch_backends` so that `pubspec.lock` is present. + - name: Pub Upgrade + working-directory: canaries + run: flutter pub upgrade + + - name: Fetch Amplify backend configurations + uses: ./.github/composite_actions/fetch_backends + with: + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws-region: ${{ secrets.AWS_REGION }} + scope: amplified_todo + secret-identifier: ${{ secrets.AWS_SECRET_IDENTIFIER }} + + - name: Launch iOS simulator + uses: ./.github/composite_actions/launch_ios_simulator + timeout-minutes: 20 + with: + ios-version: ${{ matrix.ios-version }} + + - name: Run DataStore Canary (iOS) + timeout-minutes: 45 + working-directory: canaries + run: | + # Perform a build to reduce startup time of `flutter test` and prevent timeout + flutter build ios --simulator --target=integration_test/main_test.dart + flutter test -d test integration_test/main_test.dart --verbose + + - name: Log success/failure + if: always() + uses: ./.github/composite_actions/log_cw_metric_wrapper + with: + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws-region: ${{ secrets.AWS_REGION }} + + job-status: ${{ job.status }} + github-token: ${{ secrets.GITHUB_TOKEN }} + + test-type: canary + working-directory: canaries + + framework: flutter + flutter-dart-channel: ${{ matrix.channel }} + flutter-version: ${{ matrix.flutter-version }} + platform: ios + platform-version: ${{ matrix.ios-version }} diff --git a/.github/workflows/amplify_storage_s3_canary.yaml b/.github/workflows/amplify_storage_s3_canary.yaml new file mode 100644 index 00000000000..7fcc545566e --- /dev/null +++ b/.github/workflows/amplify_storage_s3_canary.yaml @@ -0,0 +1,168 @@ +# CANARY WORKFLOW +# This is a minimal weekly test for Storage (S3). +# Runs every Monday at 6am PST. +# For comprehensive testing, see amplify_storage_s3_example.yaml +# Platform coverage: iOS 17.5, Android 35 (stable channel only) +name: Storage Canary +on: + pull_request: + paths: + - ".github/workflows/amplify_storage_s3_canary.yaml" + schedule: + # Weekly on Monday at 6am PST (13:00 UTC) + - cron: "0 13 * * 1" + workflow_dispatch: + +# These permissions are needed to interact with GitHub's OIDC Token endpoint. +permissions: + id-token: write + contents: read + +# Cancels in-progress job when there is another push to same ref. +# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + e2e-android: + runs-on: ubuntu-latest + # These permissions are needed to interact with GitHub's OIDC Token endpoint. + permissions: + id-token: write + contents: read + strategy: + fail-fast: false + matrix: + channel: + - "stable" + flutter-version: + - "any" # latest + steps: + - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # 4.0.0 + with: + persist-credentials: false + submodules: true + + - name: Install dependencies + uses: ./.github/composite_actions/install_dependencies + with: + channel: ${{ matrix.channel }} + flutter-version: ${{ matrix.flutter-version }} + + - uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # 5.0.0 + with: + distribution: "corretto" # Amazon Corretto Build of OpenJDK + java-version: "17" + + # Must be run before `fetch_backends` so that `pubspec.lock` is present. + - name: Pub Upgrade + working-directory: canaries + run: flutter pub upgrade + + - name: Fetch Amplify backend configurations + uses: ./.github/composite_actions/fetch_backends + with: + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws-region: ${{ secrets.AWS_REGION }} + scope: amplified_todo + secret-identifier: ${{ secrets.AWS_SECRET_IDENTIFIER }} + + - name: Run Storage Canary (Android) + timeout-minutes: 45 + uses: ./.github/composite_actions/launch_android_emulator + with: + # Perform a build to reduce startup time of `flutter test` and prevent timeout + script: cd canaries && flutter build apk --debug && flutter test -d emulator-5554 integration_test/main_test.dart + + - name: Log success/failure + if: always() + uses: ./.github/composite_actions/log_cw_metric_wrapper + with: + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws-region: ${{ secrets.AWS_REGION }} + + job-status: ${{ job.status }} + github-token: ${{ secrets.GITHUB_TOKEN }} + + test-type: canary + working-directory: canaries + + framework: flutter + flutter-dart-channel: ${{ matrix.channel }} + flutter-version: ${{ matrix.flutter-version }} + platform: android + platform-version: "35" + + e2e-ios: + runs-on: macos-14-xlarge + # These permissions are needed to interact with GitHub's OIDC Token endpoint. + permissions: + id-token: write + contents: read + strategy: + fail-fast: false + matrix: + channel: + - "stable" + flutter-version: + - "any" # latest + ios-version: + - "17.5" + steps: + - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # 4.0.0 + with: + persist-credentials: false + submodules: true + + - name: Install dependencies + uses: ./.github/composite_actions/install_dependencies + with: + channel: ${{ matrix.channel }} + flutter-version: ${{ matrix.flutter-version }} + + # Must be run before `fetch_backends` so that `pubspec.lock` is present. + - name: Pub Upgrade + working-directory: canaries + run: flutter pub upgrade + + - name: Fetch Amplify backend configurations + uses: ./.github/composite_actions/fetch_backends + with: + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws-region: ${{ secrets.AWS_REGION }} + scope: amplified_todo + secret-identifier: ${{ secrets.AWS_SECRET_IDENTIFIER }} + + - name: Launch iOS simulator + uses: ./.github/composite_actions/launch_ios_simulator + timeout-minutes: 20 + with: + ios-version: ${{ matrix.ios-version }} + + - name: Run Storage Canary (iOS) + timeout-minutes: 45 + working-directory: canaries + run: | + # Perform a build to reduce startup time of `flutter test` and prevent timeout + flutter build ios --simulator --target=integration_test/main_test.dart + flutter test -d test integration_test/main_test.dart --verbose + + - name: Log success/failure + if: always() + uses: ./.github/composite_actions/log_cw_metric_wrapper + with: + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws-region: ${{ secrets.AWS_REGION }} + + job-status: ${{ job.status }} + github-token: ${{ secrets.GITHUB_TOKEN }} + + test-type: canary + working-directory: canaries + + framework: flutter + flutter-dart-channel: ${{ matrix.channel }} + flutter-version: ${{ matrix.flutter-version }} + platform: ios + platform-version: ${{ matrix.ios-version }}