From 03482ce84c0b08c7c303509bd4955f5a95ec058c Mon Sep 17 00:00:00 2001 From: tom doron Date: Fri, 10 Mar 2023 10:17:28 -0800 Subject: [PATCH 1/2] improve examples 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 --- Examples/Benchmark/Package.swift | 13 +++++--- Examples/Deployment/Package.swift | 13 +++++--- Examples/Echo/Package.swift | 13 +++++--- Examples/ErrorHandling/Package.swift | 13 +++++--- Examples/Foundation/Package.swift | 13 +++++--- Examples/JSON/Package.swift | 13 +++++--- .../LocalDebugging/MyLambda/Package.swift | 17 +++++++--- Examples/Testing/Package.swift | 13 +++++--- docker/docker-compose.yaml | 31 ++++++++++++++----- 9 files changed, 98 insertions(+), 41 deletions(-) diff --git a/Examples/Benchmark/Package.swift b/Examples/Benchmark/Package.swift index 7cceea76..c6370ce6 100644 --- a/Examples/Benchmark/Package.swift +++ b/Examples/Benchmark/Package.swift @@ -1,5 +1,6 @@ // swift-tools-version:5.7 +import class Foundation.ProcessInfo // needed for CI to test the local version of the library import PackageDescription let package = Package( @@ -11,10 +12,7 @@ let package = Package( .executable(name: "MyLambda", targets: ["MyLambda"]), ], dependencies: [ - // this is the dependency on the swift-aws-lambda-runtime library - // in real-world projects this would say - // .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0") - .package(name: "swift-aws-lambda-runtime", path: "../.."), + .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0-alpha"), ], targets: [ .executableTarget( @@ -26,3 +24,10 @@ let package = Package( ), ] ) + +// for CI to test the local version of the library +if ProcessInfo.processInfo.environment["LAMBDA_USE_LOCAL_DEPS"] != nil { + package.dependencies = [ + .package(name: "swift-aws-lambda-runtime", path: "../.."), + ] +} diff --git a/Examples/Deployment/Package.swift b/Examples/Deployment/Package.swift index 4fb37203..51181f66 100644 --- a/Examples/Deployment/Package.swift +++ b/Examples/Deployment/Package.swift @@ -1,5 +1,6 @@ // swift-tools-version:5.7 +import class Foundation.ProcessInfo // needed for CI to test the local version of the library import PackageDescription let package = Package( @@ -15,10 +16,7 @@ let package = Package( // demonstrate different types of error handling ], dependencies: [ - // this is the dependency on the swift-aws-lambda-runtime library - // in real-world projects this would say - // .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0") - .package(name: "swift-aws-lambda-runtime", path: "../.."), + .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0-alpha"), ], targets: [ .executableTarget(name: "Benchmark", dependencies: [ @@ -29,3 +27,10 @@ let package = Package( ]), ] ) + +// for CI to test the local version of the library +if ProcessInfo.processInfo.environment["LAMBDA_USE_LOCAL_DEPS"] != nil { + package.dependencies = [ + .package(name: "swift-aws-lambda-runtime", path: "../.."), + ] +} diff --git a/Examples/Echo/Package.swift b/Examples/Echo/Package.swift index dc5fa33c..a6d7ffef 100644 --- a/Examples/Echo/Package.swift +++ b/Examples/Echo/Package.swift @@ -1,5 +1,6 @@ // swift-tools-version:5.7 +import class Foundation.ProcessInfo // needed for CI to test the local version of the library import PackageDescription let package = Package( @@ -11,10 +12,7 @@ let package = Package( .executable(name: "MyLambda", targets: ["MyLambda"]), ], dependencies: [ - // this is the dependency on the swift-aws-lambda-runtime library - // in real-world projects this would say - // .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0") - .package(name: "swift-aws-lambda-runtime", path: "../.."), + .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0-alpha"), ], targets: [ .executableTarget( @@ -26,3 +24,10 @@ let package = Package( ), ] ) + +// for CI to test the local version of the library +if ProcessInfo.processInfo.environment["LAMBDA_USE_LOCAL_DEPS"] != nil { + package.dependencies = [ + .package(name: "swift-aws-lambda-runtime", path: "../.."), + ] +} diff --git a/Examples/ErrorHandling/Package.swift b/Examples/ErrorHandling/Package.swift index dc5fa33c..a6d7ffef 100644 --- a/Examples/ErrorHandling/Package.swift +++ b/Examples/ErrorHandling/Package.swift @@ -1,5 +1,6 @@ // swift-tools-version:5.7 +import class Foundation.ProcessInfo // needed for CI to test the local version of the library import PackageDescription let package = Package( @@ -11,10 +12,7 @@ let package = Package( .executable(name: "MyLambda", targets: ["MyLambda"]), ], dependencies: [ - // this is the dependency on the swift-aws-lambda-runtime library - // in real-world projects this would say - // .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0") - .package(name: "swift-aws-lambda-runtime", path: "../.."), + .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0-alpha"), ], targets: [ .executableTarget( @@ -26,3 +24,10 @@ let package = Package( ), ] ) + +// for CI to test the local version of the library +if ProcessInfo.processInfo.environment["LAMBDA_USE_LOCAL_DEPS"] != nil { + package.dependencies = [ + .package(name: "swift-aws-lambda-runtime", path: "../.."), + ] +} diff --git a/Examples/Foundation/Package.swift b/Examples/Foundation/Package.swift index dc5fa33c..a6d7ffef 100644 --- a/Examples/Foundation/Package.swift +++ b/Examples/Foundation/Package.swift @@ -1,5 +1,6 @@ // swift-tools-version:5.7 +import class Foundation.ProcessInfo // needed for CI to test the local version of the library import PackageDescription let package = Package( @@ -11,10 +12,7 @@ let package = Package( .executable(name: "MyLambda", targets: ["MyLambda"]), ], dependencies: [ - // this is the dependency on the swift-aws-lambda-runtime library - // in real-world projects this would say - // .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0") - .package(name: "swift-aws-lambda-runtime", path: "../.."), + .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0-alpha"), ], targets: [ .executableTarget( @@ -26,3 +24,10 @@ let package = Package( ), ] ) + +// for CI to test the local version of the library +if ProcessInfo.processInfo.environment["LAMBDA_USE_LOCAL_DEPS"] != nil { + package.dependencies = [ + .package(name: "swift-aws-lambda-runtime", path: "../.."), + ] +} diff --git a/Examples/JSON/Package.swift b/Examples/JSON/Package.swift index dc5fa33c..a6d7ffef 100644 --- a/Examples/JSON/Package.swift +++ b/Examples/JSON/Package.swift @@ -1,5 +1,6 @@ // swift-tools-version:5.7 +import class Foundation.ProcessInfo // needed for CI to test the local version of the library import PackageDescription let package = Package( @@ -11,10 +12,7 @@ let package = Package( .executable(name: "MyLambda", targets: ["MyLambda"]), ], dependencies: [ - // this is the dependency on the swift-aws-lambda-runtime library - // in real-world projects this would say - // .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0") - .package(name: "swift-aws-lambda-runtime", path: "../.."), + .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0-alpha"), ], targets: [ .executableTarget( @@ -26,3 +24,10 @@ let package = Package( ), ] ) + +// for CI to test the local version of the library +if ProcessInfo.processInfo.environment["LAMBDA_USE_LOCAL_DEPS"] != nil { + package.dependencies = [ + .package(name: "swift-aws-lambda-runtime", path: "../.."), + ] +} diff --git a/Examples/LocalDebugging/MyLambda/Package.swift b/Examples/LocalDebugging/MyLambda/Package.swift index 567d0c49..afc9fa21 100644 --- a/Examples/LocalDebugging/MyLambda/Package.swift +++ b/Examples/LocalDebugging/MyLambda/Package.swift @@ -1,5 +1,6 @@ // swift-tools-version:5.7 +import class Foundation.ProcessInfo // needed for CI to test the local version of the library import PackageDescription let package = Package( @@ -11,10 +12,7 @@ let package = Package( .executable(name: "MyLambda", targets: ["MyLambda"]), ], dependencies: [ - // this is the dependency on the swift-aws-lambda-runtime library - // in real-world projects this would say - // .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0") - .package(name: "swift-aws-lambda-runtime", path: "../../.."), + .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0-alpha"), .package(name: "Shared", path: "../Shared"), ], targets: [ @@ -24,7 +22,16 @@ let package = Package( .product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime"), .product(name: "Shared", package: "Shared"), ], - path: "." + path: ".", + exclude: ["scripts/", "Dockerfile"] ), ] ) + +// for CI to test the local version of the library +if ProcessInfo.processInfo.environment["LAMBDA_USE_LOCAL_DEPS"] != nil { + package.dependencies = [ + .package(name: "swift-aws-lambda-runtime", path: "../../.."), + .package(name: "Shared", path: "../Shared"), + ] +} diff --git a/Examples/Testing/Package.swift b/Examples/Testing/Package.swift index c80d39d9..b29e9b19 100644 --- a/Examples/Testing/Package.swift +++ b/Examples/Testing/Package.swift @@ -1,5 +1,6 @@ // swift-tools-version:5.7 +import class Foundation.ProcessInfo // needed for CI to test the local version of the library import PackageDescription let package = Package( @@ -11,10 +12,7 @@ let package = Package( .executable(name: "MyLambda", targets: ["MyLambda"]), ], dependencies: [ - // this is the dependency on the swift-aws-lambda-runtime library - // in real-world projects this would say - // .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0") - .package(name: "swift-aws-lambda-runtime", path: "../.."), + .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0-alpha"), ], targets: [ .executableTarget( @@ -28,3 +26,10 @@ let package = Package( .testTarget(name: "MyLambdaTests", dependencies: ["MyLambda"], path: "Tests"), ] ) + +// for CI to test the local version of the library +if ProcessInfo.processInfo.environment["LAMBDA_USE_LOCAL_DEPS"] != nil { + package.dependencies = [ + .package(name: "swift-aws-lambda-runtime", path: "../.."), + ] +} diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 3af40b1e..70d34fcb 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -30,18 +30,33 @@ services: <<: *common command: /bin/bash -cl "swift test -Xswiftc -warnings-as-errors $${SANITIZER_ARG-}" + # to be deprecated, sue test-examples instead test-samples: <<: *common command: >- /bin/bash -clx " - swift build --package-path Examples/Benchmark && - swift build --package-path Examples/Deployment && - swift build --package-path Examples/Echo && - swift build --package-path Examples/ErrorHandling && - swift build --package-path Examples/Foundation && - swift build --package-path Examples/JSON && - swift build --package-path Examples/LocalDebugging/MyLambda && - swift test --package-path Examples/Testing + LAMBDA_USE_LOCAL_DEPS=true swift build --package-path Examples/Benchmark && + LAMBDA_USE_LOCAL_DEPS=true swift build --package-path Examples/Deployment && + LAMBDA_USE_LOCAL_DEPS=true swift build --package-path Examples/Echo && + LAMBDA_USE_LOCAL_DEPS=true swift build --package-path Examples/ErrorHandling && + LAMBDA_USE_LOCAL_DEPS=true swift build --package-path Examples/Foundation && + LAMBDA_USE_LOCAL_DEPS=true swift build --package-path Examples/JSON && + LAMBDA_USE_LOCAL_DEPS=true swift build --package-path Examples/LocalDebugging/MyLambda && + LAMBDA_USE_LOCAL_DEPS=true swift test --package-path Examples/Testing + " + + test-examples: + <<: *common + command: >- + /bin/bash -clx " + LAMBDA_USE_LOCAL_DEPS=true swift build --package-path Examples/Benchmark && + LAMBDA_USE_LOCAL_DEPS=true swift build --package-path Examples/Deployment && + LAMBDA_USE_LOCAL_DEPS=true swift build --package-path Examples/Echo && + LAMBDA_USE_LOCAL_DEPS=true swift build --package-path Examples/ErrorHandling && + LAMBDA_USE_LOCAL_DEPS=true swift build --package-path Examples/Foundation && + LAMBDA_USE_LOCAL_DEPS=true swift build --package-path Examples/JSON && + LAMBDA_USE_LOCAL_DEPS=true swift build --package-path Examples/LocalDebugging/MyLambda && + LAMBDA_USE_LOCAL_DEPS=true swift test --package-path Examples/Testing " # util From a21cc7b0d6761da2afdbfe60b8e4d3fa7762ac64 Mon Sep 17 00:00:00 2001 From: tom doron Date: Sun, 12 Mar 2023 11:16:20 -0700 Subject: [PATCH 2/2] fixup --- docker/docker-compose.al2.57.yaml | 2 +- docker/docker-compose.al2.58.yaml | 2 +- docker/docker-compose.al2.main.yaml | 2 +- docker/docker-compose.yaml | 15 --------------- 4 files changed, 3 insertions(+), 18 deletions(-) diff --git a/docker/docker-compose.al2.57.yaml b/docker/docker-compose.al2.57.yaml index dc5044fa..1b19f1f0 100644 --- a/docker/docker-compose.al2.57.yaml +++ b/docker/docker-compose.al2.57.yaml @@ -11,7 +11,7 @@ services: test: image: swift-aws-lambda:al2-5.7 - test-samples: + test-examples: image: swift-aws-lambda:al2-5.7 shell: diff --git a/docker/docker-compose.al2.58.yaml b/docker/docker-compose.al2.58.yaml index 74154ab8..275fcee6 100644 --- a/docker/docker-compose.al2.58.yaml +++ b/docker/docker-compose.al2.58.yaml @@ -11,7 +11,7 @@ services: test: image: swift-aws-lambda:al2-5.8 - test-samples: + test-examples: image: swift-aws-lambda:al2-5.8 shell: diff --git a/docker/docker-compose.al2.main.yaml b/docker/docker-compose.al2.main.yaml index c63a13e2..b2f890c1 100644 --- a/docker/docker-compose.al2.main.yaml +++ b/docker/docker-compose.al2.main.yaml @@ -11,7 +11,7 @@ services: test: image: swift-aws-lambda:al2-main - test-samples: + test-examples: image: swift-aws-lambda:al2-main shell: diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 70d34fcb..32507dcf 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -30,21 +30,6 @@ services: <<: *common command: /bin/bash -cl "swift test -Xswiftc -warnings-as-errors $${SANITIZER_ARG-}" - # to be deprecated, sue test-examples instead - test-samples: - <<: *common - command: >- - /bin/bash -clx " - LAMBDA_USE_LOCAL_DEPS=true swift build --package-path Examples/Benchmark && - LAMBDA_USE_LOCAL_DEPS=true swift build --package-path Examples/Deployment && - LAMBDA_USE_LOCAL_DEPS=true swift build --package-path Examples/Echo && - LAMBDA_USE_LOCAL_DEPS=true swift build --package-path Examples/ErrorHandling && - LAMBDA_USE_LOCAL_DEPS=true swift build --package-path Examples/Foundation && - LAMBDA_USE_LOCAL_DEPS=true swift build --package-path Examples/JSON && - LAMBDA_USE_LOCAL_DEPS=true swift build --package-path Examples/LocalDebugging/MyLambda && - LAMBDA_USE_LOCAL_DEPS=true swift test --package-path Examples/Testing - " - test-examples: <<: *common command: >-