From 1b63f324c89c0d980e23c7d7d1d284f2f783c864 Mon Sep 17 00:00:00 2001 From: Michael Law <1365977+lawmicha@users.noreply.github.com> Date: Wed, 10 Aug 2022 16:28:44 -0400 Subject: [PATCH] chore(api): Add github workflow for Functional and GraphQLIAM tests (#2121) * chore(api): Add github workflow for Functional and GraphQLIAM tests * disable graphql IAM tests due to backend mismatch --- .github/workflows/integ_test_api.yml | 84 ++++++++++++++ .gitignore | 1 + .../APIHostApp.xcodeproj/project.pbxproj | 20 +++- .../contents.xcworkspacedata | 7 ++ .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++ .../xcshareddata/swiftpm/Package.resolved | 106 ++++++++++++++++++ .../AWSAPIPluginGraphQLIAMTests.xcscheme | 97 ++++++++++++++++ .../APIHostApp/APIHostApp/APIHostAppApp.swift | 31 +++++ .../Tests/APIHostApp/APIHostApp/Info.plist | 23 ++++ 9 files changed, 373 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/integ_test_api.yml create mode 100644 AmplifyPlugins/API/Tests/APIHostApp/APIHostApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 AmplifyPlugins/API/Tests/APIHostApp/APIHostApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 AmplifyPlugins/API/Tests/APIHostApp/APIHostApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved create mode 100644 AmplifyPlugins/API/Tests/APIHostApp/APIHostApp.xcodeproj/xcshareddata/xcschemes/AWSAPIPluginGraphQLIAMTests.xcscheme create mode 100644 AmplifyPlugins/API/Tests/APIHostApp/APIHostApp/Info.plist diff --git a/.github/workflows/integ_test_api.yml b/.github/workflows/integ_test_api.yml new file mode 100644 index 0000000000..1f89445980 --- /dev/null +++ b/.github/workflows/integ_test_api.yml @@ -0,0 +1,84 @@ +name: API Integration Tests +on: + push: + branches: [dev-preview-api] + +permissions: + id-token: write + contents: read + +concurrency: + group: ${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + prepare-for-test: + runs-on: macos-latest + environment: IntegrationTest + steps: + - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + with: + persist-credentials: false + + - name: Verify copy resources + uses: ./.github/composite_actions/download_test_configuration + with: + resource_subfolder: NA + aws_role_to_assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws_region: ${{ secrets.AWS_REGION }} + aws_s3_bucket: ${{ secrets.AWS_S3_BUCKET_INTEG }} + + api-functional-test: + continue-on-error: true + needs: prepare-for-test + runs-on: macos-latest + 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: api + aws_role_to_assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws_region: ${{ secrets.AWS_REGION }} + aws_s3_bucket: ${{ secrets.AWS_S3_BUCKET_INTEG }} + + - name: Run Integration test + uses: ./.github/composite_actions/run_xcodebuild_test + with: + project_path: ./AmplifyPlugins/API/Tests/APIHostApp + scheme: AWSAPIPluginFunctionalTests + + api-graphql-iam-test: + if: ${{ false }} + continue-on-error: true + needs: prepare-for-test + runs-on: macos-latest + 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: api + aws_role_to_assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws_region: ${{ secrets.AWS_REGION }} + aws_s3_bucket: ${{ secrets.AWS_S3_BUCKET_INTEG }} + + - name: Run Integration test + uses: ./.github/composite_actions/run_xcodebuild_test + with: + project_path: ./AmplifyPlugins/API/Tests/APIHostApp + scheme: AWSAPIPluginGraphQLIAMTests \ No newline at end of file diff --git a/.gitignore b/.gitignore index 19f576ad51..c43d2f9ecc 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ Thumbs.db *.xcworkspace/ !.swiftpm/xcode/package.xcworkspace !AmplifyPlugins/DataStore/Tests/DataStoreHostApp/DataStoreHostApp.xcodeproj/project.xcworkspace +!AmplifyPlugins/API/Tests/APIHostApp/APIHostApp.xcodeproj/project.xcworkspace Amplify.xcodeproj/xcuserdata Amplify.xcworkspace/xcuserdata xcuserdata diff --git a/AmplifyPlugins/API/Tests/APIHostApp/APIHostApp.xcodeproj/project.pbxproj b/AmplifyPlugins/API/Tests/APIHostApp/APIHostApp.xcodeproj/project.pbxproj index 82ebd99157..cddb5636e2 100644 --- a/AmplifyPlugins/API/Tests/APIHostApp/APIHostApp.xcodeproj/project.pbxproj +++ b/AmplifyPlugins/API/Tests/APIHostApp/APIHostApp.xcodeproj/project.pbxproj @@ -186,6 +186,7 @@ 2126272E289ABFEB003788E3 /* Post+Schema.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Post+Schema.swift"; sourceTree = ""; }; 2126272F289ABFEB003788E3 /* NestedTypeTestModel+Schema.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NestedTypeTestModel+Schema.swift"; sourceTree = ""; }; 21262730289ABFEB003788E3 /* Post3.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Post3.swift; sourceTree = ""; }; + 213DBB6028A40DAE00B30280 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; 21698A7B28899804004BD994 /* AWSAPIPluginFunctionalTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AWSAPIPluginFunctionalTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 21698A882889980F004BD994 /* AWSAPIPluginGraphQLAPIKeyIntegrationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AWSAPIPluginGraphQLAPIKeyIntegrationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 21698A9528899818004BD994 /* AWSAPIPluginIntegrationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AWSAPIPluginIntegrationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -492,6 +493,7 @@ 21E73E6D28898D7900D7DB7E /* APIHostApp */ = { isa = PBXGroup; children = ( + 213DBB6028A40DAE00B30280 /* Info.plist */, 21698C072889B173004BD994 /* TestCommonConstants.swift */, 21698C062889B173004BD994 /* TestExtensions.swift */, 21E73E6E28898D7900D7DB7E /* APIHostAppApp.swift */, @@ -916,6 +918,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -940,6 +943,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -963,6 +967,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -987,6 +992,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1010,6 +1016,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1034,6 +1041,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1099,7 +1107,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 15.5; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; @@ -1153,7 +1161,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 15.5; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = iphoneos; @@ -1175,11 +1183,12 @@ DEVELOPMENT_TEAM = ""; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; - INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_FILE = APIHostApp/Info.plist; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1206,11 +1215,12 @@ DEVELOPMENT_TEAM = ""; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; - INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_FILE = APIHostApp/Info.plist; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1232,6 +1242,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = "Amazon-Web-Services.AWSAPIPluginGraphQLIAMTest"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1249,6 +1260,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = "Amazon-Web-Services.AWSAPIPluginGraphQLIAMTest"; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/AmplifyPlugins/API/Tests/APIHostApp/APIHostApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/AmplifyPlugins/API/Tests/APIHostApp/APIHostApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000000..919434a625 --- /dev/null +++ b/AmplifyPlugins/API/Tests/APIHostApp/APIHostApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/AmplifyPlugins/API/Tests/APIHostApp/APIHostApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/AmplifyPlugins/API/Tests/APIHostApp/APIHostApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000..18d981003d --- /dev/null +++ b/AmplifyPlugins/API/Tests/APIHostApp/APIHostApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/AmplifyPlugins/API/Tests/APIHostApp/APIHostApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/AmplifyPlugins/API/Tests/APIHostApp/APIHostApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000000..d24d427b3d --- /dev/null +++ b/AmplifyPlugins/API/Tests/APIHostApp/APIHostApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,106 @@ +{ + "object": { + "pins": [ + { + "package": "AppSyncRealTimeClient", + "repositoryURL": "https://github.com/aws-amplify/aws-appsync-realtime-client-ios.git", + "state": { + "branch": null, + "revision": "da88cf1cab82e281e7277cd9feb9efc87a057041", + "version": "2.1.1" + } + }, + { + "package": "AwsCrt", + "repositoryURL": "https://github.com/awslabs/aws-crt-swift.git", + "state": { + "branch": null, + "revision": "d654b82a55aec736ad8b4354027acab17394a060", + "version": "0.2.2" + } + }, + { + "package": "AWSSwiftSDK", + "repositoryURL": "https://github.com/awslabs/aws-sdk-swift.git", + "state": { + "branch": null, + "revision": "497c2034a00a507806611eec42727fb8ec9b5d69", + "version": "0.2.5" + } + }, + { + "package": "CwlCatchException", + "repositoryURL": "https://github.com/mattgallagher/CwlCatchException.git", + "state": { + "branch": null, + "revision": "35f9e770f54ce62dd8526470f14c6e137cef3eea", + "version": "2.1.1" + } + }, + { + "package": "CwlPreconditionTesting", + "repositoryURL": "https://github.com/mattgallagher/CwlPreconditionTesting.git", + "state": { + "branch": null, + "revision": "c21f7bab5ca8eee0a9998bbd17ca1d0eb45d4688", + "version": "2.1.0" + } + }, + { + "package": "ClientRuntime", + "repositoryURL": "https://github.com/awslabs/smithy-swift.git", + "state": { + "branch": null, + "revision": "46e2e69abc12ad820fcb31834045a1c9e1d053c1", + "version": "0.2.4" + } + }, + { + "package": "SQLite.swift", + "repositoryURL": "https://github.com/stephencelis/SQLite.swift.git", + "state": { + "branch": null, + "revision": "0a9893ec030501a3956bee572d6b4fdd3ae158a1", + "version": "0.12.2" + } + }, + { + "package": "Starscream", + "repositoryURL": "https://github.com/daltoniam/Starscream", + "state": { + "branch": null, + "revision": "df8d82047f6654d8e4b655d1b1525c64e1059d21", + "version": "4.0.4" + } + }, + { + "package": "swift-collections", + "repositoryURL": "https://github.com/apple/swift-collections", + "state": { + "branch": null, + "revision": "48254824bb4248676bf7ce56014ff57b142b77eb", + "version": "1.0.2" + } + }, + { + "package": "swift-log", + "repositoryURL": "https://github.com/apple/swift-log.git", + "state": { + "branch": null, + "revision": "5d66f7ba25daf4f94100e7022febf3c75e37a6c7", + "version": "1.4.2" + } + }, + { + "package": "XMLCoder", + "repositoryURL": "https://github.com/MaxDesiatov/XMLCoder.git", + "state": { + "branch": null, + "revision": "ca932442d7481700f5434a7b138c47dd42d9902b", + "version": "0.14.0" + } + } + ] + }, + "version": 1 +} diff --git a/AmplifyPlugins/API/Tests/APIHostApp/APIHostApp.xcodeproj/xcshareddata/xcschemes/AWSAPIPluginGraphQLIAMTests.xcscheme b/AmplifyPlugins/API/Tests/APIHostApp/APIHostApp.xcodeproj/xcshareddata/xcschemes/AWSAPIPluginGraphQLIAMTests.xcscheme new file mode 100644 index 0000000000..3e5c390a8c --- /dev/null +++ b/AmplifyPlugins/API/Tests/APIHostApp/APIHostApp.xcodeproj/xcshareddata/xcschemes/AWSAPIPluginGraphQLIAMTests.xcscheme @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AmplifyPlugins/API/Tests/APIHostApp/APIHostApp/APIHostAppApp.swift b/AmplifyPlugins/API/Tests/APIHostApp/APIHostApp/APIHostAppApp.swift index 7cf64c86eb..4c8a97ad43 100644 --- a/AmplifyPlugins/API/Tests/APIHostApp/APIHostApp/APIHostAppApp.swift +++ b/AmplifyPlugins/API/Tests/APIHostApp/APIHostApp/APIHostAppApp.swift @@ -7,7 +7,21 @@ import SwiftUI +// Run project on iOS 13; https://stackoverflow.com/questions/62935053/use-main-in-xcode-12 + @main +struct APIHostAppAppWrapper { + static func main() { + if #available(iOS 14.0, *) { + APIHostAppApp.main() + } + else { + UIApplicationMain(CommandLine.argc, CommandLine.unsafeArgv, nil, NSStringFromClass(SceneDelegate.self)) + } + } +} + +@available(iOS 14.0, *) struct APIHostAppApp: App { var body: some Scene { WindowGroup { @@ -15,3 +29,20 @@ struct APIHostAppApp: App { } } } + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + + var window: UIWindow? + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + let contentView = ContentView() + + // Use a UIHostingController as window root view controller. + if let windowScene = scene as? UIWindowScene { + let window = UIWindow(windowScene: windowScene) + window.rootViewController = UIHostingController(rootView: contentView) + self.window = window + window.makeKeyAndVisible() + } + } +} diff --git a/AmplifyPlugins/API/Tests/APIHostApp/APIHostApp/Info.plist b/AmplifyPlugins/API/Tests/APIHostApp/APIHostApp/Info.plist new file mode 100644 index 0000000000..7f7d5c806d --- /dev/null +++ b/AmplifyPlugins/API/Tests/APIHostApp/APIHostApp/Info.plist @@ -0,0 +1,23 @@ + + + + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + + + + + +