Skip to content

Update SDK to Swift 6 #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
Jul 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
steps:
- uses: swift-actions/setup-swift@v2
with:
swift-version: "5.7.3"
swift-version: '6.1.2'
- name: Get swift version
run: swift --version
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/swift-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
matrix:
image:
- swift:5.10.1
- swift:6.1.2
services:
localstack:
image: localstack/localstack
Expand Down
4 changes: 4 additions & 0 deletions .spi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version: 1
builder:
configs:
- documentation_targets: [BreezeLambdaAPI, BreezeDynamoDBService]
Binary file added Images/Icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,35 @@ composer_down:
localstack:
docker run -it --rm -p "4566:4566" localstack/localstack

local_setup_dynamo_db:
aws --endpoint-url=http://localhost:4566 dynamodb create-table \
--table-name Breeze \
--attribute-definitions AttributeName=itemKey,AttributeType=S \
--key-schema AttributeName=itemKey,KeyType=HASH \
--billing-mode PAY_PER_REQUEST
--region us-east-1

local_invoke_demo_app:
curl -X POST 127.0.0.1:7000/invoke -H "Content-Type: application/json" -d @Tests/BreezeLambdaAPITests/Fixtures/post_products_api_gtw.json

test:
swift test --sanitize=thread --enable-code-coverage

generate_docc:
mkdir -p docs && \
swift package --allow-writing-to-directory docs/BreezeLambdaAPI generate-documentation \
--target BreezeLambdaAPI \
--disable-indexing \
--transform-for-static-hosting \
--hosting-base-path "https://swift-serverless.github.io/BreezeLambdaDynamoDBAPI/BreezeLambdaAPI/" \
--output-path docs/BreezeLambdaAPI && \
swift package --allow-writing-to-directory docs/BreezeDynamoDBService generate-documentation \
--target BreezeDynamoDBService \
--disable-indexing \
--transform-for-static-hosting \
--hosting-base-path "https://swift-serverless.github.io/BreezeLambdaDynamoDBAPI/BreezeDynamoDBService/" \
--output-path docs/BreezeDynamoDBService

coverage:
llvm-cov export $(TEST_PACKAGE) \
--instr-profile=$(SWIFT_BIN_PATH)/codecov/default.profdata \
Expand Down
51 changes: 37 additions & 14 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// swift-tools-version: 5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.
// swift-tools-version: 6.0

import PackageDescription

#if os(macOS)
let platforms: [PackageDescription.SupportedPlatform]? = [.macOS(.v15)]
#else
let platforms: [PackageDescription.SupportedPlatform]? = nil
#endif

