Skip to content

Commit 0a75e0f

Browse files
authored
Use package traits when using Swift 6.1 (#490)
1 parent 03876f6 commit 0a75e0f

File tree

118 files changed

+431
-643
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+431
-643
lines changed

.github/workflows/integration_tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ on:
3939
matrix_linux_swift_container_image:
4040
type: string
4141
description: "Container image for the matrix job. Defaults to matching latest Swift Ubuntu image."
42-
default: "swift:amazonlinux2"
42+
default: "swiftlang/swift:nightly-6.1-jammy"
4343

4444
## We are cancelling previously triggered workflow runs
4545
concurrency:

.github/workflows/pull_request.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ jobs:
1212
license_header_check_project_name: "SwiftAWSLambdaRuntime"
1313
shell_check_enabled: true
1414
python_lint_check_enabled: true
15-
api_breakage_check_container_image: "swift:6.0-noble"
15+
api_breakage_check_container_image: "swiftlang/swift:nightly-6.1-jammy"
1616
docs_check_container_image: "swift:6.0-noble"
17-
format_check_container_image: "swiftlang/swift:nightly-6.0-jammy"
17+
format_check_container_image: "swiftlang/swift:nightly-6.1-jammy"
1818
yamllint_check_enabled: true
1919

2020
unit-tests:

.spi.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
version: 1
22
builder:
33
configs:
4-
- documentation_targets: [AWSLambdaRuntimeCore, AWSLambdaRuntime]
4+
- documentation_targets: [AWSLambdaRuntime]

Examples/HelloJSON/Package.swift

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:6.0
1+
// swift-tools-version:6.1
22

33
import PackageDescription
44

@@ -13,7 +13,13 @@ let package = Package(
1313
],
1414
dependencies: [
1515
// during CI, the dependency on local version of swift-aws-lambda-runtime is added dynamically below
16-
.package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", branch: "main")
16+
.package(
17+
url: "https://github.com/swift-server/swift-aws-lambda-runtime.git",
18+
branch: "ff-package-traits",
19+
traits: [
20+
.trait(name: "FoundationJSONSupport")
21+
]
22+
)
1723
],
1824
targets: [
1925
.executableTarget(

Package.swift

+21-14
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,50 @@
1-
// swift-tools-version:6.0
1+
// swift-tools-version:6.1
22

33
import PackageDescription
44

55
let package = Package(
66
name: "swift-aws-lambda-runtime",
77
platforms: [.macOS(.v15)],
88
products: [
9-
// this library exports `AWSLambdaRuntimeCore` and adds Foundation convenience methods
109
.library(name: "AWSLambdaRuntime", targets: ["AWSLambdaRuntime"]),
11-
// this has all the main functionality for lambda and it does not link Foundation
12-
.library(name: "AWSLambdaRuntimeCore", targets: ["AWSLambdaRuntimeCore"]),
1310
// plugin to package the lambda, creating an archive that can be uploaded to AWS
1411
// requires Linux or at least macOS v15
1512
.plugin(name: "AWSLambdaPackager", targets: ["AWSLambdaPackager"]),
1613
// for testing only
1714
.library(name: "AWSLambdaTesting", targets: ["AWSLambdaTesting"]),
1815
],
16+
traits: [
17+
"FoundationJSONSupport",
18+
"ServiceLifecycleSupport",
19+
"LocalServerSupport",
20+
.default(
21+
enabledTraits: [
22+
"FoundationJSONSupport",
23+
"ServiceLifecycleSupport",
24+
"LocalServerSupport",
25+
]
26+
),
27+
],
1928
dependencies: [
2029
.package(url: "https://github.com/apple/swift-nio.git", from: "2.81.0"),
2130
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.4"),
2231
.package(url: "https://github.com/apple/swift-collections.git", from: "1.1.4"),
32+
.package(url: "https://github.com/swift-server/swift-service-lifecycle.git", from: "2.6.3"),
2333
],
2434
targets: [
2535
.target(
2636
name: "AWSLambdaRuntime",
2737
dependencies: [
28-
.byName(name: "AWSLambdaRuntimeCore"),
2938
.product(name: "NIOCore", package: "swift-nio"),
30-
]
31-
),
32-
.target(
33-
name: "AWSLambdaRuntimeCore",
34-
dependencies: [
3539
.product(name: "DequeModule", package: "swift-collections"),
3640
.product(name: "Logging", package: "swift-log"),
3741
.product(name: "NIOHTTP1", package: "swift-nio"),
38-
.product(name: "NIOCore", package: "swift-nio"),
3942
.product(name: "NIOPosix", package: "swift-nio"),
43+
.product(
44+
name: "ServiceLifecycle",
45+
package: "swift-service-lifecycle",
46+
condition: .when(traits: ["ServiceLifecycleSupport"])
47+
),
4048
]
4149
),
4250
.plugin(
@@ -58,16 +66,15 @@ let package = Package(
5866
.testTarget(
5967
name: "AWSLambdaRuntimeCoreTests",
6068
dependencies: [
61-
.byName(name: "AWSLambdaRuntimeCore"),
69+
.byName(name: "AWSLambdaRuntime"),
6270
.product(name: "NIOTestUtils", package: "swift-nio"),
6371
.product(name: "NIOFoundationCompat", package: "swift-nio"),
6472
]
6573
),
6674
.testTarget(
6775
name: "AWSLambdaRuntimeTests",
6876
dependencies: [
69-
.byName(name: "AWSLambdaRuntimeCore"),
70-
.byName(name: "AWSLambdaRuntime"),
77+
.byName(name: "AWSLambdaRuntime")
7178
]
7279
),
7380
// testing helper

[email protected]

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
// swift-tools-version:6.0
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "swift-aws-lambda-runtime",
7+
platforms: [.macOS(.v15)],
8+
products: [
9+
.library(name: "AWSLambdaRuntime", targets: ["AWSLambdaRuntime"]),
10+
// plugin to package the lambda, creating an archive that can be uploaded to AWS
11+
// requires Linux or at least macOS v15
12+
.plugin(name: "AWSLambdaPackager", targets: ["AWSLambdaPackager"]),
13+
// for testing only
14+
.library(name: "AWSLambdaTesting", targets: ["AWSLambdaTesting"]),
15+
],
16+
dependencies: [
17+
.package(url: "https://github.com/apple/swift-nio.git", from: "2.81.0"),
18+
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.4"),
19+
.package(url: "https://github.com/apple/swift-collections.git", from: "1.1.4"),
20+
.package(url: "https://github.com/swift-server/swift-service-lifecycle.git", from: "2.6.3"),
21+
],
22+
targets: [
23+
.target(
24+
name: "AWSLambdaRuntime",
25+
dependencies: [
26+
.product(name: "NIOCore", package: "swift-nio"),
27+
.product(name: "DequeModule", package: "swift-collections"),
28+
.product(name: "Logging", package: "swift-log"),
29+
.product(name: "NIOHTTP1", package: "swift-nio"),
30+
.product(name: "NIOPosix", package: "swift-nio"),
31+
.product(name: "ServiceLifecycle", package: "swift-service-lifecycle"),
32+
],
33+
swiftSettings: [
34+
.define("FoundationJSONSupport"),
35+
.define("ServiceLifecycleSupport"),
36+
.define("LocalServerSupport"),
37+
]
38+
),
39+
.plugin(
40+
name: "AWSLambdaPackager",
41+
capability: .command(
42+
intent: .custom(
43+
verb: "archive",
44+
description:
45+
"Archive the Lambda binary and prepare it for uploading to AWS. Requires docker on macOS or non Amazonlinux 2 distributions."
46+
),
47+
permissions: [
48+
.allowNetworkConnections(
49+
scope: .docker,
50+
reason: "This plugin uses Docker to create the AWS Lambda ZIP package."
51+
)
52+
]
53+
)
54+
),
55+
.testTarget(
56+
name: "AWSLambdaRuntimeCoreTests",
57+
dependencies: [
58+
.byName(name: "AWSLambdaRuntime"),
59+
.product(name: "NIOTestUtils", package: "swift-nio"),
60+
.product(name: "NIOFoundationCompat", package: "swift-nio"),
61+
]
62+
),
63+
.testTarget(
64+
name: "AWSLambdaRuntimeTests",
65+
dependencies: [
66+
.byName(name: "AWSLambdaRuntime")
67+
]
68+
),
69+
// testing helper
70+
.target(
71+
name: "AWSLambdaTesting",
72+
dependencies: [
73+
.byName(name: "AWSLambdaRuntime"),
74+
.product(name: "NIOCore", package: "swift-nio"),
75+
.product(name: "NIOPosix", package: "swift-nio"),
76+
]
77+
),
78+
.testTarget(
79+
name: "AWSLambdaTestingTests",
80+
dependencies: [
81+
.byName(name: "AWSLambdaTesting")
82+
]
83+
),
84+
// for perf testing
85+
.executableTarget(
86+
name: "MockServer",
87+
dependencies: [
88+
.product(name: "Logging", package: "swift-log"),
89+
.product(name: "NIOHTTP1", package: "swift-nio"),
90+
.product(name: "NIOCore", package: "swift-nio"),
91+
.product(name: "NIOPosix", package: "swift-nio"),
92+
]
93+
),
94+
]
95+
)

Sources/AWSLambdaRuntimeCore/Documentation.docc/Documentation.md Sources/AWSLambdaRuntime/Docs.docc/Documentation.md

+1-1

Sources/AWSLambdaRuntimeCore/Documentation.docc/Proposals/0001-v2-api.md Sources/AWSLambdaRuntime/Docs.docc/Proposals/0001-v2-api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
2025-01-02T14:59:29+0100 info LocalLambdaServer : [AWSLambdaRuntimeCore]
1+
2025-01-02T14:59:29+0100 info LocalLambdaServer : [AWSLambdaRuntime]
22
LocalLambdaServer started and listening on 127.0.0.1:7000, receiving events on /invoke

Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-04-07-terminal.sh Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-04-07-terminal.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ swift run
33
Building for debugging...
44
[1/1] Write swift-version--58304C5D6DBC2206.txt
55
Build of product 'PalindromeLambda' complete! (0.11s)
6-
2025-01-02T15:12:49+0100 info LocalLambdaServer : [AWSLambdaRuntimeCore] LocalLambdaServer started and listening on 127.0.0.1:7000, receiving events on /invoke
6+
2025-01-02T15:12:49+0100 info LocalLambdaServer : [AWSLambdaRuntime] LocalLambdaServer started and listening on 127.0.0.1:7000, receiving events on /invoke

0 commit comments

Comments
 (0)