Skip to content

Commit

Permalink
Merge branch 'main' into test/analytics_integration
Browse files Browse the repository at this point in the history
* main:
  chore(ci): update dependency review config file path (#3233)
  test(logging): add logging plugin integration test (#3218)
  chore: remove unnecessary CloudWatch dependency from logger plugin (#3235)
  chore: Update CHANGELOG.md for 2.18.0 (#3236)
  chore: finalize release 2.18.1 [skip ci]
  chore: release 2.18.1 [skip ci]
  fix(datastore): call errorHandler in Sync operation when failure
  • Loading branch information
phantumcode committed Sep 26, 2023
2 parents 887fddc + 318385d commit 53dc859
Show file tree
Hide file tree
Showing 23 changed files with 1,784 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
- name: Dependency Review
uses: actions/dependency-review-action@7d90b4f05fea31dde1c4a1fb3fa787e197ea93ab # v3.0.7
with:
config-file: aws-amplify/amplify-ci-support/.github/dependency-review-config.yml@main
config-file: amazon-ospo/dependency-review-config/default/dependency-review-config.yml@main
5 changes: 5 additions & 0 deletions .github/workflows/integ_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,8 @@ jobs:
needs: prepare-for-test
uses: ./.github/workflows/integ_test_storage.yml
secrets: inherit

logging-test:
needs: prepare-for-test
uses: ./.github/workflows/integ_test_logging.yml
secrets: inherit
90 changes: 90 additions & 0 deletions .github/workflows/integ_test_logging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Integration Tests | Logging
on:
workflow_dispatch:
workflow_call:

permissions:
id-token: write
contents: read

jobs:
logging-integration-test-iOS:
runs-on: macos-12
environment: IntegrationTest
steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
with:
persist-credentials: false

- name: Make directory
run: mkdir -p ~/.aws-amplify/amplify-ios/testconfiguration/

- name: Copy integration test resouces
uses: ./.github/composite_actions/download_test_configuration
with:
resource_subfolder: logging
aws_role_to_assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws_region: ${{ secrets.AWS_REGION }}
aws_s3_bucket: ${{ secrets.AWS_S3_BUCKET_INTEG_V2 }}

- name: Run Integration test
uses: ./.github/composite_actions/run_xcodebuild_test
with:
project_path: ./AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp
scheme: AWSCloudWatchLoggingPluginIntegrationTests

logging-integration-test-tvOS:
runs-on: macos-13
environment: IntegrationTest
steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
with:
persist-credentials: false

- name: Make directory
run: mkdir -p ~/.aws-amplify/amplify-ios/testconfiguration/

- name: Copy integration test resouces
uses: ./.github/composite_actions/download_test_configuration
with:
resource_subfolder: logging
aws_role_to_assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws_region: ${{ secrets.AWS_REGION }}
aws_s3_bucket: ${{ secrets.AWS_S3_BUCKET_INTEG_V2 }}

- name: Run Integration test
uses: ./.github/composite_actions/run_xcodebuild_test
with:
project_path: ./AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp
scheme: AWSCloudWatchLoggingPluginIntegrationTests
destination: platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=latest
sdk: appletvsimulator
xcode_path: '/Applications/Xcode_14.3.app'

logging-integration-test-watchOS:
runs-on: macos-13
environment: IntegrationTest
steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
with:
persist-credentials: false

- name: Make directory
run: mkdir -p ~/.aws-amplify/amplify-ios/testconfiguration/

- name: Copy integration test resouces
uses: ./.github/composite_actions/download_test_configuration
with:
resource_subfolder: logging
aws_role_to_assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws_region: ${{ secrets.AWS_REGION }}
aws_s3_bucket: ${{ secrets.AWS_S3_BUCKET_INTEG_V2 }}

- name: Run Integration test
uses: ./.github/composite_actions/run_xcodebuild_test
with:
project_path: ./AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp
scheme: AWSCloudWatchLoggingPluginIntegrationTestsWatch
destination: platform=watchOS Simulator,name=Apple Watch Series 8 (45mm),OS=latest
sdk: watchsimulator
xcode_path: '/Applications/Xcode_14.3.app'
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Amplify
public class AmplifyAWSServiceConfiguration {

/// - Tag: AmplifyAWSServiceConfiguration.amplifyVersion
public static let amplifyVersion = "2.18.0"
public static let amplifyVersion = "2.18.1"

/// - Tag: AmplifyAWSServiceConfiguration.platformName
public static let platformName = "amplify-swift"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,13 @@ final class InitialSyncOperation: AsynchronousOperation {
switch result {
case .failure(let apiError):
if self.isAuthSignedOutError(apiError: apiError) {
self.dataStoreConfiguration.errorHandler(DataStoreError.api(apiError))
self.log.error("Sync for \(self.modelSchema.name) failed due to signed out error \(apiError.errorDescription)")
}

// TODO: Retry query on error
self.finish(result: .failure(DataStoreError.api(apiError)))
let error = DataStoreError.api(apiError)
self.dataStoreConfiguration.errorHandler(error)
self.finish(result: .failure(error))
case .success(let graphQLResult):
self.handleQueryResults(lastSyncTime: lastSyncTime, graphQLResult: graphQLResult)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public class AWSCloudWatchLoggingPlugin: LoggingCategoryPlugin {
localStore.reset()
}

DispatchQueue.main.async {
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(500)) {
self.loggingClient.takeUserIdentifierFromCurrentUser()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// Copyright Amazon.com Inc. or its affiliates.
// All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//

import Foundation
import AWSCloudWatchLogs

class AWSCloudWatchClientHelper {
static func getFilterLogEventCount(client: CloudWatchLogsClientProtocol?, filterPattern: String?, startTime: Date?, endTime: Date?, logGroupName: String?) async throws -> [CloudWatchLogsClientTypes.FilteredLogEvent]? {
let filterEventInput = FilterLogEventsInput(endTime: endTime?.epochMilliseconds, filterPattern: filterPattern, logGroupName: logGroupName, startTime: startTime?.epochMilliseconds)
let response = try await client?.filterLogEvents(input: filterEventInput)
return response?.events
}
}

extension Date {
var epochMilliseconds: Int {
Int(self.timeIntervalSince1970 * 1_000)
}
}
Loading

0 comments on commit 53dc859

Please sign in to comment.