Skip to content

Commit f6702de

Browse files
Merge pull request swift-serverless#43 from Andrea-Scuderi/feature/amazonlinux2
Support for amazonlinux2
2 parents c074762 + a70003b commit f6702de

32 files changed

+335
-76
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
lambda.zip
77
swift-shared-libs
88
default.profraw
9+
.swiftpm

.travis.yml

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -24,48 +24,34 @@ addons:
2424
before_install:
2525
- ./scripts/aws_travis_credentials.sh
2626

27+
global:
28+
- DOCKER_OS=amazonlinux2
29+
- SWIFT_VERSION=5.2.4-amazonlinux2
30+
- LAYER_VERSION=5.2.4-amazonlinux2
31+
2732
install:
2833
- make --version
2934
- make docker_build
30-
31-
script:
3235
- docker image ls
3336
- make package_layer
3437
- make package_lambda
35-
- make swift_test
36-
- make swift_test SWIFT_EXECUTABLE=HTTPSRequest SWIFT_PROJECT_PATH=Examples/HTTPSRequest LAMBDA_FUNCTION_NAME=HTTPSRequest LAMBDA_HANDLER=HTTPSRequest.getHttps
37-
- make swift_test SWIFT_EXECUTABLE=S3Test SWIFT_PROJECT_PATH=Examples/S3Test LAMBDA_FUNCTION_NAME=S3Test LAMBDA_HANDLER=S3Test.getObject
38-
- make build_lambda_local SWIFT_EXECUTABLE=HelloWorld SWIFT_PROJECT_PATH=Examples/HelloWorld LAMBDA_FUNCTION_NAME=HelloWorld LAMBDA_HANDLER=HelloWorld.helloWorld
39-
- make start_docker_compose_env SWIFT_EXECUTABLE=HelloWorld SWIFT_PROJECT_PATH=Examples/HelloWorld LAMBDA_FUNCTION_NAME=HelloWorld LAMBDA_HANDLER=HelloWorld.helloWorld
40-
- make invoke_lambda_local SWIFT_EXECUTABLE=HelloWorld SWIFT_PROJECT_PATH=Examples/HelloWorld LAMBDA_FUNCTION_NAME=HelloWorld LAMBDA_HANDLER=HelloWorld.helloWorld
41-
- make stop_docker_compose_env SWIFT_EXECUTABLE=HelloWorld SWIFT_PROJECT_PATH=Examples/HelloWorld LAMBDA_FUNCTION_NAME=HelloWorld LAMBDA_HANDLER=HelloWorld.helloWorld
42-
- make test_lambda_local_output SWIFT_EXECUTABLE=HelloWorld SWIFT_PROJECT_PATH=Examples/HelloWorld LAMBDA_FUNCTION_NAME=HelloWorld LAMBDA_HANDLER=HelloWorld.helloWorld
43-
- make build_lambda_local SWIFT_EXECUTABLE=HTTPSRequest SWIFT_PROJECT_PATH=Examples/HTTPSRequest LAMBDA_FUNCTION_NAME=HTTPSRequest LAMBDA_HANDLER=HTTPSRequest.getHttps
44-
- make start_docker_compose_env SWIFT_EXECUTABLE=HTTPSRequest SWIFT_PROJECT_PATH=Examples/HTTPSRequest LAMBDA_FUNCTION_NAME=HTTPSRequest LAMBDA_HANDLER=HTTPSRequest.getHttps
45-
- make invoke_lambda_local SWIFT_EXECUTABLE=HTTPSRequest SWIFT_PROJECT_PATH=Examples/HTTPSRequest LAMBDA_FUNCTION_NAME=HTTPSRequest LAMBDA_HANDLER=HTTPSRequest.getHttps
46-
- make stop_docker_compose_env SWIFT_EXECUTABLE=HTTPSRequest SWIFT_PROJECT_PATH=Examples/HTTPSRequest LAMBDA_FUNCTION_NAME=HTTPSRequest LAMBDA_HANDLER=HTTPSRequest.getHttps
47-
- make test_lambda_local_output SWIFT_EXECUTABLE=HTTPSRequest SWIFT_PROJECT_PATH=Examples/HTTPSRequest LAMBDA_FUNCTION_NAME=HTTPSRequest LAMBDA_HANDLER=HTTPSRequest.getHttps
48-
- make build_lambda_local SWIFT_EXECUTABLE=S3Test SWIFT_PROJECT_PATH=Examples/S3Test LAMBDA_FUNCTION_NAME=S3Test LAMBDA_HANDLER=S3Test.getObject
49-
- make start_docker_compose_env SWIFT_EXECUTABLE=S3Test SWIFT_PROJECT_PATH=Examples/S3Test LAMBDA_FUNCTION_NAME=S3Test LAMBDA_HANDLER=S3Test.getObject
50-
- make invoke_lambda_local SWIFT_EXECUTABLE=S3Test SWIFT_PROJECT_PATH=Examples/S3Test LAMBDA_FUNCTION_NAME=S3Test LAMBDA_HANDLER=S3Test.getObject
51-
- make stop_docker_compose_env SWIFT_EXECUTABLE=S3Test SWIFT_PROJECT_PATH=Examples/S3Test LAMBDA_FUNCTION_NAME=S3Test LAMBDA_HANDLER=S3Test.getObject
52-
- make test_lambda_local_output SWIFT_EXECUTABLE=S3Test SWIFT_PROJECT_PATH=Examples/S3Test LAMBDA_FUNCTION_NAME=S3Test LAMBDA_HANDLER=S3Test.getObject
53-
- make build_lambda_local SWIFT_EXECUTABLE=RedisDemo SWIFT_PROJECT_PATH=Examples/RedisDemo LAMBDA_FUNCTION_NAME=RedisDemo LAMBDA_HANDLER=$(SWIFT_EXECUTABLE).setGet
54-
- make start_docker_compose_env SWIFT_EXECUTABLE=RedisDemo SWIFT_PROJECT_PATH=Examples/RedisDemo LAMBDA_FUNCTION_NAME=RedisDemo LAMBDA_HANDLER=$(SWIFT_EXECUTABLE).setGet
55-
- make invoke_lambda_local SWIFT_EXECUTABLE=RedisDemo SWIFT_PROJECT_PATH=Examples/RedisDemo LAMBDA_FUNCTION_NAME=RedisDemo LAMBDA_HANDLER=$(SWIFT_EXECUTABLE).setGet
56-
- make stop_docker_compose_env SWIFT_EXECUTABLE=RedisDemo SWIFT_PROJECT_PATH=Examples/RedisDemo LAMBDA_FUNCTION_NAME=RedisDemo LAMBDA_HANDLER=$(SWIFT_EXECUTABLE).setGet
57-
- make test_lambda_local_output SWIFT_EXECUTABLE=RedisDemo SWIFT_PROJECT_PATH=Examples/RedisDemo LAMBDA_FUNCTION_NAME=RedisDemo LAMBDA_HANDLER=$(SWIFT_EXECUTABLE).setGet
58-
- make build_lambda_local SWIFT_EXECUTABLE=PostgreSQLDemo SWIFT_PROJECT_PATH=Examples/PostgreSQLDemo LAMBDA_FUNCTION_NAME=PostgreSQLDemo LAMBDA_HANDLER=$(SWIFT_EXECUTABLE).query
59-
- make start_docker_compose_env SWIFT_EXECUTABLE=PostgreSQLDemo SWIFT_PROJECT_PATH=Examples/PostgreSQLDemo LAMBDA_FUNCTION_NAME=PostgreSQLDemo LAMBDA_HANDLER=$(SWIFT_EXECUTABLE).query
60-
- make invoke_lambda_local SWIFT_EXECUTABLE=PostgreSQLDemo SWIFT_PROJECT_PATH=Examples/PostgreSQLDemo LAMBDA_FUNCTION_NAME=PostgreSQLDemo LAMBDA_HANDLER=$(SWIFT_EXECUTABLE).query
61-
- make stop_docker_compose_env SWIFT_EXECUTABLE=PostgreSQLDemo SWIFT_PROJECT_PATH=Examples/PostgreSQLDemo LAMBDA_FUNCTION_NAME=PostgreSQLDemo LAMBDA_HANDLER=$(SWIFT_EXECUTABLE).query
62-
- make test_lambda_local_output SWIFT_EXECUTABLE=PostgreSQLDemo SWIFT_PROJECT_PATH=Examples/PostgreSQLDemo LAMBDA_FUNCTION_NAME=PostgreSQLDemo LAMBDA_HANDLER=$(SWIFT_EXECUTABLE).query
6338

