From 2875063b974106371db63cf3561c538584820282 Mon Sep 17 00:00:00 2001 From: tom doron Date: Wed, 20 May 2020 19:54:40 -0700 Subject: [PATCH 1/3] improve debugging example motivation: clearer examples as we prepare to open source changes: * rename debugging example to make the name more accurate * add more information in the local debugging example * add a Shared module to show how to share code between client and server * make example more useful - use JSON for registration like flow * add docker-compose task to test examples --- Examples/EndToEndDebugging/README.md | 8 ----- .../contents.xcworkspacedata | 3 ++ .../xcshareddata/IDEWorkspaceChecks.plist | 0 .../xcshareddata/WorkspaceSettings.xcsettings | 0 .../MyApp/MyApp.xcodeproj/project.pbxproj | 22 +++++++++++- .../xcshareddata/xcschemes/MyApp.xcscheme | 0 .../MyApp/MyApp/AppDelegate.swift | 0 .../AppIcon.appiconset/Contents.json | 0 .../MyApp/MyApp/Assets.xcassets/Contents.json | 0 .../MyApp/Base.lproj/LaunchScreen.storyboard | 0 .../MyApp/MyApp/ContentView.swift | 24 ++++++++----- .../MyApp/MyApp/Info.plist | 0 .../Preview Assets.xcassets/Contents.json | 0 .../MyApp/MyApp/SceneDelegate.swift | 0 .../MyLambda/.dockerignore | 0 .../MyLambda/Dockerfile | 0 .../MyLambda/Package.swift | 2 ++ .../MyLambda/Sources/MyLambda/main.swift | 6 ++-- .../MyLambda/Tests/LinuxMain.swift | 0 .../MyLambda/scripts/deploy.sh | 0 .../MyLambda/scripts/package.sh | 0 Examples/LocalDebugging/README.md | 28 +++++++++++++++ Examples/LocalDebugging/Shared/Package.swift | 16 +++++++++ .../Shared/Sources/Shared/Shared.swift | 35 +++++++++++++++++++ .../Shared/Tests/LinuxMain.swift | 15 ++++++++ docker/docker-compose.1804.52.yaml | 3 ++ docker/docker-compose.1804.53.yaml | 3 ++ docker/docker-compose.yaml | 7 ++++ 28 files changed, 152 insertions(+), 20 deletions(-) delete mode 100644 Examples/EndToEndDebugging/README.md rename Examples/{EndToEndDebugging/EndToEndExample.xcworkspace => LocalDebugging/Example.xcworkspace}/contents.xcworkspacedata (82%) rename Examples/{EndToEndDebugging/EndToEndExample.xcworkspace => LocalDebugging/Example.xcworkspace}/xcshareddata/IDEWorkspaceChecks.plist (100%) rename Examples/{EndToEndDebugging/EndToEndExample.xcworkspace => LocalDebugging/Example.xcworkspace}/xcshareddata/WorkspaceSettings.xcsettings (100%) rename Examples/{EndToEndDebugging => LocalDebugging}/MyApp/MyApp.xcodeproj/project.pbxproj (94%) rename Examples/{EndToEndDebugging => LocalDebugging}/MyApp/MyApp.xcodeproj/xcshareddata/xcschemes/MyApp.xcscheme (100%) rename Examples/{EndToEndDebugging => LocalDebugging}/MyApp/MyApp/AppDelegate.swift (100%) rename Examples/{EndToEndDebugging => LocalDebugging}/MyApp/MyApp/Assets.xcassets/AppIcon.appiconset/Contents.json (100%) rename Examples/{EndToEndDebugging => LocalDebugging}/MyApp/MyApp/Assets.xcassets/Contents.json (100%) rename Examples/{EndToEndDebugging => LocalDebugging}/MyApp/MyApp/Base.lproj/LaunchScreen.storyboard (100%) rename Examples/{EndToEndDebugging => LocalDebugging}/MyApp/MyApp/ContentView.swift (78%) rename Examples/{EndToEndDebugging => LocalDebugging}/MyApp/MyApp/Info.plist (100%) rename Examples/{EndToEndDebugging => LocalDebugging}/MyApp/MyApp/Preview Content/Preview Assets.xcassets/Contents.json (100%) rename Examples/{EndToEndDebugging => LocalDebugging}/MyApp/MyApp/SceneDelegate.swift (100%) rename Examples/{EndToEndDebugging => LocalDebugging}/MyLambda/.dockerignore (100%) rename Examples/{EndToEndDebugging => LocalDebugging}/MyLambda/Dockerfile (100%) rename Examples/{EndToEndDebugging => LocalDebugging}/MyLambda/Package.swift (86%) rename Examples/{EndToEndDebugging => LocalDebugging}/MyLambda/Sources/MyLambda/main.swift (71%) rename Examples/{EndToEndDebugging => LocalDebugging}/MyLambda/Tests/LinuxMain.swift (100%) rename Examples/{EndToEndDebugging => LocalDebugging}/MyLambda/scripts/deploy.sh (100%) rename Examples/{EndToEndDebugging => LocalDebugging}/MyLambda/scripts/package.sh (100%) create mode 100644 Examples/LocalDebugging/README.md create mode 100644 Examples/LocalDebugging/Shared/Package.swift create mode 100644 Examples/LocalDebugging/Shared/Sources/Shared/Shared.swift create mode 100644 Examples/LocalDebugging/Shared/Tests/LinuxMain.swift diff --git a/Examples/EndToEndDebugging/README.md b/Examples/EndToEndDebugging/README.md deleted file mode 100644 index 676125a3..00000000 --- a/Examples/EndToEndDebugging/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# End-To-End Debugging - -This sample project demonstrates how to write a simple Lambda function in Swift, -and how to use local debugging techniques that emulate how the Lambda function -would be invoked by the AWS Lambda Runtime engine. - -The sample also includes a simple iOS application that calls the Lambda function -through the emulator, providing an end-to-end debugging experience. diff --git a/Examples/EndToEndDebugging/EndToEndExample.xcworkspace/contents.xcworkspacedata b/Examples/LocalDebugging/Example.xcworkspace/contents.xcworkspacedata similarity index 82% rename from Examples/EndToEndDebugging/EndToEndExample.xcworkspace/contents.xcworkspacedata rename to Examples/LocalDebugging/Example.xcworkspace/contents.xcworkspacedata index 92112301..e42d285c 100644 --- a/Examples/EndToEndDebugging/EndToEndExample.xcworkspace/contents.xcworkspacedata +++ b/Examples/LocalDebugging/Example.xcworkspace/contents.xcworkspacedata @@ -1,6 +1,9 @@ + + diff --git a/Examples/EndToEndDebugging/EndToEndExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Examples/LocalDebugging/Example.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist similarity index 100% rename from Examples/EndToEndDebugging/EndToEndExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist rename to Examples/LocalDebugging/Example.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/Examples/EndToEndDebugging/EndToEndExample.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/Examples/LocalDebugging/Example.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings similarity index 100% rename from Examples/EndToEndDebugging/EndToEndExample.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings rename to Examples/LocalDebugging/Example.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings diff --git a/Examples/EndToEndDebugging/MyApp/MyApp.xcodeproj/project.pbxproj b/Examples/LocalDebugging/MyApp/MyApp.xcodeproj/project.pbxproj similarity index 94% rename from Examples/EndToEndDebugging/MyApp/MyApp.xcodeproj/project.pbxproj rename to Examples/LocalDebugging/MyApp/MyApp.xcodeproj/project.pbxproj index e8de1fb5..fcf97682 100644 --- a/Examples/EndToEndDebugging/MyApp/MyApp.xcodeproj/project.pbxproj +++ b/Examples/LocalDebugging/MyApp/MyApp.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 52; objects = { /* Begin PBXBuildFile section */ @@ -13,6 +13,7 @@ F7B6C204246121E900607A89 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F7B6C203246121E900607A89 /* Assets.xcassets */; }; F7B6C207246121E900607A89 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F7B6C206246121E900607A89 /* Preview Assets.xcassets */; }; F7B6C20A246121E900607A89 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F7B6C208246121E900607A89 /* LaunchScreen.storyboard */; }; + F7EA8D6024762E4000B0D09E /* Shared in Frameworks */ = {isa = PBXBuildFile; productRef = F7EA8D5F24762E4000B0D09E /* Shared */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -31,6 +32,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F7EA8D6024762E4000B0D09E /* Shared in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -42,6 +44,7 @@ children = ( F7B6C1FC246121E800607A89 /* MyApp */, F7B6C1FB246121E800607A89 /* Products */, + F7EA8D5E24762E4000B0D09E /* Frameworks */, ); sourceTree = ""; }; @@ -75,6 +78,13 @@ path = "Preview Content"; sourceTree = ""; }; + F7EA8D5E24762E4000B0D09E /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -91,6 +101,9 @@ dependencies = ( ); name = MyApp; + packageProductDependencies = ( + F7EA8D5F24762E4000B0D09E /* Shared */, + ); productName = MyApp; productReference = F7B6C1FA246121E800607A89 /* MyApp.app */; productType = "com.apple.product-type.application"; @@ -340,6 +353,13 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCSwiftPackageProductDependency section */ + F7EA8D5F24762E4000B0D09E /* Shared */ = { + isa = XCSwiftPackageProductDependency; + productName = Shared; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = F7B6C1F2246121E800607A89 /* Project object */; } diff --git a/Examples/EndToEndDebugging/MyApp/MyApp.xcodeproj/xcshareddata/xcschemes/MyApp.xcscheme b/Examples/LocalDebugging/MyApp/MyApp.xcodeproj/xcshareddata/xcschemes/MyApp.xcscheme similarity index 100% rename from Examples/EndToEndDebugging/MyApp/MyApp.xcodeproj/xcshareddata/xcschemes/MyApp.xcscheme rename to Examples/LocalDebugging/MyApp/MyApp.xcodeproj/xcshareddata/xcschemes/MyApp.xcscheme diff --git a/Examples/EndToEndDebugging/MyApp/MyApp/AppDelegate.swift b/Examples/LocalDebugging/MyApp/MyApp/AppDelegate.swift similarity index 100% rename from Examples/EndToEndDebugging/MyApp/MyApp/AppDelegate.swift rename to Examples/LocalDebugging/MyApp/MyApp/AppDelegate.swift diff --git a/Examples/EndToEndDebugging/MyApp/MyApp/Assets.xcassets/AppIcon.appiconset/Contents.json b/Examples/LocalDebugging/MyApp/MyApp/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from Examples/EndToEndDebugging/MyApp/MyApp/Assets.xcassets/AppIcon.appiconset/Contents.json rename to Examples/LocalDebugging/MyApp/MyApp/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/Examples/EndToEndDebugging/MyApp/MyApp/Assets.xcassets/Contents.json b/Examples/LocalDebugging/MyApp/MyApp/Assets.xcassets/Contents.json similarity index 100% rename from Examples/EndToEndDebugging/MyApp/MyApp/Assets.xcassets/Contents.json rename to Examples/LocalDebugging/MyApp/MyApp/Assets.xcassets/Contents.json diff --git a/Examples/EndToEndDebugging/MyApp/MyApp/Base.lproj/LaunchScreen.storyboard b/Examples/LocalDebugging/MyApp/MyApp/Base.lproj/LaunchScreen.storyboard similarity index 100% rename from Examples/EndToEndDebugging/MyApp/MyApp/Base.lproj/LaunchScreen.storyboard rename to Examples/LocalDebugging/MyApp/MyApp/Base.lproj/LaunchScreen.storyboard diff --git a/Examples/EndToEndDebugging/MyApp/MyApp/ContentView.swift b/Examples/LocalDebugging/MyApp/MyApp/ContentView.swift similarity index 78% rename from Examples/EndToEndDebugging/MyApp/MyApp/ContentView.swift rename to Examples/LocalDebugging/MyApp/MyApp/ContentView.swift index c73d13ef..c31072c9 100644 --- a/Examples/EndToEndDebugging/MyApp/MyApp/ContentView.swift +++ b/Examples/LocalDebugging/MyApp/MyApp/ContentView.swift @@ -12,19 +12,22 @@ // //===----------------------------------------------------------------------===// +import Shared import SwiftUI struct ContentView: View { - @State var name: String = "World" + @State var name: String = "" + @State var password: String = "" @State var response: String = "" var body: some View { VStack(alignment: .leading, spacing: 20) { - TextField("Enter your name", text: $name) + TextField("Username", text: $name) + SecureField("Password", text: $password) Button( - action: self.sayHello, + action: self.register, label: { - Text("say hello") + Text("Register") .padding() .foregroundColor(.white) .background(Color.black) @@ -32,18 +35,20 @@ struct ContentView: View { } ) Text(response) - .foregroundColor(response.starts(with: "CommunicationError") ? .red : .black) }.padding(100) } - func sayHello() { + func register() { guard let url = URL(string: "http://localhost:7000/invoke") else { fatalError("invalid url") } - var request = URLRequest(url: url) request.httpMethod = "POST" - request.httpBody = self.name.data(using: .utf8) + + guard let jsonRequest = try? JSONEncoder().encode(Request(name: self.name, password: self.password)) else { + fatalError("encoding error") + } + request.httpBody = jsonRequest let task = URLSession.shared.dataTask(with: request as URLRequest) { data, response, error in do { @@ -59,7 +64,8 @@ struct ContentView: View { guard let data = data else { throw CommunicationError(reason: "invald response, empty body") } - self.response = String(data: data, encoding: .utf8)! + let response = try JSONDecoder().decode(Response.self, from: data) + self.response = response.message } catch { self.response = "\(error)" } diff --git a/Examples/EndToEndDebugging/MyApp/MyApp/Info.plist b/Examples/LocalDebugging/MyApp/MyApp/Info.plist similarity index 100% rename from Examples/EndToEndDebugging/MyApp/MyApp/Info.plist rename to Examples/LocalDebugging/MyApp/MyApp/Info.plist diff --git a/Examples/EndToEndDebugging/MyApp/MyApp/Preview Content/Preview Assets.xcassets/Contents.json b/Examples/LocalDebugging/MyApp/MyApp/Preview Content/Preview Assets.xcassets/Contents.json similarity index 100% rename from Examples/EndToEndDebugging/MyApp/MyApp/Preview Content/Preview Assets.xcassets/Contents.json rename to Examples/LocalDebugging/MyApp/MyApp/Preview Content/Preview Assets.xcassets/Contents.json diff --git a/Examples/EndToEndDebugging/MyApp/MyApp/SceneDelegate.swift b/Examples/LocalDebugging/MyApp/MyApp/SceneDelegate.swift similarity index 100% rename from Examples/EndToEndDebugging/MyApp/MyApp/SceneDelegate.swift rename to Examples/LocalDebugging/MyApp/MyApp/SceneDelegate.swift diff --git a/Examples/EndToEndDebugging/MyLambda/.dockerignore b/Examples/LocalDebugging/MyLambda/.dockerignore similarity index 100% rename from Examples/EndToEndDebugging/MyLambda/.dockerignore rename to Examples/LocalDebugging/MyLambda/.dockerignore diff --git a/Examples/EndToEndDebugging/MyLambda/Dockerfile b/Examples/LocalDebugging/MyLambda/Dockerfile similarity index 100% rename from Examples/EndToEndDebugging/MyLambda/Dockerfile rename to Examples/LocalDebugging/MyLambda/Dockerfile diff --git a/Examples/EndToEndDebugging/MyLambda/Package.swift b/Examples/LocalDebugging/MyLambda/Package.swift similarity index 86% rename from Examples/EndToEndDebugging/MyLambda/Package.swift rename to Examples/LocalDebugging/MyLambda/Package.swift index c35f2a3c..101557ac 100644 --- a/Examples/EndToEndDebugging/MyLambda/Package.swift +++ b/Examples/LocalDebugging/MyLambda/Package.swift @@ -15,11 +15,13 @@ let package = Package( // in real-world projects this would say // .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0") .package(name: "swift-aws-lambda-runtime", path: "../../.."), + .package(name: "Shared", path: "../shared"), ], targets: [ .target( name: "MyLambda", dependencies: [ .product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime"), + .product(name: "Shared", package: "Shared"), ] ), ] diff --git a/Examples/EndToEndDebugging/MyLambda/Sources/MyLambda/main.swift b/Examples/LocalDebugging/MyLambda/Sources/MyLambda/main.swift similarity index 71% rename from Examples/EndToEndDebugging/MyLambda/Sources/MyLambda/main.swift rename to Examples/LocalDebugging/MyLambda/Sources/MyLambda/main.swift index 45bd8d83..801a9483 100644 --- a/Examples/EndToEndDebugging/MyLambda/Sources/MyLambda/main.swift +++ b/Examples/LocalDebugging/MyLambda/Sources/MyLambda/main.swift @@ -13,9 +13,11 @@ //===----------------------------------------------------------------------===// import AWSLambdaRuntime +import Shared try Lambda.withLocalServer { - Lambda.run { (_: Lambda.Context, payload: String, callback: @escaping (Result) -> Void) in - callback(.success("Hello, \(payload)!")) + Lambda.run { (_: Lambda.Context, request: Request, callback: @escaping (Result) -> Void) in + // TODO: something useful + callback(.success(Response(message: "Hello, \(request.name)!"))) } } diff --git a/Examples/EndToEndDebugging/MyLambda/Tests/LinuxMain.swift b/Examples/LocalDebugging/MyLambda/Tests/LinuxMain.swift similarity index 100% rename from Examples/EndToEndDebugging/MyLambda/Tests/LinuxMain.swift rename to Examples/LocalDebugging/MyLambda/Tests/LinuxMain.swift diff --git a/Examples/EndToEndDebugging/MyLambda/scripts/deploy.sh b/Examples/LocalDebugging/MyLambda/scripts/deploy.sh similarity index 100% rename from Examples/EndToEndDebugging/MyLambda/scripts/deploy.sh rename to Examples/LocalDebugging/MyLambda/scripts/deploy.sh diff --git a/Examples/EndToEndDebugging/MyLambda/scripts/package.sh b/Examples/LocalDebugging/MyLambda/scripts/package.sh similarity index 100% rename from Examples/EndToEndDebugging/MyLambda/scripts/package.sh rename to Examples/LocalDebugging/MyLambda/scripts/package.sh diff --git a/Examples/LocalDebugging/README.md b/Examples/LocalDebugging/README.md new file mode 100644 index 00000000..cc253308 --- /dev/null +++ b/Examples/LocalDebugging/README.md @@ -0,0 +1,28 @@ +# Local Debugging Example + +This sample project demonstrates how to write a simple Lambda function in Swift, +and how to use local debugging techniques that emulate how the Lambda function +would be invoked by the AWS Lambda Runtime engine. + +The example includes three modules: + +1. [MyApp](MyApp) is a SwiftUI iOS application that calls the Lambda function. +2. [MyLambda](MyLambda) is a SwiftPM executable package for the Lambda function. +3. [Shared](Shared) is a SwiftPM library package used for shared code between the iOS application and the Lambda function, +such as the Request and Response model objects. + +The local debugging experience is achieved by running the Lambda function in the context of the debug only `Lambda.withLocalServer` +function which starts a local emulator enabling the communication +between the iOS application and the Lambda function over HTTP. + +To try out this example, open the workspace in Xcode and "run" the two targets, +using the relevant `MyLambda` and `MyApp` Xcode schemas. + +Start with running the `MyLambda` target on the "My Mac" destination, once up you should see a log message in Xcode console saying +`LocalLambdaServer started and listening on 127.0.0.1:7000, receiving payloads on /invoke` +which means the local emulator is up and receiving traffic on port 7000 and expecting payloads on the `/invoke` endpoint. + +Continue to run the `MyApp` target in a simulator destination. Once up, the application's UI should appear in the simulator allowing you +to interact with it. + +Once both targets are running, set up breakpoints in the iOS application or Lambda function to observe the system behavior. diff --git a/Examples/LocalDebugging/Shared/Package.swift b/Examples/LocalDebugging/Shared/Package.swift new file mode 100644 index 00000000..3ab44d3f --- /dev/null +++ b/Examples/LocalDebugging/Shared/Package.swift @@ -0,0 +1,16 @@ +// swift-tools-version:5.2 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "Shared", + products: [ + .library(name: "Shared", targets: ["Shared"]), + ], + dependencies: [ + ], + targets: [ + .target(name: "Shared", dependencies: []), + ] +) diff --git a/Examples/LocalDebugging/Shared/Sources/Shared/Shared.swift b/Examples/LocalDebugging/Shared/Sources/Shared/Shared.swift new file mode 100644 index 00000000..8189eac3 --- /dev/null +++ b/Examples/LocalDebugging/Shared/Sources/Shared/Shared.swift @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the SwiftAWSLambdaRuntime open source project +// +// Copyright (c) 2020 Apple Inc. and the SwiftAWSLambdaRuntime project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + +public struct Request: Codable, CustomStringConvertible { + public let name: String + public let password: String + + public init(name: String, password: String) { + self.name = name + self.password = password + } + + public var description: String { + "name: \(self.name), password: ***" + } +} + +public struct Response: Codable { + public let message: String + + public init(message: String) { + self.message = message + } +} diff --git a/Examples/LocalDebugging/Shared/Tests/LinuxMain.swift b/Examples/LocalDebugging/Shared/Tests/LinuxMain.swift new file mode 100644 index 00000000..c46de763 --- /dev/null +++ b/Examples/LocalDebugging/Shared/Tests/LinuxMain.swift @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the SwiftAWSLambdaRuntime open source project +// +// Copyright (c) 2020 Apple Inc. and the SwiftAWSLambdaRuntime project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + +preconditionFailure("use `swift test --enable-test-discovery`") diff --git a/docker/docker-compose.1804.52.yaml b/docker/docker-compose.1804.52.yaml index af7b0a87..9d47f8a8 100644 --- a/docker/docker-compose.1804.52.yaml +++ b/docker/docker-compose.1804.52.yaml @@ -12,5 +12,8 @@ services: test: image: swift-aws-lambda:18.04-5.2 + test-samples: + image: swift-aws-lambda:18.04-5.2 + shell: image: swift-aws-lambda:18.04-5.2 diff --git a/docker/docker-compose.1804.53.yaml b/docker/docker-compose.1804.53.yaml index 1121f2d2..2e9c35b3 100644 --- a/docker/docker-compose.1804.53.yaml +++ b/docker/docker-compose.1804.53.yaml @@ -11,5 +11,8 @@ services: test: image: swift-aws-lambda:18.04-5.3 + test-samples: + image: swift-aws-lambda:18.04-5.3 + shell: image: swift-aws-lambda:18.04-5.3 diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index b6cd4116..638bcf51 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -30,6 +30,13 @@ services: <<: *common command: /bin/bash -cl "swift test --enable-test-discovery -Xswiftc -warnings-as-errors $${SANITIZER_ARG-}" + test-samples: + <<: *common + command: >- + /bin/bash -cl " + swift build --package-path Examples/LambdaFunctions && + swift build --package-path Examples/LocalDebugging/MyLambda" + # util shell: From 5d0f126941a8b6fb162c7e0c46079a9f67f2a06e Mon Sep 17 00:00:00 2001 From: tomer doron Date: Wed, 20 May 2020 21:13:17 -0700 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Yim Lee --- Examples/LocalDebugging/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/LocalDebugging/README.md b/Examples/LocalDebugging/README.md index cc253308..a4a66ce1 100644 --- a/Examples/LocalDebugging/README.md +++ b/Examples/LocalDebugging/README.md @@ -18,9 +18,9 @@ between the iOS application and the Lambda function over HTTP. To try out this example, open the workspace in Xcode and "run" the two targets, using the relevant `MyLambda` and `MyApp` Xcode schemas. -Start with running the `MyLambda` target on the "My Mac" destination, once up you should see a log message in Xcode console saying +Start with running the `MyLambda` target on the "My Mac" destination, once it is up you should see a log message in the Xcode console saying `LocalLambdaServer started and listening on 127.0.0.1:7000, receiving payloads on /invoke` -which means the local emulator is up and receiving traffic on port 7000 and expecting payloads on the `/invoke` endpoint. +which means the local emulator is up and receiving traffic on port `7000` and expecting payloads on the `/invoke` endpoint. Continue to run the `MyApp` target in a simulator destination. Once up, the application's UI should appear in the simulator allowing you to interact with it. From c410f5ddd355ee98043fc7602073c98c8c1f2b68 Mon Sep 17 00:00:00 2001 From: tom doron Date: Wed, 20 May 2020 21:34:15 -0700 Subject: [PATCH 3/3] fxup --- Examples/LocalDebugging/MyLambda/Package.swift | 2 +- docker/docker-compose.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/LocalDebugging/MyLambda/Package.swift b/Examples/LocalDebugging/MyLambda/Package.swift index 101557ac..b7c4e7fe 100644 --- a/Examples/LocalDebugging/MyLambda/Package.swift +++ b/Examples/LocalDebugging/MyLambda/Package.swift @@ -15,7 +15,7 @@ let package = Package( // in real-world projects this would say // .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0") .package(name: "swift-aws-lambda-runtime", path: "../../.."), - .package(name: "Shared", path: "../shared"), + .package(name: "Shared", path: "../Shared"), ], targets: [ .target( diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 638bcf51..f3996271 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -33,7 +33,7 @@ services: test-samples: <<: *common command: >- - /bin/bash -cl " + /bin/bash -clx " swift build --package-path Examples/LambdaFunctions && swift build --package-path Examples/LocalDebugging/MyLambda"