Skip to content

Commit 17cc50c

Browse files
committed
Merge branch 'main' into sebsto/example_test
2 parents 25c6783 + 8c1c1b6 commit 17cc50c

File tree

10 files changed

+45
-18
lines changed

10 files changed

+45
-18
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
##===----------------------------------------------------------------------===##
3+
##
4+
## This source file is part of the SwiftAWSLambdaRuntime open source project
5+
##
6+
## Copyright (c) 2017-2024 Apple Inc. and the SwiftAWSLambdaRuntime project authors
7+
## Licensed under Apache License v2.0
8+
##
9+
## See LICENSE.txt for license information
10+
## See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors
11+
##
12+
## SPDX-License-Identifier: Apache-2.0
13+
##
14+
##===----------------------------------------------------------------------===##
15+
16+
EXAMPLE=HelloWorld
17+
OUTPUT_DIR=.build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager
18+
OUTPUT_FILE=${OUTPUT_DIR}/MyLambda/bootstrap
19+
ZIP_FILE=${OUTPUT_DIR}/MyLambda/MyLambda.zip
20+
21+
pushd Examples/${EXAMPLE} || exit 1
22+
23+
# package the example (docker and swift toolchain are installed on the GH runner)
24+
LAMBDA_USE_LOCAL_DEPS=../.. swift package archive --allow-network-connections docker || exit 1
25+
26+
# did the plugin generated a Linux binary?
27+
[ -f "${OUTPUT_FILE}" ]
28+
file "${OUTPUT_FILE}" | grep --silent ELF
29+
30+
# did the plugin created a ZIP file?
31+
[ -f "${ZIP_FILE}" ]
32+
33+
# does the ZIP file contain the bootstrap?
34+
unzip -l "${ZIP_FILE}" | grep --silent bootstrap
35+
36+
echo "✅ The archive plugin is OK"
37+
popd || exit 1

Examples/APIGateway/Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ let package = Package(
2929
.product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime"),
3030
.product(name: "AWSLambdaEvents", package: "swift-aws-lambda-events"),
3131
],
32-
path: "."
32+
path: "Sources"
3333
)
3434
]
3535
)

Examples/APIGateway/Sources/main.swift

+1-11
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@
1515
import AWSLambdaEvents
1616
import AWSLambdaRuntime
1717

18-
#if canImport(FoundationEssentials)
19-
import FoundationEssentials
20-
#else
21-
import Foundation
22-
#endif
23-
24-
let encoder = JSONEncoder()
2518
let runtime = LambdaRuntime {
2619
(event: APIGatewayV2Request, context: LambdaContext) -> APIGatewayV2Response in
2720

@@ -31,10 +24,7 @@ let runtime = LambdaRuntime {
3124
header["content-type"] = "application/json"
3225

3326
// echo the request in the response
34-
let data = try encoder.encode(event)
35-
let response = String(decoding: data, as: Unicode.UTF8.self)
36-
37-
return APIGatewayV2Response(statusCode: .ok, headers: header, body: response)
27+
return try APIGatewayV2Response(statusCode: .ok, headers: header, encodableBody: event)
3828
}
3929

4030
try await runtime.run()

Examples/BackgroundTasks/Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ let package = Package(
2727
dependencies: [
2828
.product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime")
2929
],
30-
path: "."
30+
path: "Sources"
3131
)
3232
]
3333
)

Examples/CDK/Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ let package = Package(
2929
.product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime"),
3030
.product(name: "AWSLambdaEvents", package: "swift-aws-lambda-events"),
3131
],
32-
path: "."
32+
path: "Sources"
3333
)
3434
]
3535
)

Examples/HelloWorld/Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ let package = Package(
2727
dependencies: [
2828
.product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime")
2929
],
30-
path: "."
30+
path: "Sources"
3131
)
3232
]
3333
)

Examples/Streaming/Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ let package = Package(
2727
dependencies: [
2828
.product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime")
2929
],
30-
path: "."
30+
path: "Sources"
3131
)
3232
]
3333
)

Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-02-05-package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ let package = Package(
2020
dependencies: [
2121
.product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime")
2222
],
23-
path: "."
23+
path: "Sources"
2424
)
2525
]
2626
)

Sources/AWSLambdaRuntimeCore/Documentation.docc/quick-setup.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ let package = Package(
4545
dependencies: [
4646
.product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime"),
4747
],
48-
path: "."
48+
path: "Sources"
4949
),
5050
]
5151
)

0 commit comments

Comments
 (0)