39+
env:
40+
- SWIFT_EXECUTABLE=HelloWorld SWIFT_PROJECT_PATH=Examples/HelloWorld LAMBDA_FUNCTION_NAME=HelloWorld LAMBDA_HANDLER=HelloWorld.helloWorld
41+
- SWIFT_EXECUTABLE=HTTPSRequest SWIFT_PROJECT_PATH=Examples/HTTPSRequest LAMBDA_FUNCTION_NAME=HTTPSRequest LAMBDA_HANDLER=HTTPSRequest.getHttps
42+
- SWIFT_EXECUTABLE=S3Test SWIFT_PROJECT_PATH=Examples/S3Test LAMBDA_FUNCTION_NAME=S3Test LAMBDA_HANDLER=S3Test.getObject
43+
- SWIFT_EXECUTABLE=RedisDemo SWIFT_PROJECT_PATH=Examples/RedisDemo LAMBDA_FUNCTION_NAME=RedisDemo LAMBDA_HANDLER=$(SWIFT_EXECUTABLE).setGet
44+
- SWIFT_EXECUTABLE=PostgreSQLDemo SWIFT_PROJECT_PATH=Examples/PostgreSQLDemo LAMBDA_FUNCTION_NAME=PostgreSQLDemo LAMBDA_HANDLER=$(SWIFT_EXECUTABLE).query
45+
46+
script:
47+
- make swift_test
48+
- make run_test_example
49+
6450
deploy:
6551
provider: releases
6652
api_key:
6753
secure: Ddgpz/LsTWeTTr8Xm0br+Vs3Is58V2bOHthwLOt5a1TbyhWAgU+tyc6lwvd51mhQxeNNVPSOWLKC4QgJEp2KI2ZCaw0K+Czb8lqMzWF5eJggDmJ0+wOZIHVEWMO7smLTwDc1jWtdnQA3qkPtXgSw0ERcJ9z4/haz1Q8v7Jj5qfoBJiNxnYYvw/79ElqROIjtQ0asX/i6xhZSlBFO1dXo5QPzX7XeNREQmh2dCkjfoeYSFSCah4Tnn5akxX36Pef1DJvWdFvc623pWAUoCpeswIMW/htby5tJQ6+C9PK+2yzqomKfU9gTK9iv7Nt3X1LN3KsXpk6VHgtljiUkEsecXjYB5WVBT00mY/4bnTPyY6RjI/V6C0aGnTE+0Pj78kDofJKj5uNevFi4vlBI2g4s4G0mRASFRp+sk3ASmzl62Lohkl1LfNiPYKRKRA2jT81s79zBnYv/MQ7t3fY+yd7iP+NrJfDFR/XG0vxBOQrNRpq6LR0M7DeHgTD/d9an2WEqJlX9pp+Ji/ywwepW7b/NLv42xeN99SnHbDmJJ/eZ4P1IC37JCOT5CjJ9wIyP8c+Q89JT30nlvON9xPM8MOx/MrVAGCeqC6FW1Zjc6oakTRZdngMqN1acH5OosLX83cOjjXo8ivRt5Sm2tfX3ZuOgL98kdaYsIBPIYbYhZDODdvM=
68-
file: ".build/layer/swift-lambda-runtime-5-1-5.zip"
54+
file: ".build/layer/swift-lambda-runtime-${TRAVIS_TAG}-@{DOCKER_OS}.zip"
6955
skip_cleanup: true
7056
on:
7157
tags: true

