Skip to content
This repository was archived by the owner on Jul 14, 2020. It is now read-only.

Commit 7b542c1

Browse files
committed
Initial drop
0 parents  commit 7b542c1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+3040
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- master
9+
10+
jobs:
11+
"Integration-Tests":
12+
runs-on: ubuntu-18.04
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v1
16+
with:
17+
fetch-depth: 1
18+
- name: Install ruby
19+
uses: actions/setup-ruby@v1
20+
- name: Install aws-sam-cli
21+
run: sudo pip install aws-sam-cli
22+
- name: Build Docker Swift Dev Image
23+
run: docker build -t swift-dev:5.1.2 .
24+
- name: Build local layer
25+
run: cd Layer && make create_layer
26+
- name: test local lambda
27+
run: make test_lambda
28+
env:
29+
EXAMPLE_LAMBDA: SquareNumber
30+
31+
"tuxOS-Tests":
32+
runs-on: ubuntu-latest
33+
strategy:
34+
matrix:
35+
tag: ['5.1']
36+
container:
37+
image: swift:${{ matrix.tag }}
38+
volumes:
39+
- $GITHUB_WORKSPACE:/src
40+
options: --workdir /src
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@v1
44+
with:
45+
fetch-depth: 1
46+
- name: Install dependencies
47+
run: apt-get update && apt-get install -y zlib1g-dev zip openssl libssl-dev
48+
- name: Test
49+
run: swift test --enable-code-coverage --enable-test-discovery
50+
- name: Convert coverage files
51+
run: llvm-cov export -format="lcov" .build/debug/swift-aws-lambdaPackageTests.xctest -instr-profile .build/debug/codecov/default.profdata > info.lcov
52+
- name: Upload to codecov.io
53+
uses: codecov/codecov-action@v1.0.3
54+
with:
55+
token: ${{secrets.CODECOV_TOKEN}}
56+
57+
"macOS-Tests":
58+
runs-on: macOS-latest
59+
steps:
60+
- name: Checkout
61+
uses: actions/checkout@v1
62+
with:
63+
fetch-depth: 1
64+
- name: Show all Xcode versions
65+
run: ls -an /Applications/ | grep Xcode*
66+
- name: Change Xcode command line tools
67+
run: sudo xcode-select -s /Applications/Xcode_11.2.app/Contents/Developer
68+
- name: SPM Build
69+
run: swift build
70+
- name: SPM Tests
71+
run: swift test --parallel -Xswiftc -DDEBUG
72+
- name: Xcode Tests
73+
run: |
74+
swift package generate-xcodeproj
75+
xcodebuild -quiet -parallel-testing-enabled YES -scheme swift-aws-lambda-Package -enableCodeCoverage YES build test
76+
- name: Codecov
77+
run: bash <(curl -s https://codecov.io/bash) -J 'AWSLambda' -t ${{secrets.CODECOV_TOKEN}}

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
.build
3+
/*.xcodeproj
4+
xcuserdata
5+
Layer/swift-lambda-runtime
6+
Layer/swift-lambda-runtime.zip
7+
Examples/**/lambda.zip

.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1110"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "AWSLambda"
18+
BuildableName = "AWSLambda"
19+
BlueprintName = "AWSLambda"
20+
ReferencedContainer = "container:">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
<BuildActionEntry
24+
buildForTesting = "YES"
25+
buildForRunning = "YES"
26+
buildForProfiling = "NO"
27+
buildForArchiving = "NO"
28+
buildForAnalyzing = "YES">
29+
<BuildableReference
30+
BuildableIdentifier = "primary"
31+
BlueprintIdentifier = "AWSLambdaTests"
32+
BuildableName = "AWSLambdaTests"
33+
BlueprintName = "AWSLambdaTests"
34+
ReferencedContainer = "container:">
35+
</BuildableReference>
36+
</BuildActionEntry>
37+
</BuildActionEntries>
38+
</BuildAction>
39+
<TestAction
40+
buildConfiguration = "Debug"
41+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
42+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
43+
shouldUseLaunchSchemeArgsEnv = "YES"
44+
codeCoverageEnabled = "YES">
45+
<Testables>
46+
<TestableReference
47+
skipped = "NO">
48+
<BuildableReference
49+
BuildableIdentifier = "primary"
50+
BlueprintIdentifier = "AWSLambdaTests"
51+
BuildableName = "AWSLambdaTests"
52+
BlueprintName = "AWSLambdaTests"
53+
ReferencedContainer = "container:">
54+
</BuildableReference>
55+
</TestableReference>
56+
</Testables>
57+
</TestAction>
58+
<LaunchAction
59+
buildConfiguration = "Debug"
60+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
61+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
62+
launchStyle = "0"
63+
useCustomWorkingDirectory = "NO"
64+
ignoresPersistentStateOnLaunch = "NO"
65+
debugDocumentVersioning = "YES"
66+
debugServiceExtension = "internal"
67+
allowLocationSimulation = "YES">
68+
</LaunchAction>
69+
<ProfileAction
70+
buildConfiguration = "Release"
71+
shouldUseLaunchSchemeArgsEnv = "YES"
72+
savedToolIdentifier = ""
73+
useCustomWorkingDirectory = "NO"
74+
debugDocumentVersioning = "YES">
75+
<MacroExpansion>
76+
<BuildableReference
77+
BuildableIdentifier = "primary"
78+
BlueprintIdentifier = "AWSLambda"
79+
BuildableName = "AWSLambda"
80+
BlueprintName = "AWSLambda"
81+
ReferencedContainer = "container:">
82+
</BuildableReference>
83+
</MacroExpansion>
84+
</ProfileAction>
85+
<AnalyzeAction
86+
buildConfiguration = "Debug">
87+
</AnalyzeAction>
88+
<ArchiveAction
89+
buildConfiguration = "Release"
90+
revealArchiveInOrganizer = "YES">
91+
</ArchiveAction>
92+
</Scheme>

Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# This Dockerfile is used to compile our examples, by just adding some dev
2+
# dependencies.
3+
4+
FROM swift:5.1.2
5+
6+
RUN apt-get update && apt-get install -y zlib1g-dev zip openssl libssl-dev

Docs/Add-Layer-to-Function.png

146 KB
Loading

Docs/Develop.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
3+
build
4+
```bash
5+
$ docker build -t swift-dev:5.1.2 .
6+
```
7+
8+
run docker in interactive mode
9+
```
10+
$ docker run -it --rm -v $(pwd):"/src" --workdir "/src" swift-dev:5.1.2
11+
```

Docs/Function-Create.png

277 KB
Loading

Docs/Invocation-Success.png

276 KB
Loading

Docs/Layer-Copy-Arn.png

137 KB
Loading

Docs/Upload-Lambda-zip.png

177 KB
Loading

Examples/SquareNumber/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/SquareNumber/Package.resolved

Lines changed: 52 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/SquareNumber/Package.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// swift-tools-version:5.1
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "SquareNumber",
8+
dependencies: [
9+
.package(path: "../../"),
10+
],
11+
targets: [
12+
.target(
13+
name: "SquareNumber",
14+
dependencies: ["AWSLambda"]
15+
),
16+
]
17+
)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import AWSLambda
2+
import NIO
3+
4+
struct Input: Codable {
5+
let number: Double
6+
}
7+
8+
struct Output: Codable {
9+
let result: Double
10+
}
11+
12+
func squareNumber(input: Input, context: Context) -> Output {
13+
let squaredNumber = input.number * input.number
14+
return Output(result: squaredNumber)
15+
}
16+
17+
let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
18+
defer {
19+
try! group.syncShutdownGracefully()
20+
}
21+
22+
do {
23+
let runtime = try Runtime.createRuntime(eventLoopGroup: group)
24+
defer { try! runtime.syncShutdown() }
25+
26+
runtime.register(for: "squareNumber", handler: Runtime.codable(squareNumber))
27+
try runtime.start().wait()
28+
}
29+
catch {
30+
print(String(describing: error))
31+
}
32+
33+

Examples/SquareNumber/template.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
AWSTemplateFormatVersion: '2010-09-09'
2+
Transform: AWS::Serverless-2016-10-31
3+
Description: >
4+
sam-app
5+
6+
Sample SAM Template for sam-app
7+
8+
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
9+
Globals:
10+
Function:
11+
Timeout: 3
12+
13+
Resources:
14+
15+
SwiftLayer:
16+
Type: AWS::Serverless::LayerVersion
17+
Properties:
18+
ContentUri: Layer/swift-lambda-runtime/
19+
# ContentUri:
20+
# Bucket: de.fabianfett.denkan.app.sam
21+
# Key: swift-lambda-runtime.zip
22+
23+
SquareNumberFunction:
24+
Type: AWS::Serverless::Function
25+
Properties:
26+
CodeUri: Examples/SquareNumber/lambda.zip
27+
Handler: "SquareNumber.squareNumber"
28+
Runtime: provided
29+
Layers:
30+
- !Ref SwiftLayer
31+
Events:
32+
HelloWorld:
33+
Type: Api
34+
Properties:
35+
Path: /hello
36+
Method: get
37+

Examples/TodoAPIGateway/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)