Skip to content

Commit 3b72f6a

Browse files
authored
improve examples (#292)
motivation: examples can be confusing since they use relative path to the library for CI purposes changes: * update examples to use the library URL, expect when env variable is set for CI purposes * rename docker compose job to test-examples since it is more accurate
1 parent fb86060 commit 3b72f6a

File tree

12 files changed

+87
-45
lines changed

12 files changed

+87
-45
lines changed

Examples/Benchmark/Package.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// swift-tools-version:5.7
22

3+
import class Foundation.ProcessInfo // needed for CI to test the local version of the library
34
import PackageDescription
45

56
let package = Package(
@@ -11,10 +12,7 @@ let package = Package(
1112
.executable(name: "MyLambda", targets: ["MyLambda"]),
1213
],
1314
dependencies: [
14-
// this is the dependency on the swift-aws-lambda-runtime library
15-
// in real-world projects this would say
16-
// .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0")
17-
.package(name: "swift-aws-lambda-runtime", path: "../.."),
15+
.package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0-alpha"),
1816
],
1917
targets: [
2018
.executableTarget(
@@ -26,3 +24,10 @@ let package = Package(
2624
),
2725
]
2826
)
27+
28+
// for CI to test the local version of the library
29+
if ProcessInfo.processInfo.environment["LAMBDA_USE_LOCAL_DEPS"] != nil {
30+
package.dependencies = [
31+
.package(name: "swift-aws-lambda-runtime", path: "../.."),
32+
]
33+
}

Examples/Deployment/Package.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// swift-tools-version:5.7
22

3+
import class Foundation.ProcessInfo // needed for CI to test the local version of the library
34
import PackageDescription
45

56
let package = Package(
@@ -15,10 +16,7 @@ let package = Package(
1516
// demonstrate different types of error handling
1617
],
1718
dependencies: [
18-
// this is the dependency on the swift-aws-lambda-runtime library
19-
// in real-world projects this would say
20-
// .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0")
21-
.package(name: "swift-aws-lambda-runtime", path: "../.."),
19+
.package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0-alpha"),
2220
],
2321
targets: [
2422
.executableTarget(name: "Benchmark", dependencies: [
@@ -29,3 +27,10 @@ let package = Package(
2927
]),
3028
]
3129
)
30+
31+
// for CI to test the local version of the library
32+
if ProcessInfo.processInfo.environment["LAMBDA_USE_LOCAL_DEPS"] != nil {
33+
package.dependencies = [
34+
.package(name: "swift-aws-lambda-runtime", path: "../.."),
35+
]
36+
}

Examples/Echo/Package.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// swift-tools-version:5.7
22

3+
import class Foundation.ProcessInfo // needed for CI to test the local version of the library
34
import PackageDescription
45

56
let package = Package(
@@ -11,10 +12,7 @@ let package = Package(
1112
.executable(name: "MyLambda", targets: ["MyLambda"]),
1213
],
1314
dependencies: [
14-
// this is the dependency on the swift-aws-lambda-runtime library
15-
// in real-world projects this would say
16-
// .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0")
17-
.package(name: "swift-aws-lambda-runtime", path: "../.."),
15+
.package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0-alpha"),
1816
],
1917
targets: [
2018
.executableTarget(
@@ -26,3 +24,10 @@ let package = Package(
2624
),
2725
]
2826
)
27+
28+
// for CI to test the local version of the library
29+
if ProcessInfo.processInfo.environment["LAMBDA_USE_LOCAL_DEPS"] != nil {
30+
package.dependencies = [
31+
.package(name: "swift-aws-lambda-runtime", path: "../.."),
32+
]
33+
}

Examples/ErrorHandling/Package.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// swift-tools-version:5.7
22

3+
import class Foundation.ProcessInfo // needed for CI to test the local version of the library
34
import PackageDescription
45

56
let package = Package(
@@ -11,10 +12,7 @@ let package = Package(
1112
.executable(name: "MyLambda", targets: ["MyLambda"]),
1213
],
1314
dependencies: [
14-
// this is the dependency on the swift-aws-lambda-runtime library
15-
// in real-world projects this would say
16-
// .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0")
17-
.package(name: "swift-aws-lambda-runtime", path: "../.."),
15+
.package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0-alpha"),
1816
],
1917
targets: [
2018
.executableTarget(
@@ -26,3 +24,10 @@ let package = Package(
2624
),
2725
]
2826
)
27+
28+
// for CI to test the local version of the library
29+
if ProcessInfo.processInfo.environment["LAMBDA_USE_LOCAL_DEPS"] != nil {
30+
package.dependencies = [
31+
.package(name: "swift-aws-lambda-runtime", path: "../.."),
32+
]
33+
}

Examples/Foundation/Package.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// swift-tools-version:5.7
22

3+
import class Foundation.ProcessInfo // needed for CI to test the local version of the library
34
import PackageDescription
45

56
let package = Package(
@@ -11,10 +12,7 @@ let package = Package(
1112
.executable(name: "MyLambda", targets: ["MyLambda"]),
1213
],
1314
dependencies: [
14-
// this is the dependency on the swift-aws-lambda-runtime library
15-
// in real-world projects this would say
16-
// .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0")
17-
.package(name: "swift-aws-lambda-runtime", path: "../.."),
15+
.package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0-alpha"),
1816
],
1917
targets: [
2018
.executableTarget(
@@ -26,3 +24,10 @@ let package = Package(
2624
),
2725
]
2826
)
27+
28+
// for CI to test the local version of the library
29+
if ProcessInfo.processInfo.environment["LAMBDA_USE_LOCAL_DEPS"] != nil {
30+
package.dependencies = [
31+
.package(name: "swift-aws-lambda-runtime", path: "../.."),
32+
]
33+
}

Examples/JSON/Package.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// swift-tools-version:5.7
22

3+
import class Foundation.ProcessInfo // needed for CI to test the local version of the library
34
import PackageDescription
45

56
let package = Package(
@@ -11,10 +12,7 @@ let package = Package(
1112
.executable(name: "MyLambda", targets: ["MyLambda"]),
1213
],
1314
dependencies: [
14-
// this is the dependency on the swift-aws-lambda-runtime library
15-
// in real-world projects this would say
16-
// .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0")
17-
.package(name: "swift-aws-lambda-runtime", path: "../.."),
15+
.package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0-alpha"),
1816
],
1917
targets: [
2018
.executableTarget(
@@ -26,3 +24,10 @@ let package = Package(
2624
),
2725
]
2826
)
27+
28+
// for CI to test the local version of the library
29+
if ProcessInfo.processInfo.environment["LAMBDA_USE_LOCAL_DEPS"] != nil {
30+
package.dependencies = [
31+
.package(name: "swift-aws-lambda-runtime", path: "../.."),
32+
]
33+
}

Examples/LocalDebugging/MyLambda/Package.swift

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// swift-tools-version:5.7
22

3+
import class Foundation.ProcessInfo // needed for CI to test the local version of the library
34
import PackageDescription
45

56
let package = Package(
@@ -11,10 +12,7 @@ let package = Package(
1112
.executable(name: "MyLambda", targets: ["MyLambda"]),
1213
],
1314
dependencies: [
14-
// this is the dependency on the swift-aws-lambda-runtime library
15-
// in real-world projects this would say
16-
// .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0")
17-
.package(name: "swift-aws-lambda-runtime", path: "../../.."),
15+
.package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0-alpha"),
1816
.package(name: "Shared", path: "../Shared"),
1917
],
2018
targets: [
@@ -24,7 +22,16 @@ let package = Package(
2422
.product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime"),
2523
.product(name: "Shared", package: "Shared"),
2624
],
27-
path: "."
25+
path: ".",
26+
exclude: ["scripts/", "Dockerfile"]
2827
),
2928
]
3029
)
30+
31+
// for CI to test the local version of the library
32+
if ProcessInfo.processInfo.environment["LAMBDA_USE_LOCAL_DEPS"] != nil {
33+
package.dependencies = [
34+
.package(name: "swift-aws-lambda-runtime", path: "../../.."),
35+
.package(name: "Shared", path: "../Shared"),
36+
]
37+
}

Examples/Testing/Package.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// swift-tools-version:5.7
22

3+
import class Foundation.ProcessInfo // needed for CI to test the local version of the library
34
import PackageDescription
45

56
let package = Package(
@@ -11,10 +12,7 @@ let package = Package(
1112
.executable(name: "MyLambda", targets: ["MyLambda"]),
1213
],
1314
dependencies: [
14-
// this is the dependency on the swift-aws-lambda-runtime library
15-
// in real-world projects this would say
16-
// .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0")
17-
.package(name: "swift-aws-lambda-runtime", path: "../.."),
15+
.package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0-alpha"),
1816
],
1917
targets: [
2018
.executableTarget(
@@ -28,3 +26,10 @@ let package = Package(
2826
.testTarget(name: "MyLambdaTests", dependencies: ["MyLambda"], path: "Tests"),
2927
]
3028
)
29+
30+
// for CI to test the local version of the library
31+
if ProcessInfo.processInfo.environment["LAMBDA_USE_LOCAL_DEPS"] != nil {
32+
package.dependencies = [
33+
.package(name: "swift-aws-lambda-runtime", path: "../.."),
34+
]
35+
}

docker/docker-compose.al2.57.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ services:
1111
test:
1212
image: swift-aws-lambda:al2-5.7
1313

14-
test-samples:
14+
test-examples:
1515
image: swift-aws-lambda:al2-5.7
1616

1717
shell:

docker/docker-compose.al2.58.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ services:
1111
test:
1212
image: swift-aws-lambda:al2-5.8
1313

14-
test-samples:
14+
test-examples:
1515
image: swift-aws-lambda:al2-5.8
1616

1717
shell:

0 commit comments

Comments
 (0)