Examples/HTTPSRequest/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ services:
44
image: "lambci/lambda:provided"
55
volumes:
66
- ../../.build/local:/var/task:ro,delegated
7-
- ../../bootstrap:/opt/bootstrap:ro,delegated
8-
- ../../swift-shared-libs:/opt/swift-shared-libs:ro,delegated
7+
- ../../swift-shared-libs/bootstrap:/opt/bootstrap:ro,delegated
8+
- ../../swift-shared-libs:/opt/:ro,delegated
99
environment:
1010
- DOCKER_LAMBDA_STAY_OPEN=1
1111
- AWS_LAMBDA_FUNCTION_TIMEOUT=10

Examples/HelloWorld/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ services:
44
image: "lambci/lambda:provided"
55
volumes:
66
- ../../.build/local:/var/task:ro,delegated
7-
- ../../bootstrap:/opt/bootstrap:ro,delegated
8-
- ../../swift-shared-libs:/opt/swift-shared-libs:ro,delegated
7+
- ../../swift-shared-libs/bootstrap:/opt/bootstrap:ro,delegated
8+
- ../../swift-shared-libs:/opt/:ro,delegated
99
environment:
1010
- DOCKER_LAMBDA_STAY_OPEN=1
1111
- AWS_LAMBDA_FUNCTION_TIMEOUT=10

Examples/PostgreSQLDemo/Package.resolved

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

