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

Commit

Permalink
Initial drop
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianfett committed Nov 20, 2019
0 parents commit 7b542c1
Show file tree
Hide file tree
Showing 54 changed files with 3,040 additions and 0 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
"Integration-Tests":
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Install ruby
uses: actions/setup-ruby@v1
- name: Install aws-sam-cli
run: sudo pip install aws-sam-cli
- name: Build Docker Swift Dev Image
run: docker build -t swift-dev:5.1.2 .
- name: Build local layer
run: cd Layer && make create_layer
- name: test local lambda
run: make test_lambda
env:
EXAMPLE_LAMBDA: SquareNumber

"tuxOS-Tests":
runs-on: ubuntu-latest
strategy:
matrix:
tag: ['5.1']
container:
image: swift:${{ matrix.tag }}
volumes:
- $GITHUB_WORKSPACE:/src
options: --workdir /src
steps:
- name: Checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Install dependencies
run: apt-get update && apt-get install -y zlib1g-dev zip openssl libssl-dev
- name: Test
run: swift test --enable-code-coverage --enable-test-discovery
- name: Convert coverage files
run: llvm-cov export -format="lcov" .build/debug/swift-aws-lambdaPackageTests.xctest -instr-profile .build/debug/codecov/default.profdata > info.lcov
- name: Upload to codecov.io
uses: codecov/[email protected]
with:
token: ${{secrets.CODECOV_TOKEN}}

"macOS-Tests":
runs-on: macOS-latest
steps:
- name: Checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Show all Xcode versions
run: ls -an /Applications/ | grep Xcode*
- name: Change Xcode command line tools
run: sudo xcode-select -s /Applications/Xcode_11.2.app/Contents/Developer
- name: SPM Build
run: swift build
- name: SPM Tests
run: swift test --parallel -Xswiftc -DDEBUG
- name: Xcode Tests
run: |
swift package generate-xcodeproj
xcodebuild -quiet -parallel-testing-enabled YES -scheme swift-aws-lambda-Package -enableCodeCoverage YES build test
- name: Codecov
run: bash <(curl -s https://codecov.io/bash) -J 'AWSLambda' -t ${{secrets.CODECOV_TOKEN}}
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store
.build
/*.xcodeproj
xcuserdata
Layer/swift-lambda-runtime
Layer/swift-lambda-runtime.zip
Examples/**/lambda.zip
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
92 changes: 92 additions & 0 deletions .swiftpm/xcode/xcshareddata/xcschemes/AWSLambda.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1110"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AWSLambda"
BuildableName = "AWSLambda"
BlueprintName = "AWSLambda"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AWSLambdaTests"
BuildableName = "AWSLambdaTests"
BlueprintName = "AWSLambdaTests"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AWSLambdaTests"
BuildableName = "AWSLambdaTests"
BlueprintName = "AWSLambdaTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AWSLambda"
BuildableName = "AWSLambda"
BlueprintName = "AWSLambda"
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This Dockerfile is used to compile our examples, by just adding some dev
# dependencies.

FROM swift:5.1.2

RUN apt-get update && apt-get install -y zlib1g-dev zip openssl libssl-dev
Binary file added Docs/Add-Layer-to-Function.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions Docs/Develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@


build
```bash
$ docker build -t swift-dev:5.1.2 .
```

run docker in interactive mode
```
$ docker run -it --rm -v $(pwd):"/src" --workdir "/src" swift-dev:5.1.2
```
Binary file added Docs/Function-Create.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Invocation-Success.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Layer-Copy-Arn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Upload-Lambda-zip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions Examples/SquareNumber/Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"object": {
"pins": [
{
"package": "async-http-client",
"repositoryURL": "https://github.com/swift-server/async-http-client.git",
"state": {
"branch": null,
"revision": "51dc885a30ca704b02fa803099b0a9b5b38067b6",
"version": "1.0.0"
}
},
{
"package": "swift-log",
"repositoryURL": "https://github.com/apple/swift-log.git",
"state": {
"branch": null,
"revision": "e8aabbe95db22e064ad42f1a4a9f8982664c70ed",
"version": "1.1.1"
}
},
{
"package": "swift-nio",
"repositoryURL": "https://github.com/apple/swift-nio.git",
"state": {
"branch": null,
"revision": "8066b0f581604e3711979307a4377457e2b0f007",
"version": "2.9.0"
}
},
{
"package": "swift-nio-extras",
"repositoryURL": "https://github.com/apple/swift-nio-extras.git",
"state": {
"branch": null,
"revision": "ed97628fa310c314c4a5cd8038445054b2991f07",
"version": "1.3.1"
}
},
{
"package": "swift-nio-ssl",
"repositoryURL": "https://github.com/apple/swift-nio-ssl.git",
"state": {
"branch": null,
"revision": "e5c1af45ac934ac0a6117b2927a51d845cf4f705",
"version": "2.4.3"
}
}
]
},
"version": 1
}
17 changes: 17 additions & 0 deletions Examples/SquareNumber/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "SquareNumber",
dependencies: [
.package(path: "../../"),
],
targets: [
.target(
name: "SquareNumber",
dependencies: ["AWSLambda"]
),
]
)
33 changes: 33 additions & 0 deletions Examples/SquareNumber/Sources/SquareNumber/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import AWSLambda
import NIO

struct Input: Codable {
let number: Double
}

struct Output: Codable {
let result: Double
}

func squareNumber(input: Input, context: Context) -> Output {
let squaredNumber = input.number * input.number
return Output(result: squaredNumber)
}

let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
defer {
try! group.syncShutdownGracefully()
}

do {
let runtime = try Runtime.createRuntime(eventLoopGroup: group)
defer { try! runtime.syncShutdown() }

runtime.register(for: "squareNumber", handler: Runtime.codable(squareNumber))
try runtime.start().wait()
}
catch {
print(String(describing: error))
}


37 changes: 37 additions & 0 deletions Examples/SquareNumber/template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
sam-app
Sample SAM Template for sam-app
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 3

Resources:

SwiftLayer:
Type: AWS::Serverless::LayerVersion
Properties:
ContentUri: Layer/swift-lambda-runtime/
# ContentUri:
# Bucket: de.fabianfett.denkan.app.sam
# Key: swift-lambda-runtime.zip

SquareNumberFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: Examples/SquareNumber/lambda.zip
Handler: "SquareNumber.squareNumber"
Runtime: provided
Layers:
- !Ref SwiftLayer
Events:
HelloWorld:
Type: Api
Properties:
Path: /hello
Method: get

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7b542c1

Please sign in to comment.