diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 6c3dbde8..05ba8061 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -35,7 +35,7 @@ jobs: with: name: "Integration tests" examples_enabled: true - matrix_linux_command: "LAMBDA_USE_LOCAL_DEPS=../.. swift build" + matrix_linux_command: "swift build" # We pass the list of examples here, but we can't pass an array as argument # Instead, we pass a String with a valid JSON array. # The workaround is mentioned here https://github.com/orgs/community/discussions/11692 diff --git a/.github/workflows/scripts/check-link-foundation.sh b/.github/workflows/scripts/check-link-foundation.sh index d62e3cc5..594781c9 100755 --- a/.github/workflows/scripts/check-link-foundation.sh +++ b/.github/workflows/scripts/check-link-foundation.sh @@ -25,7 +25,7 @@ LIBS_TO_CHECK="libFoundation.so libFoundationInternationalization.so lib_Foundat pushd Examples/${EXAMPLE} || fatal "Failed to change directory to Examples/${EXAMPLE}." # recompile the example without the --static-swift-stdlib flag -LAMBDA_USE_LOCAL_DEPS=../.. swift build -c release || fatal "Failed to build the example." +swift build -c release || fatal "Failed to build the example." # check if the binary exists if [ ! -f "${OUTPUT_FILE}" ]; then diff --git a/Examples/APIGatewayV1/Package.swift b/Examples/APIGatewayV1/Package.swift index d28df7bf..7334a328 100644 --- a/Examples/APIGatewayV1/Package.swift +++ b/Examples/APIGatewayV1/Package.swift @@ -2,9 +2,6 @@ import PackageDescription -// needed for CI to test the local version of the library -import struct Foundation.URL - let package = Package( name: "swift-aws-lambda-runtime-example", platforms: [.macOS(.v15)], @@ -12,8 +9,12 @@ let package = Package( .executable(name: "APIGatewayLambda", targets: ["APIGatewayLambda"]) ], dependencies: [ - // during CI, the dependency on local version of swift-aws-lambda-runtime is added dynamically below - .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "2.0.0"), + // For local development (default) + .package(name: "swift-aws-lambda-runtime", path: "../.."), + + // For standalone usage, comment the line above and uncomment below: + // .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "1.0.0"), + .package(url: "https://github.com/awslabs/swift-aws-lambda-events.git", from: "1.0.0"), ], targets: [ @@ -27,30 +28,3 @@ let package = Package( ) ] ) - -if let localDepsPath = Context.environment["LAMBDA_USE_LOCAL_DEPS"], - localDepsPath != "", - let v = try? URL(fileURLWithPath: localDepsPath).resourceValues(forKeys: [.isDirectoryKey]), - v.isDirectory == true -{ - // when we use the local runtime as deps, let's remove the dependency added above - let indexToRemove = package.dependencies.firstIndex { dependency in - if case .sourceControl( - name: _, - location: "https://github.com/awslabs/swift-aws-lambda-runtime.git", - requirement: _ - ) = dependency.kind { - return true - } - return false - } - if let indexToRemove { - package.dependencies.remove(at: indexToRemove) - } - - // then we add the dependency on LAMBDA_USE_LOCAL_DEPS' path (typically ../..) - print("[INFO] Compiling against swift-aws-lambda-runtime located at \(localDepsPath)") - package.dependencies += [ - .package(name: "swift-aws-lambda-runtime", path: localDepsPath) - ] -} diff --git a/Examples/APIGatewayV2+LambdaAuthorizer/Package.swift b/Examples/APIGatewayV2+LambdaAuthorizer/Package.swift index fdb6cd73..0874ed56 100644 --- a/Examples/APIGatewayV2+LambdaAuthorizer/Package.swift +++ b/Examples/APIGatewayV2+LambdaAuthorizer/Package.swift @@ -2,9 +2,6 @@ import PackageDescription -// needed for CI to test the local version of the library -import struct Foundation.URL - let package = Package( name: "swift-aws-lambda-runtime-example", platforms: [.macOS(.v15)], @@ -13,8 +10,12 @@ let package = Package( .executable(name: "AuthorizerLambda", targets: ["AuthorizerLambda"]), ], dependencies: [ - // during CI, the dependency on local version of swift-aws-lambda-runtime is added dynamically below - .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "2.0.0"), + // For local development (default) + .package(name: "swift-aws-lambda-runtime", path: "../.."), + + // For standalone usage, comment the line above and uncomment below: + // .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "1.0.0"), + .package(url: "https://github.com/awslabs/swift-aws-lambda-events.git", from: "1.0.0"), ], targets: [ @@ -34,30 +35,3 @@ let package = Package( ), ] ) - -if let localDepsPath = Context.environment["LAMBDA_USE_LOCAL_DEPS"], - localDepsPath != "", - let v = try? URL(fileURLWithPath: localDepsPath).resourceValues(forKeys: [.isDirectoryKey]), - v.isDirectory == true -{ - // when we use the local runtime as deps, let's remove the dependency added above - let indexToRemove = package.dependencies.firstIndex { dependency in - if case .sourceControl( - name: _, - location: "https://github.com/awslabs/swift-aws-lambda-runtime.git", - requirement: _ - ) = dependency.kind { - return true - } - return false - } - if let indexToRemove { - package.dependencies.remove(at: indexToRemove) - } - - // then we add the dependency on LAMBDA_USE_LOCAL_DEPS' path (typically ../..) - print("[INFO] Compiling against swift-aws-lambda-runtime located at \(localDepsPath)") - package.dependencies += [ - .package(name: "swift-aws-lambda-runtime", path: localDepsPath) - ] -} diff --git a/Examples/APIGatewayV2/Package.swift b/Examples/APIGatewayV2/Package.swift index d28df7bf..7334a328 100644 --- a/Examples/APIGatewayV2/Package.swift +++ b/Examples/APIGatewayV2/Package.swift @@ -2,9 +2,6 @@ import PackageDescription -// needed for CI to test the local version of the library -import struct Foundation.URL - let package = Package( name: "swift-aws-lambda-runtime-example", platforms: [.macOS(.v15)], @@ -12,8 +9,12 @@ let package = Package( .executable(name: "APIGatewayLambda", targets: ["APIGatewayLambda"]) ], dependencies: [ - // during CI, the dependency on local version of swift-aws-lambda-runtime is added dynamically below - .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "2.0.0"), + // For local development (default) + .package(name: "swift-aws-lambda-runtime", path: "../.."), + + // For standalone usage, comment the line above and uncomment below: + // .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "1.0.0"), + .package(url: "https://github.com/awslabs/swift-aws-lambda-events.git", from: "1.0.0"), ], targets: [ @@ -27,30 +28,3 @@ let package = Package( ) ] ) - -if let localDepsPath = Context.environment["LAMBDA_USE_LOCAL_DEPS"], - localDepsPath != "", - let v = try? URL(fileURLWithPath: localDepsPath).resourceValues(forKeys: [.isDirectoryKey]), - v.isDirectory == true -{ - // when we use the local runtime as deps, let's remove the dependency added above - let indexToRemove = package.dependencies.firstIndex { dependency in - if case .sourceControl( - name: _, - location: "https://github.com/awslabs/swift-aws-lambda-runtime.git", - requirement: _ - ) = dependency.kind { - return true - } - return false - } - if let indexToRemove { - package.dependencies.remove(at: indexToRemove) - } - - // then we add the dependency on LAMBDA_USE_LOCAL_DEPS' path (typically ../..) - print("[INFO] Compiling against swift-aws-lambda-runtime located at \(localDepsPath)") - package.dependencies += [ - .package(name: "swift-aws-lambda-runtime", path: localDepsPath) - ] -} diff --git a/Examples/BackgroundTasks/Package.swift b/Examples/BackgroundTasks/Package.swift index 713f8bb9..ecc659d0 100644 --- a/Examples/BackgroundTasks/Package.swift +++ b/Examples/BackgroundTasks/Package.swift @@ -2,9 +2,6 @@ import PackageDescription -// needed for CI to test the local version of the library -import struct Foundation.URL - let package = Package( name: "swift-aws-lambda-runtime-example", platforms: [.macOS(.v15)], @@ -12,8 +9,11 @@ let package = Package( .executable(name: "BackgroundTasks", targets: ["BackgroundTasks"]) ], dependencies: [ - // during CI, the dependency on local version of swift-aws-lambda-runtime is added dynamically below - .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "2.0.0") + // For local development (default) + .package(name: "swift-aws-lambda-runtime", path: "../..") + + // For standalone usage, comment the line above and uncomment below: + // .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "1.0.0"), ], targets: [ .executableTarget( @@ -25,30 +25,3 @@ let package = Package( ) ] ) - -if let localDepsPath = Context.environment["LAMBDA_USE_LOCAL_DEPS"], - localDepsPath != "", - let v = try? URL(fileURLWithPath: localDepsPath).resourceValues(forKeys: [.isDirectoryKey]), - v.isDirectory == true -{ - // when we use the local runtime as deps, let's remove the dependency added above - let indexToRemove = package.dependencies.firstIndex { dependency in - if case .sourceControl( - name: _, - location: "https://github.com/awslabs/swift-aws-lambda-runtime.git", - requirement: _ - ) = dependency.kind { - return true - } - return false - } - if let indexToRemove { - package.dependencies.remove(at: indexToRemove) - } - - // then we add the dependency on LAMBDA_USE_LOCAL_DEPS' path (typically ../..) - print("[INFO] Compiling against swift-aws-lambda-runtime located at \(localDepsPath)") - package.dependencies += [ - .package(name: "swift-aws-lambda-runtime", path: localDepsPath) - ] -} diff --git a/Examples/CDK/Package.swift b/Examples/CDK/Package.swift index d28df7bf..7334a328 100644 --- a/Examples/CDK/Package.swift +++ b/Examples/CDK/Package.swift @@ -2,9 +2,6 @@ import PackageDescription -// needed for CI to test the local version of the library -import struct Foundation.URL - let package = Package( name: "swift-aws-lambda-runtime-example", platforms: [.macOS(.v15)], @@ -12,8 +9,12 @@ let package = Package( .executable(name: "APIGatewayLambda", targets: ["APIGatewayLambda"]) ], dependencies: [ - // during CI, the dependency on local version of swift-aws-lambda-runtime is added dynamically below - .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "2.0.0"), + // For local development (default) + .package(name: "swift-aws-lambda-runtime", path: "../.."), + + // For standalone usage, comment the line above and uncomment below: + // .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "1.0.0"), + .package(url: "https://github.com/awslabs/swift-aws-lambda-events.git", from: "1.0.0"), ], targets: [ @@ -27,30 +28,3 @@ let package = Package( ) ] ) - -if let localDepsPath = Context.environment["LAMBDA_USE_LOCAL_DEPS"], - localDepsPath != "", - let v = try? URL(fileURLWithPath: localDepsPath).resourceValues(forKeys: [.isDirectoryKey]), - v.isDirectory == true -{ - // when we use the local runtime as deps, let's remove the dependency added above - let indexToRemove = package.dependencies.firstIndex { dependency in - if case .sourceControl( - name: _, - location: "https://github.com/awslabs/swift-aws-lambda-runtime.git", - requirement: _ - ) = dependency.kind { - return true - } - return false - } - if let indexToRemove { - package.dependencies.remove(at: indexToRemove) - } - - // then we add the dependency on LAMBDA_USE_LOCAL_DEPS' path (typically ../..) - print("[INFO] Compiling against swift-aws-lambda-runtime located at \(localDepsPath)") - package.dependencies += [ - .package(name: "swift-aws-lambda-runtime", path: localDepsPath) - ] -} diff --git a/Examples/HelloJSON/Package.swift b/Examples/HelloJSON/Package.swift index b8b75c58..37466648 100644 --- a/Examples/HelloJSON/Package.swift +++ b/Examples/HelloJSON/Package.swift @@ -2,9 +2,6 @@ import PackageDescription -// needed for CI to test the local version of the library -import struct Foundation.URL - let package = Package( name: "swift-aws-lambda-runtime-example", platforms: [.macOS(.v15)], @@ -12,11 +9,11 @@ let package = Package( .executable(name: "HelloJSON", targets: ["HelloJSON"]) ], dependencies: [ - // during CI, the dependency on local version of swift-aws-lambda-runtime is added dynamically below - .package( - url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", - from: "2.0.0" - ) + // For local development (default) + .package(name: "swift-aws-lambda-runtime", path: "../..") + + // For standalone usage, comment the line above and uncomment below: + // .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "1.0.0"), ], targets: [ .executableTarget( @@ -27,30 +24,3 @@ let package = Package( ) ] ) - -if let localDepsPath = Context.environment["LAMBDA_USE_LOCAL_DEPS"], - localDepsPath != "", - let v = try? URL(fileURLWithPath: localDepsPath).resourceValues(forKeys: [.isDirectoryKey]), - v.isDirectory == true -{ - // when we use the local runtime as deps, let's remove the dependency added above - let indexToRemove = package.dependencies.firstIndex { dependency in - if case .sourceControl( - name: _, - location: "https://github.com/awslabs/swift-aws-lambda-runtime.git", - requirement: _ - ) = dependency.kind { - return true - } - return false - } - if let indexToRemove { - package.dependencies.remove(at: indexToRemove) - } - - // then we add the dependency on LAMBDA_USE_LOCAL_DEPS' path (typically ../..) - print("[INFO] Compiling against swift-aws-lambda-runtime located at \(localDepsPath)") - package.dependencies += [ - .package(name: "swift-aws-lambda-runtime", path: localDepsPath) - ] -} diff --git a/Examples/HelloWorld/Package.swift b/Examples/HelloWorld/Package.swift index eca1e6ca..07d45f83 100644 --- a/Examples/HelloWorld/Package.swift +++ b/Examples/HelloWorld/Package.swift @@ -2,9 +2,6 @@ import PackageDescription -// needed for CI to test the local version of the library -import struct Foundation.URL - let package = Package( name: "swift-aws-lambda-runtime-example", platforms: [.macOS(.v15)], @@ -12,8 +9,11 @@ let package = Package( .executable(name: "MyLambda", targets: ["MyLambda"]) ], dependencies: [ - // during CI, the dependency on local version of swift-aws-lambda-runtime is added dynamically below - .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "2.0.0") + // For local development (default) + .package(name: "swift-aws-lambda-runtime", path: "../..") + + // For standalone usage, comment the line above and uncomment below: + // .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "1.0.0"), ], targets: [ .executableTarget( @@ -25,30 +25,3 @@ let package = Package( ) ] ) - -if let localDepsPath = Context.environment["LAMBDA_USE_LOCAL_DEPS"], - localDepsPath != "", - let v = try? URL(fileURLWithPath: localDepsPath).resourceValues(forKeys: [.isDirectoryKey]), - v.isDirectory == true -{ - // when we use the local runtime as deps, let's remove the dependency added above - let indexToRemove = package.dependencies.firstIndex { dependency in - if case .sourceControl( - name: _, - location: "https://github.com/awslabs/swift-aws-lambda-runtime.git", - requirement: _ - ) = dependency.kind { - return true - } - return false - } - if let indexToRemove { - package.dependencies.remove(at: indexToRemove) - } - - // then we add the dependency on LAMBDA_USE_LOCAL_DEPS' path (typically ../..) - print("[INFO] Compiling against swift-aws-lambda-runtime located at \(localDepsPath)") - package.dependencies += [ - .package(name: "swift-aws-lambda-runtime", path: localDepsPath) - ] -} diff --git a/Examples/HelloWorldNoTraits/Package.swift b/Examples/HelloWorldNoTraits/Package.swift index 37d8e8d6..07d45f83 100644 --- a/Examples/HelloWorldNoTraits/Package.swift +++ b/Examples/HelloWorldNoTraits/Package.swift @@ -2,9 +2,6 @@ import PackageDescription -// needed for CI to test the local version of the library -import struct Foundation.URL - let package = Package( name: "swift-aws-lambda-runtime-example", platforms: [.macOS(.v15)], @@ -12,8 +9,11 @@ let package = Package( .executable(name: "MyLambda", targets: ["MyLambda"]) ], dependencies: [ - // during CI, the dependency on local version of swift-aws-lambda-runtime is added dynamically below - .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "2.0.0", traits: []) + // For local development (default) + .package(name: "swift-aws-lambda-runtime", path: "../..") + + // For standalone usage, comment the line above and uncomment below: + // .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "1.0.0"), ], targets: [ .executableTarget( @@ -25,30 +25,3 @@ let package = Package( ) ] ) - -if let localDepsPath = Context.environment["LAMBDA_USE_LOCAL_DEPS"], - localDepsPath != "", - let v = try? URL(fileURLWithPath: localDepsPath).resourceValues(forKeys: [.isDirectoryKey]), - v.isDirectory == true -{ - // when we use the local runtime as deps, let's remove the dependency added above - let indexToRemove = package.dependencies.firstIndex { dependency in - if case .sourceControl( - name: _, - location: "https://github.com/awslabs/swift-aws-lambda-runtime.git", - requirement: _ - ) = dependency.kind { - return true - } - return false - } - if let indexToRemove { - package.dependencies.remove(at: indexToRemove) - } - - // then we add the dependency on LAMBDA_USE_LOCAL_DEPS' path (typically ../..) - print("[INFO] Compiling against swift-aws-lambda-runtime located at \(localDepsPath)") - package.dependencies += [ - .package(name: "swift-aws-lambda-runtime", path: localDepsPath, traits: []) - ] -} diff --git a/Examples/HummingbirdLambda/Package.swift b/Examples/HummingbirdLambda/Package.swift index 879d448a..776db88f 100644 --- a/Examples/HummingbirdLambda/Package.swift +++ b/Examples/HummingbirdLambda/Package.swift @@ -3,17 +3,16 @@ import PackageDescription -// needed for CI to test the local version of the library -import struct Foundation.URL - let package = Package( name: "HBLambda", platforms: [.macOS(.v15)], dependencies: [ - .package( - url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", - from: "2.0.0" - ), + // For local development (default) + .package(name: "swift-aws-lambda-runtime", path: "../.."), + + // For standalone usage, comment the line above and uncomment below: + // .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "1.0.0"), + .package( url: "https://github.com/hummingbird-project/hummingbird-lambda.git", branch: "main" @@ -30,30 +29,3 @@ let package = Package( ) ] ) - -if let localDepsPath = Context.environment["LAMBDA_USE_LOCAL_DEPS"], - localDepsPath != "", - let v = try? URL(fileURLWithPath: localDepsPath).resourceValues(forKeys: [.isDirectoryKey]), - v.isDirectory == true -{ - // when we use the local runtime as deps, let's remove the dependency added above - let indexToRemove = package.dependencies.firstIndex { dependency in - if case .sourceControl( - name: _, - location: "https://github.com/awslabs/swift-aws-lambda-runtime.git", - requirement: _ - ) = dependency.kind { - return true - } - return false - } - if let indexToRemove { - package.dependencies.remove(at: indexToRemove) - } - - // then we add the dependency on LAMBDA_USE_LOCAL_DEPS' path (typically ../..) - print("[INFO] Compiling against swift-aws-lambda-runtime located at \(localDepsPath)") - package.dependencies += [ - .package(name: "swift-aws-lambda-runtime", path: localDepsPath) - ] -} diff --git a/Examples/MultiSourceAPI/Package.swift b/Examples/MultiSourceAPI/Package.swift index 83ec9e02..5661777e 100644 --- a/Examples/MultiSourceAPI/Package.swift +++ b/Examples/MultiSourceAPI/Package.swift @@ -2,9 +2,6 @@ import PackageDescription -// needed for CI to test the local version of the library -import struct Foundation.URL - let package = Package( name: "MultiSourceAPI", platforms: [.macOS(.v15)], @@ -12,7 +9,12 @@ let package = Package( .executable(name: "MultiSourceAPI", targets: ["MultiSourceAPI"]) ], dependencies: [ - .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "2.0.0"), + // For local development (default) + .package(name: "swift-aws-lambda-runtime", path: "../.."), + + // For standalone usage, comment the line above and uncomment below: + // .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "1.0.0"), + .package(url: "https://github.com/awslabs/swift-aws-lambda-events.git", from: "1.0.0"), ], targets: [ @@ -26,30 +28,3 @@ let package = Package( ) ] ) - -if let localDepsPath = Context.environment["LAMBDA_USE_LOCAL_DEPS"], - localDepsPath != "", - let v = try? URL(fileURLWithPath: localDepsPath).resourceValues(forKeys: [.isDirectoryKey]), - v.isDirectory == true -{ - let indexToRemove = package.dependencies.firstIndex { dependency in - switch dependency.kind { - case .sourceControl( - name: _, - location: "https://github.com/awslabs/swift-aws-lambda-runtime.git", - requirement: _ - ): - return true - default: - return false - } - } - if let indexToRemove { - package.dependencies.remove(at: indexToRemove) - } - - print("[INFO] Compiling against swift-aws-lambda-runtime located at \(localDepsPath)") - package.dependencies += [ - .package(name: "swift-aws-lambda-runtime", path: localDepsPath) - ] -} diff --git a/Examples/MultiTenant/Package.swift b/Examples/MultiTenant/Package.swift index c22dd399..6051738f 100644 --- a/Examples/MultiTenant/Package.swift +++ b/Examples/MultiTenant/Package.swift @@ -2,9 +2,6 @@ import PackageDescription -// needed for CI to test the local version of the library -import struct Foundation.URL - let package = Package( name: "swift-aws-lambda-runtime-example", platforms: [.macOS(.v15)], @@ -12,8 +9,12 @@ let package = Package( .executable(name: "MultiTenant", targets: ["MultiTenant"]) ], dependencies: [ - // during CI, the dependency on local version of swift-aws-lambda-runtime is added dynamically below - .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "2.0.0"), + // For local development (default) + .package(name: "swift-aws-lambda-runtime", path: "../.."), + + // For standalone usage, comment the line above and uncomment below: + // .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "1.0.0"), + .package(url: "https://github.com/awslabs/swift-aws-lambda-events.git", from: "1.0.0"), ], targets: [ @@ -26,30 +27,3 @@ let package = Package( ) ] ) - -if let localDepsPath = Context.environment["LAMBDA_USE_LOCAL_DEPS"], - localDepsPath != "", - let v = try? URL(fileURLWithPath: localDepsPath).resourceValues(forKeys: [.isDirectoryKey]), - v.isDirectory == true -{ - // when we use the local runtime as deps, let's remove the dependency added above - let indexToRemove = package.dependencies.firstIndex { dependency in - if case .sourceControl( - name: _, - location: "https://github.com/awslabs/swift-aws-lambda-runtime.git", - requirement: _ - ) = dependency.kind { - return true - } - return false - } - if let indexToRemove { - package.dependencies.remove(at: indexToRemove) - } - - // then we add the dependency on LAMBDA_USE_LOCAL_DEPS' path (typically ../..) - print("[INFO] Compiling against swift-aws-lambda-runtime located at \(localDepsPath)") - package.dependencies += [ - .package(name: "swift-aws-lambda-runtime", path: localDepsPath) - ] -} diff --git a/Examples/ResourcesPackaging/Package.swift b/Examples/ResourcesPackaging/Package.swift index 7f99b5bd..5972e9dc 100644 --- a/Examples/ResourcesPackaging/Package.swift +++ b/Examples/ResourcesPackaging/Package.swift @@ -2,9 +2,6 @@ import PackageDescription -// needed for CI to test the local version of the library -import struct Foundation.URL - let package = Package( name: "ResourcesPackaging", platforms: [.macOS(.v15)], @@ -12,7 +9,11 @@ let package = Package( .executable(name: "MyLambda", targets: ["MyLambda"]) ], dependencies: [ - .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "2.0.0") + // For local development (default) + .package(name: "swift-aws-lambda-runtime", path: "../..") + + // For standalone usage, comment the line above and uncomment below: + // .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "1.0.0"), ], targets: [ .executableTarget( @@ -27,30 +28,3 @@ let package = Package( ) ] ) - -if let localDepsPath = Context.environment["LAMBDA_USE_LOCAL_DEPS"], - localDepsPath != "", - let v = try? URL(fileURLWithPath: localDepsPath).resourceValues(forKeys: [.isDirectoryKey]), - v.isDirectory == true -{ - // when we use the local runtime as deps, let's remove the dependency added above - let indexToRemove = package.dependencies.firstIndex { dependency in - if case .sourceControl( - name: _, - location: "https://github.com/awslabs/swift-aws-lambda-runtime.git", - requirement: _ - ) = dependency.kind { - return true - } - return false - } - if let indexToRemove { - package.dependencies.remove(at: indexToRemove) - } - - // then we add the dependency on LAMBDA_USE_LOCAL_DEPS' path (typically ../..) - print("[INFO] Compiling against swift-aws-lambda-runtime located at \(localDepsPath)") - package.dependencies += [ - .package(name: "swift-aws-lambda-runtime", path: localDepsPath) - ] -} diff --git a/Examples/S3EventNotifier/Package.swift b/Examples/S3EventNotifier/Package.swift index 59eee0f4..f2d81b75 100644 --- a/Examples/S3EventNotifier/Package.swift +++ b/Examples/S3EventNotifier/Package.swift @@ -1,15 +1,17 @@ // swift-tools-version: 6.2 import PackageDescription -// needed for CI to test the local version of the library -import struct Foundation.URL - let package = Package( name: "S3EventNotifier", platforms: [.macOS(.v15)], dependencies: [ - .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "2.0.0"), - .package(url: "https://github.com/awslabs/swift-aws-lambda-events", from: "1.0.0"), + // For local development (default) + .package(name: "swift-aws-lambda-runtime", path: "../.."), + + // For standalone usage, comment the line above and uncomment below: + // .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "1.0.0"), + + .package(url: "https://github.com/awslabs/swift-aws-lambda-events.git", from: "1.0.0"), ], targets: [ .executableTarget( @@ -21,30 +23,3 @@ let package = Package( ) ] ) - -if let localDepsPath = Context.environment["LAMBDA_USE_LOCAL_DEPS"], - localDepsPath != "", - let v = try? URL(fileURLWithPath: localDepsPath).resourceValues(forKeys: [.isDirectoryKey]), - v.isDirectory == true -{ - // when we use the local runtime as deps, let's remove the dependency added above - let indexToRemove = package.dependencies.firstIndex { dependency in - if case .sourceControl( - name: _, - location: "https://github.com/awslabs/swift-aws-lambda-runtime.git", - requirement: _ - ) = dependency.kind { - return true - } - return false - } - if let indexToRemove { - package.dependencies.remove(at: indexToRemove) - } - - // then we add the dependency on LAMBDA_USE_LOCAL_DEPS' path (typically ../..) - print("[INFO] Compiling against swift-aws-lambda-runtime located at \(localDepsPath)") - package.dependencies += [ - .package(name: "swift-aws-lambda-runtime", path: localDepsPath) - ] -} diff --git a/Examples/S3_AWSSDK/Package.swift b/Examples/S3_AWSSDK/Package.swift index 68a73153..f04ee235 100644 --- a/Examples/S3_AWSSDK/Package.swift +++ b/Examples/S3_AWSSDK/Package.swift @@ -2,9 +2,6 @@ import PackageDescription -// needed for CI to test the local version of the library -import struct Foundation.URL - let package = Package( name: "AWSSDKExample", platforms: [.macOS(.v15)], @@ -12,9 +9,13 @@ let package = Package( .executable(name: "AWSSDKExample", targets: ["AWSSDKExample"]) ], dependencies: [ - // during CI, the dependency on local version of swift-aws-lambda-runtime is added dynamically below - .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "2.0.0"), - .package(url: "https://github.com/awslabs/swift-aws-lambda-events", from: "1.0.0"), + // For local development (default) + .package(name: "swift-aws-lambda-runtime", path: "../.."), + + // For standalone usage, comment the line above and uncomment below: + // .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "1.0.0"), + + .package(url: "https://github.com/awslabs/swift-aws-lambda-events.git", from: "1.0.0"), .package(url: "https://github.com/awslabs/aws-sdk-swift", from: "1.0.0"), ], targets: [ @@ -28,30 +29,3 @@ let package = Package( ) ] ) - -if let localDepsPath = Context.environment["LAMBDA_USE_LOCAL_DEPS"], - localDepsPath != "", - let v = try? URL(fileURLWithPath: localDepsPath).resourceValues(forKeys: [.isDirectoryKey]), - v.isDirectory == true -{ - // when we use the local runtime as deps, let's remove the dependency added above - let indexToRemove = package.dependencies.firstIndex { dependency in - if case .sourceControl( - name: _, - location: "https://github.com/awslabs/swift-aws-lambda-runtime.git", - requirement: _ - ) = dependency.kind { - return true - } - return false - } - if let indexToRemove { - package.dependencies.remove(at: indexToRemove) - } - - // then we add the dependency on LAMBDA_USE_LOCAL_DEPS' path (typically ../..) - print("[INFO] Compiling against swift-aws-lambda-runtime located at \(localDepsPath)") - package.dependencies += [ - .package(name: "swift-aws-lambda-runtime", path: localDepsPath) - ] -} diff --git a/Examples/S3_Soto/Package.swift b/Examples/S3_Soto/Package.swift index eb06b915..c9d23760 100644 --- a/Examples/S3_Soto/Package.swift +++ b/Examples/S3_Soto/Package.swift @@ -2,9 +2,6 @@ import PackageDescription -// needed for CI to test the local version of the library -import struct Foundation.URL - let package = Package( name: "SotoExample", platforms: [.macOS(.v15)], @@ -12,11 +9,14 @@ let package = Package( .executable(name: "SotoExample", targets: ["SotoExample"]) ], dependencies: [ - .package(url: "https://github.com/soto-project/soto.git", from: "7.0.0"), + // For local development (default) + .package(name: "swift-aws-lambda-runtime", path: "../.."), - // during CI, the dependency on local version of swift-aws-lambda-runtime is added dynamically below - .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "2.0.0"), - .package(url: "https://github.com/awslabs/swift-aws-lambda-events", from: "1.0.0"), + // For standalone usage, comment the line above and uncomment below: + // .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "1.0.0"), + + .package(url: "https://github.com/awslabs/swift-aws-lambda-events.git", from: "1.0.0"), + .package(url: "https://github.com/soto-project/soto.git", from: "7.0.0"), ], targets: [ .executableTarget( @@ -29,30 +29,3 @@ let package = Package( ) ] ) - -if let localDepsPath = Context.environment["LAMBDA_USE_LOCAL_DEPS"], - localDepsPath != "", - let v = try? URL(fileURLWithPath: localDepsPath).resourceValues(forKeys: [.isDirectoryKey]), - v.isDirectory == true -{ - // when we use the local runtime as deps, let's remove the dependency added above - let indexToRemove = package.dependencies.firstIndex { dependency in - if case .sourceControl( - name: _, - location: "https://github.com/awslabs/swift-aws-lambda-runtime.git", - requirement: _ - ) = dependency.kind { - return true - } - return false - } - if let indexToRemove { - package.dependencies.remove(at: indexToRemove) - } - - // then we add the dependency on LAMBDA_USE_LOCAL_DEPS' path (typically ../..) - print("[INFO] Compiling against swift-aws-lambda-runtime located at \(localDepsPath)") - package.dependencies += [ - .package(name: "swift-aws-lambda-runtime", path: localDepsPath) - ] -} diff --git a/Examples/ServiceLifecycle+Postgres/Package.swift b/Examples/ServiceLifecycle+Postgres/Package.swift index aeea0613..de3ef51e 100644 --- a/Examples/ServiceLifecycle+Postgres/Package.swift +++ b/Examples/ServiceLifecycle+Postgres/Package.swift @@ -3,18 +3,20 @@ import PackageDescription -// needed for CI to test the local version of the library -import struct Foundation.URL - let package = Package( name: "LambdaWithServiceLifecycle", platforms: [ .macOS(.v15) ], dependencies: [ - .package(url: "https://github.com/vapor/postgres-nio.git", from: "1.26.0"), - .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "2.0.0"), + // For local development (default) + .package(name: "swift-aws-lambda-runtime", path: "../.."), + + // For standalone usage, comment the line above and uncomment below: + // .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "1.0.0"), + .package(url: "https://github.com/awslabs/swift-aws-lambda-events.git", from: "1.0.0"), + .package(url: "https://github.com/vapor/postgres-nio.git", from: "1.26.0"), .package(url: "https://github.com/swift-server/swift-service-lifecycle.git", from: "2.6.3"), ], targets: [ @@ -29,30 +31,3 @@ let package = Package( ) ] ) - -if let localDepsPath = Context.environment["LAMBDA_USE_LOCAL_DEPS"], - localDepsPath != "", - let v = try? URL(fileURLWithPath: localDepsPath).resourceValues(forKeys: [.isDirectoryKey]), - v.isDirectory == true -{ - // when we use the local runtime as deps, let's remove the dependency added above - let indexToRemove = package.dependencies.firstIndex { dependency in - if case .sourceControl( - name: _, - location: "https://github.com/awslabs/swift-aws-lambda-runtime.git", - requirement: _ - ) = dependency.kind { - return true - } - return false - } - if let indexToRemove { - package.dependencies.remove(at: indexToRemove) - } - - // then we add the dependency on LAMBDA_USE_LOCAL_DEPS' path (typically ../..) - print("[INFO] Compiling against swift-aws-lambda-runtime located at \(localDepsPath)") - package.dependencies += [ - .package(name: "swift-aws-lambda-runtime", path: localDepsPath) - ] -} diff --git a/Examples/Streaming+Codable/Package.swift b/Examples/Streaming+Codable/Package.swift index 77e2f45b..7e6fdf2a 100644 --- a/Examples/Streaming+Codable/Package.swift +++ b/Examples/Streaming+Codable/Package.swift @@ -2,16 +2,17 @@ import PackageDescription -// needed for CI to test the local version of the library -import struct Foundation.URL - let package = Package( name: "StreamingCodable", platforms: [.macOS(.v15)], dependencies: [ - // during CI, the dependency on local version of swift-aws-lambda-runtime is added dynamically below - .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "2.0.0"), - .package(url: "https://github.com/awslabs/swift-aws-lambda-events.git", from: "1.2.0"), + // For local development (default) + .package(name: "swift-aws-lambda-runtime", path: "../.."), + + // For standalone usage, comment the line above and uncomment below: + // .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "1.0.0"), + + .package(url: "https://github.com/awslabs/swift-aws-lambda-events.git", from: "1.0.0"), ], targets: [ .executableTarget( @@ -30,30 +31,3 @@ let package = Package( ), ] ) - -if let localDepsPath = Context.environment["LAMBDA_USE_LOCAL_DEPS"], - localDepsPath != "", - let v = try? URL(fileURLWithPath: localDepsPath).resourceValues(forKeys: [.isDirectoryKey]), - v.isDirectory == true -{ - // when we use the local runtime as deps, let's remove the dependency added above - let indexToRemove = package.dependencies.firstIndex { dependency in - if case .sourceControl( - name: _, - location: "https://github.com/awslabs/swift-aws-lambda-runtime.git", - requirement: _ - ) = dependency.kind { - return true - } - return false - } - if let indexToRemove { - package.dependencies.remove(at: indexToRemove) - } - - // then we add the dependency on LAMBDA_USE_LOCAL_DEPS' path (typically ../..) - print("[INFO] Compiling against swift-aws-lambda-runtime located at \(localDepsPath)") - package.dependencies += [ - .package(name: "swift-aws-lambda-runtime", path: localDepsPath) - ] -} diff --git a/Examples/Streaming/Package.swift b/Examples/Streaming/Package.swift index 49bb3373..267668a9 100644 --- a/Examples/Streaming/Package.swift +++ b/Examples/Streaming/Package.swift @@ -2,9 +2,6 @@ import PackageDescription -// needed for CI to test the local version of the library -import struct Foundation.URL - let package = Package( name: "swift-aws-lambda-runtime-example", platforms: [.macOS(.v15)], @@ -12,8 +9,11 @@ let package = Package( .executable(name: "StreamingNumbers", targets: ["StreamingNumbers"]) ], dependencies: [ - // during CI, the dependency on local version of swift-aws-lambda-runtime is added dynamically below - .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "2.0.0") + // For local development (default) + .package(name: "swift-aws-lambda-runtime", path: "../..") + + // For standalone usage, comment the line above and uncomment below: + // .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "1.0.0"), ], targets: [ .executableTarget( @@ -25,30 +25,3 @@ let package = Package( ) ] ) - -if let localDepsPath = Context.environment["LAMBDA_USE_LOCAL_DEPS"], - localDepsPath != "", - let v = try? URL(fileURLWithPath: localDepsPath).resourceValues(forKeys: [.isDirectoryKey]), - v.isDirectory == true -{ - // when we use the local runtime as deps, let's remove the dependency added above - let indexToRemove = package.dependencies.firstIndex { dependency in - if case .sourceControl( - name: _, - location: "https://github.com/awslabs/swift-aws-lambda-runtime.git", - requirement: _ - ) = dependency.kind { - return true - } - return false - } - if let indexToRemove { - package.dependencies.remove(at: indexToRemove) - } - - // then we add the dependency on LAMBDA_USE_LOCAL_DEPS' path (typically ../..) - print("[INFO] Compiling against swift-aws-lambda-runtime located at \(localDepsPath)") - package.dependencies += [ - .package(name: "swift-aws-lambda-runtime", path: localDepsPath) - ] -} diff --git a/Examples/Testing/Package.swift b/Examples/Testing/Package.swift index 62734553..02445450 100644 --- a/Examples/Testing/Package.swift +++ b/Examples/Testing/Package.swift @@ -2,9 +2,6 @@ import PackageDescription -// needed for CI to test the local version of the library -import struct Foundation.URL - let package = Package( name: "swift-aws-lambda-runtime-example", platforms: [.macOS(.v15)], @@ -12,8 +9,12 @@ let package = Package( .executable(name: "APIGatewayLambda", targets: ["APIGatewayLambda"]) ], dependencies: [ - // during CI, the dependency on local version of swift-aws-lambda-runtime is added dynamically below - .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "2.0.0"), + // For local development (default) + .package(name: "swift-aws-lambda-runtime", path: "../.."), + + // For standalone usage, comment the line above and uncomment below: + // .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "1.0.0"), + .package(url: "https://github.com/awslabs/swift-aws-lambda-events.git", from: "1.0.0"), ], targets: [ @@ -35,30 +36,3 @@ let package = Package( ), ] ) - -if let localDepsPath = Context.environment["LAMBDA_USE_LOCAL_DEPS"], - localDepsPath != "", - let v = try? URL(fileURLWithPath: localDepsPath).resourceValues(forKeys: [.isDirectoryKey]), - v.isDirectory == true -{ - // when we use the local runtime as deps, let's remove the dependency added above - let indexToRemove = package.dependencies.firstIndex { dependency in - if case .sourceControl( - name: _, - location: "https://github.com/awslabs/swift-aws-lambda-runtime.git", - requirement: _ - ) = dependency.kind { - return true - } - return false - } - if let indexToRemove { - package.dependencies.remove(at: indexToRemove) - } - - // then we add the dependency on LAMBDA_USE_LOCAL_DEPS' path (typically ../..) - print("[INFO] Compiling against swift-aws-lambda-runtime located at \(localDepsPath)") - package.dependencies += [ - .package(name: "swift-aws-lambda-runtime", path: localDepsPath) - ] -} diff --git a/Examples/Tutorial/Package.swift b/Examples/Tutorial/Package.swift index 357db119..ab875419 100644 --- a/Examples/Tutorial/Package.swift +++ b/Examples/Tutorial/Package.swift @@ -3,13 +3,15 @@ import PackageDescription -import struct Foundation.URL - let package = Package( name: "Palindrome", platforms: [.macOS(.v15)], dependencies: [ - .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "2.0.0") + // For local development (default) + .package(name: "swift-aws-lambda-runtime", path: "../..") + + // For standalone usage, comment the line above and uncomment below: + // .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "1.0.0"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. @@ -22,30 +24,3 @@ let package = Package( ) ] ) - -if let localDepsPath = Context.environment["LAMBDA_USE_LOCAL_DEPS"], - localDepsPath != "", - let v = try? URL(fileURLWithPath: localDepsPath).resourceValues(forKeys: [.isDirectoryKey]), - v.isDirectory == true -{ - // when we use the local runtime as deps, let's remove the dependency added above - let indexToRemove = package.dependencies.firstIndex { dependency in - if case .sourceControl( - name: _, - location: "https://github.com/awslabs/swift-aws-lambda-runtime.git", - requirement: _ - ) = dependency.kind { - return true - } - return false - } - if let indexToRemove { - package.dependencies.remove(at: indexToRemove) - } - - // then we add the dependency on LAMBDA_USE_LOCAL_DEPS' path (typically ../..) - print("[INFO] Compiling against swift-aws-lambda-runtime located at \(localDepsPath)") - package.dependencies += [ - .package(name: "swift-aws-lambda-runtime", path: localDepsPath) - ] -} diff --git a/scripts/local_performance_test.sh b/scripts/local_performance_test.sh index 36029d0a..10fa6a93 100755 --- a/scripts/local_performance_test.sh +++ b/scripts/local_performance_test.sh @@ -41,8 +41,8 @@ fi echo "🏗️ Building library and test functions" swift build -c release -Xswiftc -g -LAMBDA_USE_LOCAL_DEPS=../.. swift build --package-path Examples/HelloWorld -c release -Xswiftc -g -LAMBDA_USE_LOCAL_DEPS=../.. swift build --package-path Examples/HelloJSON -c release -Xswiftc -g +swift build --package-path Examples/HelloWorld -c release -Xswiftc -g +swift build --package-path Examples/HelloJSON -c release -Xswiftc -g cleanup() { pkill -9 MockServer && echo "killed previous mock server" # ignore-unacceptable-language diff --git a/scripts/ubuntu-test-plugin.sh b/scripts/ubuntu-test-plugin.sh index 51bf79ac..8c69bf9c 100644 --- a/scripts/ubuntu-test-plugin.sh +++ b/scripts/ubuntu-test-plugin.sh @@ -26,4 +26,4 @@ git clone https://github.com/awslabs/swift-aws-lambda-runtime.git # build the project cd swift-aws-lambda-runtime/Examples/ResourcesPackaging/ || exit 1 -LAMBDA_USE_LOCAL_DEPS=../.. swift package archive --allow-network-connections docker +swift package archive --allow-network-connections docker