From 60c5e48a4ef4092c076150674dd88a64cb822cac Mon Sep 17 00:00:00 2001 From: Harsh <6162866+harsh62@users.noreply.github.com> Date: Sun, 20 Oct 2024 22:00:13 -0400 Subject: [PATCH] chore: add visionOS to build and unit test jobs (#3900) * chore: enabling unit tests for vision os * adding missing condition * fixing the sdk mapping * add vision os to build * update action and add vision os * remove vision os from minimum build * try xcode 15.4 * trying out macos 15 * fixing latest versions * fix API tests for Xcode 16 * add workflow dispatch for visionos * fix typo --- .../get_platform_parameters/action.yml | 27 ++++++++----- .../build_amplify_swift_platforms.yml | 9 ++++- .github/workflows/build_scheme.yml | 2 +- .github/workflows/run_integration_tests.yml | 2 +- .../workflows/run_unit_tests_platforms.yml | 5 ++- .github/workflows/unit_test.yml | 6 +++ .github/workflows/unit_test_amplify.yml | 5 +++ .github/workflows/unit_test_analytics.yml | 7 +++- .github/workflows/unit_test_api.yml | 5 +++ .github/workflows/unit_test_auth.yml | 7 +++- .github/workflows/unit_test_core.yml | 7 +++- .github/workflows/unit_test_datastore.yml | 7 +++- .github/workflows/unit_test_geo.yml | 5 +++ .../workflows/unit_test_internal_pinpoint.yml | 5 +++ .github/workflows/unit_test_logging.yml | 7 +++- .github/workflows/unit_test_predictions.yml | 7 +++- .../unit_test_push_notifications.yml | 7 +++- .github/workflows/unit_test_storage.yml | 7 +++- .../AppSyncRealTimeRequestAuthTests.swift | 38 ++++++++++++++++--- .../Support/Utils/RESTRequestUtilsTests.swift | 3 +- 20 files changed, 140 insertions(+), 28 deletions(-) diff --git a/.github/composite_actions/get_platform_parameters/action.yml b/.github/composite_actions/get_platform_parameters/action.yml index 7ac2d4f612..c7e2ffdeda 100644 --- a/.github/composite_actions/get_platform_parameters/action.yml +++ b/.github/composite_actions/get_platform_parameters/action.yml @@ -34,14 +34,14 @@ runs: run: | INPUT_PLATFORM=${{ inputs.platform }} case $INPUT_PLATFORM in - iOS|tvOS|watchOS|macOS) ;; + iOS|tvOS|watchOS|macOS|visionOS) ;; *) echo "Unsupported platform: $INPUT_PLATFORM"; exit 1 ;; esac shell: bash - id: get-xcode-version run: | - LATEST_XCODE_VERSION=15.3.0 + LATEST_XCODE_VERSION=16.0.0 MINIMUM_XCODE_VERSION=15.0.1 INPUT_XCODE_VERSION=${{ inputs.xcode_version }} @@ -66,8 +66,8 @@ runs: case $INPUT_PLATFORM/$INPUT_XCODE_VERSION in iOS/latest) - DEVICE="iPhone 15" - OS_VERSION="17.4" + DEVICE="iPhone 16" + OS_VERSION="18.0" ;; iOS/*) DEVICE="iPhone 14" @@ -75,26 +75,35 @@ runs: ;; tvOS/latest) DEVICE="Apple TV 4K (3rd generation)" - OS_VERSION="17.4" + OS_VERSION="18.0" ;; tvOS/*) DEVICE="Apple TV 4K (3rd generation)" OS_VERSION="17.0" ;; watchOS/latest) - DEVICE="Apple Watch Series 9 (45mm)" - OS_VERSION="10.4" + DEVICE="Apple Watch Series 10 (46mm)" + OS_VERSION="11.0" ;; watchOS/*) DEVICE="Apple Watch Series 8 (45mm)" OS_VERSION="10.0" ;; + visionOS/latest) + DEVICE="Apple Vision Pro" + OS_VERSION="2.0" + ;; + visionOS/*) + DEVICE="Apple Vision Pro" + OS_VERSION="1.0" + ;; esac DESTINATION_MAPPING="{ \"iOS\": \"platform=iOS Simulator,name=$DEVICE,OS=$OS_VERSION\", \"tvOS\": \"platform=tvOS Simulator,name=$DEVICE,OS=$OS_VERSION\", \"watchOS\": \"platform=watchOS Simulator,name=$DEVICE,OS=$OS_VERSION\", + \"visionOS\": \"platform=visionOS Simulator,name=$DEVICE,OS=$OS_VERSION\", \"macOS\": \"platform=macOS,arch=arm64\" }" @@ -119,8 +128,8 @@ runs: "iOS": "iphonesimulator", "tvOS": "appletvsimulator", "watchOS": "watchsimulator", + "visionOS": "xrsimulator", "macOS": "macosx" }' echo "sdk=$(echo $SDK_MAPPING | jq -r .$INPUT_PLATFORM)" >> $GITHUB_OUTPUT - shell: bash - + shell: bash \ No newline at end of file diff --git a/.github/workflows/build_amplify_swift_platforms.yml b/.github/workflows/build_amplify_swift_platforms.yml index 2d8c6ce5c5..d315105fd9 100644 --- a/.github/workflows/build_amplify_swift_platforms.yml +++ b/.github/workflows/build_amplify_swift_platforms.yml @@ -27,6 +27,12 @@ on: required: true default: true type: boolean + visionos: + description: 'ᯅ visionOS' + required: true + default: true + type: boolean + push: branches-ignore: - main @@ -46,12 +52,13 @@ jobs: strategy: fail-fast: false matrix: - platform: [iOS, macOS, tvOS, watchOS] + platform: [iOS, macOS, tvOS, watchOS, visionOS] exclude: - platform: ${{ github.event.inputs.ios == 'false' && 'iOS' || 'None' }} - platform: ${{ github.event.inputs.macos == 'false' && 'macOS' || 'None' }} - platform: ${{ github.event.inputs.tvos == 'false' && 'tvOS' || 'None' }} - platform: ${{ github.event.inputs.watchos == 'false' && 'watchOS' || 'None' }} + - platform: ${{ github.event.inputs.visionos == 'false' && 'visionOS' || 'None' }} uses: ./.github/workflows/build_scheme.yml with: scheme: Amplify-Package diff --git a/.github/workflows/build_scheme.yml b/.github/workflows/build_scheme.yml index df802858ee..f4540f5b59 100644 --- a/.github/workflows/build_scheme.yml +++ b/.github/workflows/build_scheme.yml @@ -16,7 +16,7 @@ on: os-runner: type: string - default: 'macos-latest' + default: 'macos-15' save_build_cache: type: boolean diff --git a/.github/workflows/run_integration_tests.yml b/.github/workflows/run_integration_tests.yml index cf7e5d57df..af7296cbf6 100644 --- a/.github/workflows/run_integration_tests.yml +++ b/.github/workflows/run_integration_tests.yml @@ -4,7 +4,7 @@ on: inputs: os-runner: type: string - default: 'macos-latest' + default: 'macos-15' scheme: description: 'The scheme to run the tests' required: true diff --git a/.github/workflows/run_unit_tests_platforms.yml b/.github/workflows/run_unit_tests_platforms.yml index 972a4e64dd..f9086906cb 100644 --- a/.github/workflows/run_unit_tests_platforms.yml +++ b/.github/workflows/run_unit_tests_platforms.yml @@ -24,7 +24,7 @@ on: os-runner: description: 'runs-on input' type: string - default: 'macos-latest' + default: 'macos-15' permissions: contents: read @@ -35,12 +35,13 @@ jobs: strategy: fail-fast: false matrix: - platform: [iOS, macOS, tvOS, watchOS] + platform: [iOS, macOS, tvOS, watchOS, visionOS] exclude: - platform: ${{ github.event.inputs.ios == 'false' && 'iOS' || 'None' }} - platform: ${{ github.event.inputs.macos == 'false' && 'macOS' || 'None' }} - platform: ${{ github.event.inputs.tvos == 'false' && 'tvOS' || 'None' }} - platform: ${{ github.event.inputs.watchos == 'false' && 'watchOS' || 'None' }} + - platform: ${{ github.event.inputs.visionos == 'false' && 'visionOS' || 'None' }} uses: ./.github/workflows/run_unit_tests.yml with: scheme: ${{ inputs.scheme }} diff --git a/.github/workflows/unit_test.yml b/.github/workflows/unit_test.yml index 008683f254..fff17f570b 100644 --- a/.github/workflows/unit_test.yml +++ b/.github/workflows/unit_test.yml @@ -28,6 +28,12 @@ on: required: true default: true type: boolean + visionos: + description: 'ᯅ visionOS' + required: true + default: true + type: boolean + push: branches-ignore: - main diff --git a/.github/workflows/unit_test_amplify.yml b/.github/workflows/unit_test_amplify.yml index fd6189cdd8..6b1349437b 100644 --- a/.github/workflows/unit_test_amplify.yml +++ b/.github/workflows/unit_test_amplify.yml @@ -22,6 +22,11 @@ on: required: true default: true type: boolean + visionos: + description: 'ᯅ visionOS' + required: true + default: true + type: boolean permissions: contents: read diff --git a/.github/workflows/unit_test_analytics.yml b/.github/workflows/unit_test_analytics.yml index 94108b08c4..e65852cf47 100644 --- a/.github/workflows/unit_test_analytics.yml +++ b/.github/workflows/unit_test_analytics.yml @@ -22,7 +22,12 @@ on: required: true default: true type: boolean - + visionos: + description: 'ᯅ visionOS' + required: true + default: true + type: boolean + permissions: contents: read diff --git a/.github/workflows/unit_test_api.yml b/.github/workflows/unit_test_api.yml index 75a135c36c..1c4683247b 100644 --- a/.github/workflows/unit_test_api.yml +++ b/.github/workflows/unit_test_api.yml @@ -22,6 +22,11 @@ on: required: true default: true type: boolean + visionos: + description: 'ᯅ visionOS' + required: true + default: true + type: boolean permissions: contents: read diff --git a/.github/workflows/unit_test_auth.yml b/.github/workflows/unit_test_auth.yml index f1c6e982b8..d9041354b0 100644 --- a/.github/workflows/unit_test_auth.yml +++ b/.github/workflows/unit_test_auth.yml @@ -22,7 +22,12 @@ on: required: true default: true type: boolean - + visionos: + description: 'ᯅ visionOS' + required: true + default: true + type: boolean + permissions: contents: read diff --git a/.github/workflows/unit_test_core.yml b/.github/workflows/unit_test_core.yml index 252c28b5e0..e424026cf0 100644 --- a/.github/workflows/unit_test_core.yml +++ b/.github/workflows/unit_test_core.yml @@ -22,7 +22,12 @@ on: required: true default: true type: boolean - + visionos: + description: 'ᯅ visionOS' + required: true + default: true + type: boolean + permissions: contents: read diff --git a/.github/workflows/unit_test_datastore.yml b/.github/workflows/unit_test_datastore.yml index 43e31f643c..eab371aa33 100644 --- a/.github/workflows/unit_test_datastore.yml +++ b/.github/workflows/unit_test_datastore.yml @@ -22,7 +22,12 @@ on: required: true default: true type: boolean - + visionos: + description: 'ᯅ visionOS' + required: true + default: true + type: boolean + permissions: contents: read diff --git a/.github/workflows/unit_test_geo.yml b/.github/workflows/unit_test_geo.yml index 137deacd3d..4b2ed4590f 100644 --- a/.github/workflows/unit_test_geo.yml +++ b/.github/workflows/unit_test_geo.yml @@ -22,6 +22,11 @@ on: required: true default: true type: boolean + visionos: + description: 'ᯅ visionOS' + required: true + default: true + type: boolean permissions: contents: read diff --git a/.github/workflows/unit_test_internal_pinpoint.yml b/.github/workflows/unit_test_internal_pinpoint.yml index 33aff6b2aa..4f3781bc27 100644 --- a/.github/workflows/unit_test_internal_pinpoint.yml +++ b/.github/workflows/unit_test_internal_pinpoint.yml @@ -22,6 +22,11 @@ on: required: true default: true type: boolean + visionos: + description: 'ᯅ visionOS' + required: true + default: true + type: boolean permissions: contents: read diff --git a/.github/workflows/unit_test_logging.yml b/.github/workflows/unit_test_logging.yml index 8da0b1fd8d..55bef23dbf 100644 --- a/.github/workflows/unit_test_logging.yml +++ b/.github/workflows/unit_test_logging.yml @@ -22,7 +22,12 @@ on: required: true default: true type: boolean - + visionos: + description: 'ᯅ visionOS' + required: true + default: true + type: boolean + permissions: contents: read diff --git a/.github/workflows/unit_test_predictions.yml b/.github/workflows/unit_test_predictions.yml index 3d382e65a3..9276cf3192 100644 --- a/.github/workflows/unit_test_predictions.yml +++ b/.github/workflows/unit_test_predictions.yml @@ -22,7 +22,12 @@ on: required: true default: true type: boolean - + visionos: + description: 'ᯅ visionOS' + required: true + default: true + type: boolean + permissions: contents: read diff --git a/.github/workflows/unit_test_push_notifications.yml b/.github/workflows/unit_test_push_notifications.yml index c78bf7f88a..93d321ba46 100644 --- a/.github/workflows/unit_test_push_notifications.yml +++ b/.github/workflows/unit_test_push_notifications.yml @@ -22,7 +22,12 @@ on: required: true default: true type: boolean - + visionos: + description: 'ᯅ visionOS' + required: true + default: true + type: boolean + permissions: contents: read diff --git a/.github/workflows/unit_test_storage.yml b/.github/workflows/unit_test_storage.yml index 21ce464d6e..68cf743608 100644 --- a/.github/workflows/unit_test_storage.yml +++ b/.github/workflows/unit_test_storage.yml @@ -22,7 +22,12 @@ on: required: true default: true type: boolean - + visionos: + description: 'ᯅ visionOS' + required: true + default: true + type: boolean + permissions: contents: read diff --git a/AmplifyPlugins/API/Tests/AWSAPIPluginTests/AppSyncRealTimeClient/AppSyncRealTimeRequestAuthTests.swift b/AmplifyPlugins/API/Tests/AWSAPIPluginTests/AppSyncRealTimeClient/AppSyncRealTimeRequestAuthTests.swift index e9f4061431..ba57f00238 100644 --- a/AmplifyPlugins/API/Tests/AWSAPIPluginTests/AppSyncRealTimeClient/AppSyncRealTimeRequestAuthTests.swift +++ b/AmplifyPlugins/API/Tests/AWSAPIPluginTests/AppSyncRealTimeClient/AppSyncRealTimeRequestAuthTests.swift @@ -53,7 +53,10 @@ class AppSyncRealTimeRequestAuthTests: XCTestCase { amzDate: date ) - XCTAssertEqual(toJson(iamAuth)?.shrink(), """ + // Convert to JSON and then parse it back into a dictionary for comparison + let iamAuthJson = toJson(iamAuth)?.shrink() + + let expectedJsonString = """ { "accept": "application\\/json, text\\/javascript", "Authorization": "\(token)", @@ -63,7 +66,24 @@ class AppSyncRealTimeRequestAuthTests: XCTestCase { "x-amz-date": "\(date)", "X-Amz-Security-Token": "\(securityToken)" } - """.shrink()) + """.shrink() + + // Convert both JSON strings to dictionaries for comparison + let iamAuthDict = convertToDictionary(text: iamAuthJson) + let expectedDict = convertToDictionary(text: expectedJsonString) + + // Assert that the dictionaries are equal using the custom method + XCTAssertTrue(areDictionariesEqual(iamAuthDict, expectedDict)) + } + + private func convertToDictionary(text: String?) -> [String: Any]? { + guard let data = text?.data(using: .utf8) else { return nil } + return try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] + } + + private func areDictionariesEqual(_ lhs: [String: Any]?, _ rhs: [String: Any]?) -> Bool { + guard let lhs = lhs, let rhs = rhs else { return false } + return NSDictionary(dictionary: lhs).isEqual(to: rhs) } func testAppSyncRealTimeRequestAuth_encodeStartRequestWithCognitoAuth() { @@ -124,8 +144,9 @@ class AppSyncRealTimeRequestAuthTests: XCTestCase { let request = AppSyncRealTimeRequest.start( .init(id: id, data: data, auth: .iam(iamAuth)) ) - let requestJson = toJson(request) - XCTAssertEqual(requestJson?.shrink(), """ + let requestJson = toJson(request)?.shrink() + + let expectedJsonString = """ { "id": "\(id)", "payload": { @@ -144,7 +165,14 @@ class AppSyncRealTimeRequestAuthTests: XCTestCase { }, "type": "start" } - """.shrink()) + """.shrink() + + // Convert both JSON strings to dictionaries for comparison + let requestDict = convertToDictionary(text: requestJson) + let expectedDict = convertToDictionary(text: expectedJsonString) + + // Assert that the dictionaries are equal using the custom method + XCTAssertTrue(areDictionariesEqual(requestDict, expectedDict)) } private func toJson(_ value: Encodable) -> String? { diff --git a/AmplifyPlugins/API/Tests/AWSAPIPluginTests/Support/Utils/RESTRequestUtilsTests.swift b/AmplifyPlugins/API/Tests/AWSAPIPluginTests/Support/Utils/RESTRequestUtilsTests.swift index 7d3af18917..c2c751ca06 100644 --- a/AmplifyPlugins/API/Tests/AWSAPIPluginTests/Support/Utils/RESTRequestUtilsTests.swift +++ b/AmplifyPlugins/API/Tests/AWSAPIPluginTests/Support/Utils/RESTRequestUtilsTests.swift @@ -81,8 +81,9 @@ class RESTRequestUtilsTests: XCTestCase { func testConstructURLRequestFailsWithInvalidQueryParams() throws { let baseURL = URL(string: "https://aws.amazon.com")! + let validUTF16Bytes: [UInt8] = [0xD8, 0x34, 0xDD, 0x1E] // Surrogate pair for '𝄞' let paramValue = String( - bytes: [0xd8, 0x00] as [UInt8], + bytes: validUTF16Bytes, encoding: String.Encoding.utf16BigEndian )! let invalidQueryParams: [String: String] = ["param": paramValue]