let package = Package(
name: "BreezeLambdaDynamoDBAPI",
platforms: [
.macOS(.v13),
],
platforms: platforms,
products: [
.library(
name: "BreezeDynamoDBService",
Expand All @@ -16,43 +19,63 @@ let package = Package(
.library(
name: "BreezeLambdaAPI",
targets: ["BreezeLambdaAPI"]
),
.executable(
name: "BreezeLambdaItemAPI",
targets: ["BreezeLambdaItemAPI"]
)
],
dependencies: [
.package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0-alpha.2"),
.package(url: "https://github.com/swift-server/swift-aws-lambda-events.git", from: "0.1.0"),
.package(url: "https://github.com/soto-project/soto.git", from: "6.7.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
.package(url: "https://github.com/swift-serverless/swift-sls-adapter", from: "0.2.1"),
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.11.2"),
// TODO: change to upstream once the upstream is tagged
.package(url: "https://github.com/andrea-scuderi/swift-aws-lambda-runtime.git", branch: "main"),
.package(url: "https://github.com/swift-server/swift-aws-lambda-events.git", from: "0.5.0"),
.package(url: "https://github.com/swift-server/swift-service-lifecycle.git", from: "2.0.0"),
.package(url: "https://github.com/soto-project/soto.git", from: "7.0.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.6.2"),
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
],
targets: [
.executableTarget(
name: "BreezeLambdaItemAPI",
dependencies: [
"BreezeLambdaAPI"
]
),
.target(
name: "BreezeDynamoDBService",
dependencies: [
.product(name: "SotoDynamoDB", package: "soto"),
.product(name: "Logging", package: "swift-log")
.product(name: "ServiceLifecycle", package: "swift-service-lifecycle"),
.product(name: "Logging", package: "swift-log"),
]
),
.target(
name: "BreezeLambdaAPI",
dependencies: [
.product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime"),
.product(name: "AWSLambdaEvents", package: "swift-aws-lambda-events"),
.product(name: "ServiceLifecycle", package: "swift-service-lifecycle"),
"BreezeDynamoDBService"
]
),
.testTarget(
name: "BreezeLambdaAPITests",
dependencies: [
.product(name: "AWSLambdaTesting", package: "swift-aws-lambda-runtime"),
.product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime"),
.product(name: "ServiceLifecycle", package: "swift-service-lifecycle"),
.product(name: "ServiceLifecycleTestKit", package: "swift-service-lifecycle"),
"BreezeLambdaAPI"
],
resources: [.copy("Fixtures")]
),
.testTarget(
name: "BreezeDynamoDBServiceTests",
dependencies: ["BreezeDynamoDBService"]
dependencies: [
.product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime"),
.product(name: "ServiceLifecycle", package: "swift-service-lifecycle"),
.product(name: "ServiceLifecycleTestKit", package: "swift-service-lifecycle"),
"BreezeDynamoDBService"
]
)
]
)
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,16 @@ extension Item: BreezeCodable { }
Add the implementation of the Lambda to the file `swift.main`

```swift
BreezeLambdaAPI<Item>.main()
@main
struct BreezeLambdaItemAPI {
static func main() async throws {
do {
try await BreezeLambdaAPI<Item>().run()
} catch {
print(error.localizedDescription)
}
}
}
```

## Documentation
Expand Down
19 changes: 17 additions & 2 deletions Sources/BreezeDynamoDBService/BreezeCodable.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 (c) Andrea Scuderi - https://github.com/swift-serverless
// Copyright 2024 (c) Andrea Scuderi - https://github.com/swift-serverless
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -12,9 +12,24 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

public protocol BreezeCodable: Codable {
/// CodableSendable is a protocol that combines Sendable and Codable.
public protocol CodableSendable: Sendable, Codable { }

/// BreezeCodable is a protocol that extends CodableSendable to include properties
/// for a key, creation date, and update date.
/// It is designed to be used with Breeze services that require these common fields
/// for items stored in a database, such as DynamoDB.
/// - Parameters:
/// - key: A unique identifier for the item.
/// - createdAt: An optional string representing the creation date of the item.
/// - updatedAt: An optional string representing the last update date of the item.
public protocol BreezeCodable: CodableSendable {
var key: String { get set }
var createdAt: String? { get set }
var updatedAt: String? { get set }
Expand Down
50 changes: 50 additions & 0 deletions Sources/BreezeDynamoDBService/BreezeDynamoDBConfig.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright 2024 (c) Andrea Scuderi - https://github.com/swift-serverless
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import SotoCore

/// BreezeDynamoDBConfig is a configuration structure for Breeze DynamoDB service.
/// It contains the necessary parameters to connect to a DynamoDB instance, including the region, table name, key name, and an optional endpoint.
public struct BreezeDynamoDBConfig: Sendable {

/// Initializes a new instance of BreezeDynamoDBConfig.
/// - Parameters:
/// - region: The AWS region where the DynamoDB table is located.
/// - tableName: The name of the DynamoDB table.
/// - keyName: The name of the primary key in the DynamoDB table.
/// - endpoint: An optional endpoint URL for the DynamoDB service. If not provided, the default AWS endpoint will be used.
public init(
region: Region,
tableName: String,
keyName: String,
endpoint: String? = nil
) {
self.region = region
self.tableName = tableName
self.keyName = keyName
self.endpoint = endpoint
}

/// The AWS region where the DynamoDB table is located.
public let region: Region

/// The name of the DynamoDB table.
public let tableName: String

/// The name of the primary key in the DynamoDB table.
public let keyName: String

/// An optional endpoint URL for the DynamoDB service.
public let endpoint: String?
}
Loading