akrabat commented on a change in pull request #2369: document how to add swift dependencies URL: https://github.com/apache/incubator-openwhisk/pull/2369#discussion_r124740505
########## File path: docs/actions.md ########## @@ -636,49 +636,69 @@ When you create an OpenWhisk Swift action with a Swift source file, it has to be To avoid the cold-start delay, you can compile your Swift file into a binary and then upload to OpenWhisk in a zip file. As you need the OpenWhisk scaffolding, the easiest way to create the binary is to build it within the same environment as it will be run in. These are the steps: - Run an interactive Swift action container. -``` -docker run --rm -it -v "$(pwd):/owexec" openwhisk/swift3action bash -``` - This puts you in a bash shell within the Docker container. Execute the following commands within it: - -- Install zip for convenience, to package the binary ``` - apt-get install -y zip + docker run --rm -it -v "$(pwd):/owexec" openwhisk/action-swift-v3.1.1 bash ``` + This puts you in a bash shell within the Docker container. - Copy the source code and prepare to build it ``` cp /owexec/hello.swift /swift3Action/spm-build/main.swift ``` - ``` cat /swift3Action/epilogue.swift >> /swift3Action/spm-build/main.swift ``` - ``` echo '_run_main(mainFunction:main)' >> /swift3Action/spm-build/main.swift ``` + Copy any additional source files to `/swift3Action/spm-build/` -- Build and link +- (Optional) Create Package.swift + If you need to add dependencies create a Package.swift file like the following: + ```swift + import PackageDescription + + let package = Package( + name: "Action", + dependencies: [ + .Package(url: "https://github.com/apple/example-package-deckofplayingcards.git", majorVersion: 3), + .Package(url: "https://github.com/IBM-Swift/CCurl.git", "0.2.3"), + .Package(url: "https://github.com/IBM-Swift/Kitura-net.git", "1.7.10"), + .Package(url: "https://github.com/IBM-Swift/SwiftyJSON.git", "15.0.1"), + .Package(url: "https://github.com/watson-developer-cloud/swift-sdk.git", "0.16.0") + ] + ) + ``` + As you can see this example adds `swift-watson-sdk` and `example-package-deckofplayingcards` dependencies. + Notice that `CCurl`, `Kitura-net` and `SwiftyJSON.git` are the minimum required dependencies to include. Review comment: Technically, I'm pretty sure that CCurl and Kitura-net aren't minimum required dependencies, however, they are default and so it's a good idea to keep them in your `Package.swift` as it would be less confusing. How about rewording to: Notice that `CCurl`, `Kitura-net` and `SwiftyJSON` are provided in the standard Swift action and so you should include them in your own `Package.swift` ? At a minimum, remove the `.git` from `SwiftyJSON.git` as it's not included for `CCurl` or `Kitura-net`. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
