Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
test:
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: Install aws sam cli
# run: |
# sudo sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
# brew --version
# sudo brew tap aws/tap
# brew install aws-sam-cli
# sam --version
- name: Build local layer
run: make create_layer
# - name: Build local and package local lambda
# run: make build_lambda
# - name: Run show local files
# run: ls -an ./Examples/SquareNumber/
# - name: Package local lambda
# run: make package_lambda
- name: test local lambda
run: make test_layer

5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/.build
/Packages
/*.xcodeproj
/.swiftpm
lambda.zip
swift-shared-libs
swift-lambda-runtime.zip
swift-lambda-runtime
swift-lambda-runtime.zip
23 changes: 19 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
EXAMPLE_LAMBDA=SquareNumber
EXAMPLE_EXECUTABLE=SquareNumber
EXAMPLE_PROJECT_PATH=Examples/SquareNumber

# EXAMPLE_LAMBDA=SyntaxHighlighter
# EXAMPLE_EXECUTABLE=SyntaxHighlighter
# EXAMPLE_PROJECT_PATH=Examples/SyntaxHighlighter
# EXAMPLE_LAMBDA=RESTCountries
# EXAMPLE_EXECUTABLE=RESTCountries
# EXAMPLE_PROJECT_PATH=Examples/RESTCountries
LAMBDA_ZIP=lambda.zip
SHARED_LIBS_FOLDER=swift-shared-libs
LAYER_FOLDER=swift-lambda-runtime
LAYER_ZIP=swift-lambda-runtime.zip
SWIFT_DOCKER_IMAGE=swift:5.1
SHARED_LIBS_FOLDER=$(LAYER_FOLDER)/swift-shared-libs
SWIFT_DOCKER_IMAGE=swift:5.1.1

# System specific configuration

UNAME_S := $(shell uname -s)

clean_lambda:
rm $(LAMBDA_ZIP) || true
Expand All @@ -34,8 +40,11 @@ clean_layer:
rm $(LAYER_ZIP) || true
rm -r $(SHARED_LIBS_FOLDER) || true

package_layer: clean_layer
create_layer: clean_layer
mkdir -p $(LAYER_FOLDER)
mkdir -p $(SHARED_LIBS_FOLDER)/lib
cp ./bootstrap "$(LAYER_FOLDER)/bootstrap"
chmod 755 "$(LAYER_FOLDER)/bootstrap"
docker run \
--rm \
--volume "$(shell pwd)/:/src" \
Expand Down Expand Up @@ -104,5 +113,11 @@ package_layer: clean_layer
/usr/lib/x86_64-linux-gnu/libstdc++.so.6 \
/usr/lib/x86_64-linux-gnu/libtasn1.so.6 \
/usr/lib/x86_64-linux-gnu/libunistring.so.2 \
/usr/lib/x86_64-linux-gnu/libwind.so.0
/usr/lib/x86_64-linux-gnu/libwind.so.0 \
/usr/lib/x86_64-linux-gnu/libxml2.so.2

test_layer: package_lambda
echo '{"number": 9 }' | sam local invoke --force-image-build -v . "SquareNumberFunction"

package_layer: create_layer
zip -r $(LAYER_ZIP) bootstrap $(SHARED_LIBS_FOLDER)
37 changes: 37 additions & 0 deletions 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: swift-lambda-runtime/
# ContentUri:
# Bucket: de.fabianfett.denkan.app.sam
# Key: swift-lambda-runtime.zip

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