Examples/PostgreSQLDemo/Tests/PostgreSQLDemoTests/PostgreSQLDemoTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ final class PostgreSQLDemoTests: XCTestCase {
2525

2626
let data = pipe.fileHandleForReading.readDataToEndOfFile()
2727
let output = String(data: data, encoding: .utf8)
28+
let isError = output?.contains("unknown(host: \"postgres\", port: 5432)\n")
2829

29-
XCTAssertEqual(output, "Hello, world!\n")
30+
XCTAssertEqual(isError, true)
3031
}
3132

3233
/// Returns path to the built products directory.

Examples/PostgreSQLDemo/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ services:
44
image: "lambci/lambda:provided"
55
volumes:
66
- ../../.build/local:/var/task:ro,delegated
7-
- ../../bootstrap:/opt/bootstrap:ro,delegated
8-
- ../../swift-shared-libs:/opt/swift-shared-libs:ro,delegated
7+
- ../../swift-shared-libs/bootstrap:/opt/bootstrap:ro,delegated
8+
- ../../swift-shared-libs:/opt/:ro,delegated
99
environment:
1010
- DOCKER_LAMBDA_STAY_OPEN=1
1111
- AWS_LAMBDA_FUNCTION_TIMEOUT=10

Examples/RedisDemo/Tests/RedisDemoTests/RedisDemoTests.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ final class RedisDemoTests: XCTestCase {
1212
return
1313
}
1414

15-
let fooBinary = productsDirectory.appendingPathComponent("aws-lambda-swift-sprinter-redis")
15+
let fooBinary = productsDirectory.appendingPathComponent("RedisDemo")
1616

1717
let process = Process()
1818
process.executableURL = fooBinary
@@ -26,7 +26,9 @@ final class RedisDemoTests: XCTestCase {
2626
let data = pipe.fileHandleForReading.readDataToEndOfFile()
2727
let output = String(data: data, encoding: .utf8)
2828

29-
XCTAssertEqual(output, "Hello, world!\n")
29+
let isError = output?.contains("missingEnvironmentVariables(LambdaSwiftSprinter.Context.AWSEnvironmentKey.lambdaRuntimeApi)")
30+
31+
XCTAssertEqual(isError, true)
3032
}
3133

3234
/// Returns path to the built products directory.

Examples/RedisDemo/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ services:
44
image: "lambci/lambda:provided"
55
volumes:
66
- ../../.build/local:/var/task:ro,delegated
7-
- ../../bootstrap:/opt/bootstrap:ro,delegated
8-
- ../../swift-shared-libs:/opt/swift-shared-libs:ro,delegated
7+
- ../../swift-shared-libs/bootstrap:/opt/bootstrap:ro,delegated
8+
- ../../swift-shared-libs:/opt/:ro,delegated
99
environment:
1010
- DOCKER_LAMBDA_STAY_OPEN=1
1111
- AWS_LAMBDA_FUNCTION_TIMEOUT=10

Examples/S3Test/Package.resolved

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

Examples/S3Test/Package.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
1-
// swift-tools-version:5.0
1+
// swift-tools-version:5.1
22

33
import PackageDescription
44

55
let package = Package(
66
name: "S3Test",
7+
products: [
8+
.executable(name: "S3Test", targets: ["S3Test"])
9+
],
710
dependencies: [
811
// Dependencies declare other packages that this package depends on.
912
// .package(url: /* package url */, from: "1.0.0"),
1013
//.package(path: "../../../aws-lambda-swift-sprinter-core"),
1114
//.package(url: "https://github.com/swift-sprinter/aws-lambda-swift-sprinter-core", from: "1.0.0-alpha.3"),
1215
//.package(path: "../../../aws-lambda-swift-sprinter-nio-plugin"),
1316
.package(url: "https://github.com/swift-sprinter/aws-lambda-swift-sprinter-nio-plugin", from: "1.0.0"),
14-
.package(url: "https://github.com/swift-aws/aws-sdk-swift.git", from: "4.0.0"),
17+
.package(url: "https://github.com/swift-aws/aws-sdk-swift.git", from: "5.0.0-alpha.3"),
1518
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
1619
],
1720
targets: [
1821
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
1922
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
2023
.target(
2124
name: "S3Test",
22-
dependencies: ["LambdaSwiftSprinterNioPlugin", "S3", "Logging"]
25+
dependencies: [
26+
"LambdaSwiftSprinterNioPlugin",
27+
.product(name: "AWSS3", package: "aws-sdk-swift"),
28+
"Logging"
29+
]
2330
),
2431
.testTarget(
2532
name: "S3TestTests",

0 commit comments

Comments
 (0)