Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit 56a08b7

Browse files
Add local tests with Lambci and Localstack
1 parent d7a4578 commit 56a08b7

File tree

14 files changed

+158
-4
lines changed

14 files changed

+158
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.DS_Store
22
/.build
3+
.tmp
34
/Packages
45
/*.xcodeproj
56
lambda.zip

.travis.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,19 @@ script:
2323
- make package_lambda
2424
- make swift_test
2525
- make swift_test SWIFT_EXECUTABLE=HTTPSRequest SWIFT_PROJECT_PATH=Examples/HTTPSRequest LAMBDA_FUNCTION_NAME=HTTPSRequest LAMBDA_HANDLER=HTTPSRequest.getHttps
26-
- make swift_test SWIFT_EXECUTABLE=S3Test SWIFT_PROJECT_PATH=Examples/S3Test LAMBDA_FUNCTION_NAME=S3Test LAMBDA_HANDLER=S3Test.getObject
26+
- make swift_test SWIFT_EXECUTABLE=S3Test SWIFT_PROJECT_PATH=Examples/S3Test LAMBDA_FUNCTION_NAME=S3Test LAMBDA_HANDLER=S3Test.getObject
27+
- make build_lambda_local
28+
- make start_docker_compose_env
29+
- make invoke_lambda_local
30+
- make stop_docker_compose_env
31+
- make test_lambda_local_output
32+
- make build_lambda_local SWIFT_EXECUTABLE=HTTPSRequest SWIFT_PROJECT_PATH=Examples/HTTPSRequest LAMBDA_FUNCTION_NAME=HTTPSRequest LAMBDA_HANDLER=HTTPSRequest.getHttps
33+
- make start_docker_compose_env SWIFT_EXECUTABLE=HTTPSRequest SWIFT_PROJECT_PATH=Examples/HTTPSRequest LAMBDA_FUNCTION_NAME=HTTPSRequest LAMBDA_HANDLER=HTTPSRequest.getHttps
34+
- make invoke_lambda_local SWIFT_EXECUTABLE=HTTPSRequest SWIFT_PROJECT_PATH=Examples/HTTPSRequest LAMBDA_FUNCTION_NAME=HTTPSRequest LAMBDA_HANDLER=HTTPSRequest.getHttps
35+
- make stop_docker_compose_env SWIFT_EXECUTABLE=HTTPSRequest SWIFT_PROJECT_PATH=Examples/HTTPSRequest LAMBDA_FUNCTION_NAME=HTTPSRequest LAMBDA_HANDLER=HTTPSRequest.getHttps
36+
- make test_lambda_local_output SWIFT_EXECUTABLE=HTTPSRequest SWIFT_PROJECT_PATH=Examples/HTTPSRequest LAMBDA_FUNCTION_NAME=HTTPSRequest LAMBDA_HANDLER=HTTPSRequest.getHttps
37+
- make build_lambda_local SWIFT_EXECUTABLE=S3Test SWIFT_PROJECT_PATH=Examples/S3Test LAMBDA_FUNCTION_NAME=S3Test LAMBDA_HANDLER=S3Test.getObject
38+
- make start_docker_compose_env SWIFT_EXECUTABLE=S3Test SWIFT_PROJECT_PATH=Examples/S3Test LAMBDA_FUNCTION_NAME=S3Test LAMBDA_HANDLER=S3Test.getObject
39+
- make invoke_lambda_local SWIFT_EXECUTABLE=S3Test SWIFT_PROJECT_PATH=Examples/S3Test LAMBDA_FUNCTION_NAME=S3Test LAMBDA_HANDLER=S3Test.getObject
40+
- make stop_docker_compose_env SWIFT_EXECUTABLE=S3Test SWIFT_PROJECT_PATH=Examples/S3Test LAMBDA_FUNCTION_NAME=S3Test LAMBDA_HANDLER=S3Test.getObject
41+
- make test_lambda_local_output SWIFT_EXECUTABLE=S3Test SWIFT_PROJECT_PATH=Examples/S3Test LAMBDA_FUNCTION_NAME=S3Test LAMBDA_HANDLER=S3Test.getObject

Examples/HTTPSRequest/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Note: This must be launched from the root path
2+
SWIFT_PROJECT_PATH=Examples/HTTPSRequest
3+
4+
start_docker_compose_env:
5+
cd $(SWIFT_PROJECT_PATH); docker-compose up -d ; sleep 2
6+
7+
stop_docker_compose_env:
8+
cd $(SWIFT_PROJECT_PATH); docker-compose stop
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: '3'
2+
services:
3+
lambci:
4+
image: "lambci/lambda:provided"
5+
volumes:
6+
- ../../.build/local:/var/task:ro,delegated
7+
- ../../bootstrap:/opt/bootstrap:ro,delegated
8+
- ../../swift-shared-libs:/opt/swift-shared-libs:ro,delegated
9+
environment:
10+
- DOCKER_LAMBDA_STAY_OPEN=1
11+
- AWS_LAMBDA_FUNCTION_TIMEOUT=3
12+
- LAMB_CI_EXEC=1
13+
command:
14+
- HTTPSRequest.getHttps
15+
ports:
16+
- "9001:9001"

Examples/HTTPSRequest/event.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"url": "https://swift.org"
2+
"url": "https://dog.ceo/api/breeds/list/all"
33
}

Examples/HTTPSRequest/outfile.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"url":"https:\/\/dog.ceo\/api\/breeds\/list\/all","content":"{\"message\":{\"affenpinscher\":[],\"african\":[],\"airedale\":[],\"akita\":[],\"appenzeller\":[],\"basenji\":[],\"beagle\":[],\"bluetick\":[],\"borzoi\":[],\"bouvier\":[],\"boxer\":[],\"brabancon\":[],\"briard\":[],\"buhund\":[\"norwegian\"],\"bulldog\":[\"boston\",\"english\",\"french\"],\"bullterrier\":[\"staffordshire\"],\"cairn\":[],\"cattledog\":[\"australian\"],\"chihuahua\":[],\"chow\":[],\"clumber\":[],\"cockapoo\":[],\"collie\":[\"border\"],\"coonhound\":[],\"corgi\":[\"cardigan\"],\"cotondetulear\":[],\"dachshund\":[],\"dalmatian\":[],\"dane\":[\"great\"],\"deerhound\":[\"scottish\"],\"dhole\":[],\"dingo\":[],\"doberman\":[],\"elkhound\":[\"norwegian\"],\"entlebucher\":[],\"eskimo\":[],\"frise\":[\"bichon\"],\"germanshepherd\":[],\"greyhound\":[\"italian\"],\"groenendael\":[],\"hound\":[\"afghan\",\"basset\",\"blood\",\"english\",\"ibizan\",\"walker\"],\"husky\":[],\"keeshond\":[],\"kelpie\":[],\"komondor\":[],\"kuvasz\":[],\"labrador\":[],\"leonberg\":[],\"lhasa\":[],\"malamute\":[],\"malinois\":[],\"maltese\":[],\"mastiff\":[\"bull\",\"english\",\"tibetan\"],\"mexicanhairless\":[],\"mix\":[],\"mountain\":[\"bernese\",\"swiss\"],\"newfoundland\":[],\"otterhound\":[],\"papillon\":[],\"pekinese\":[],\"pembroke\":[],\"pinscher\":[\"miniature\"],\"pitbull\":[],\"pointer\":[\"german\",\"germanlonghair\"],\"pomeranian\":[],\"poodle\":[\"miniature\",\"standard\",\"toy\"],\"pug\":[],\"puggle\":[],\"pyrenees\":[],\"redbone\":[],\"retriever\":[\"chesapeake\",\"curly\",\"flatcoated\",\"golden\"],\"ridgeback\":[\"rhodesian\"],\"rottweiler\":[],\"saluki\":[],\"samoyed\":[],\"schipperke\":[],\"schnauzer\":[\"giant\",\"miniature\"],\"setter\":[\"english\",\"gordon\",\"irish\"],\"sheepdog\":[\"english\",\"shetland\"],\"shiba\":[],\"shihtzu\":[],\"spaniel\":[\"blenheim\",\"brittany\",\"cocker\",\"irish\",\"japanese\",\"sussex\",\"welsh\"],\"springer\":[\"english\"],\"stbernard\":[],\"terrier\":[\"american\",\"australian\",\"bedlington\",\"border\",\"dandie\",\"fox\",\"irish\",\"kerryblue\",\"lakeland\",\"norfolk\",\"norwich\",\"patterdale\",\"russell\",\"scottish\",\"sealyham\",\"silky\",\"tibetan\",\"toy\",\"westhighland\",\"wheaten\",\"yorkshire\"],\"vizsla\":[],\"waterdog\":[\"spanish\"],\"weimaraner\":[],\"whippet\":[],\"wolfhound\":[\"irish\"]},\"status\":\"success\"}"}

Examples/HelloWorld/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Note: This must be launched from the root path
2+
SWIFT_PROJECT_PATH=Examples/HelloWorld
3+
4+
start_docker_compose_env:
5+
cd $(SWIFT_PROJECT_PATH); docker-compose up -d ; sleep 2
6+
7+
stop_docker_compose_env:
8+
cd $(SWIFT_PROJECT_PATH); docker-compose stop
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: '3'
2+
services:
3+
lambci:
4+
image: "lambci/lambda:provided"
5+
volumes:
6+
- ../../.build/local:/var/task:ro,delegated
7+
- ../../bootstrap:/opt/bootstrap:ro,delegated
8+
- ../../swift-shared-libs:/opt/swift-shared-libs:ro,delegated
9+
environment:
10+
- DOCKER_LAMBDA_STAY_OPEN=1
11+
- AWS_LAMBDA_FUNCTION_TIMEOUT=3
12+
- LAMB_CI_EXEC=1
13+
command:
14+
- HelloWorld.helloWorld
15+
ports:
16+
- "9001:9001"

Examples/HelloWorld/outfile.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"message":"Hello World! Hello Swift-Sprinter!"}

Examples/S3Test/Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Note: This must be launched from the root path
2+
SWIFT_PROJECT_PATH=Examples/S3Test
3+
4+
start_docker_compose_env:
5+
cd $(SWIFT_PROJECT_PATH); docker-compose up -d ; sleep 2
6+
aws --endpoint http://localhost:4572 s3 mb s3://my-s3-bucket
7+
aws --endpoint http://localhost:4572 s3 cp $(SWIFT_PROJECT_PATH)/hello.txt s3://my-s3-bucket/hello.txt
8+
9+
stop_docker_compose_env:
10+
cd $(SWIFT_PROJECT_PATH); docker-compose stop

0 commit comments

Comments
 (0)