Skip to content

Commit

Permalink
Adopt Swift Testing and 6.0 for CI. (#42)
Browse files Browse the repository at this point in the history
Adopt Swift Testing and 6.0 for CI.
  • Loading branch information
tachyonics authored Sep 18, 2024
1 parent 3591a84 commit 6329f26
Show file tree
Hide file tree
Showing 14 changed files with 700 additions and 606 deletions.
30 changes: 7 additions & 23 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,21 @@ on:

jobs:
LatestVersionBuild:
name: Swift ${{ matrix.swift }} on ${{ matrix.os }}
name: Image ${{ matrix.image }}
strategy:
matrix:
os: [ubuntu-22.04, ubuntu-20.04]
swift: ["5.10"]
runs-on: ${{ matrix.os }}
image: ["swift:6.0.0-noble", "swift:6.0.0-jammy"]
runs-on: ubuntu-latest
container:
image: ${{ matrix.image }}
steps:
- uses: swift-actions/setup-swift@v2.1.0
with:
swift-version: ${{ matrix.swift }}
- name: Install libssl-dev
run: apt-get update && apt-get install -y libssl-dev
- uses: actions/checkout@v4
- name: Build
run: swift build -c release -Xswiftc -strict-concurrency=complete
- name: Run tests
run: swift test
OlderVersionBuild:
name: Swift ${{ matrix.swift }} on ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
swift: ["5.9"]
runs-on: ${{ matrix.os }}
steps:
- uses: swift-actions/setup-swift@v2.1.0
with:
swift-version: ${{ matrix.swift }}
- uses: actions/checkout@v4
- name: Build
run: swift build -c release
- name: Run tests
run: swift test
SwiftLint:
name: SwiftLint version 3.2.1
runs-on: ubuntu-latest
Expand Down
8 changes: 4 additions & 4 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/awslabs/aws-sdk-swift.git",
"state" : {
"revision" : "629d1c7f08b2e8026dd2779ca16a1871e5d2fecf",
"version" : "0.77.0"
"revision" : "828358a2c39d138325b0f87a2d813f4b972e5f4f",
"version" : "1.0.0"
}
},
{
Expand All @@ -32,8 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/smithy-lang/smithy-swift",
"state" : {
"revision" : "9115a71bacee15f7cc6f567c34b7a16e66d4626e",
"version" : "0.70.0"
"revision" : "0ed3440f8c41e27a0937364d5035d2d4fefb8aa3",
"version" : "0.71.0"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ let package = Package(
targets: ["DynamoDBTables"]),
],
dependencies: [
.package(url: "https://github.com/awslabs/aws-sdk-swift.git", from: "0.45.0"),
.package(url: "https://github.com/awslabs/aws-sdk-swift.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-metrics.git", "1.0.0"..<"3.0.0"),
.package(url: "https://github.com/JohnSundell/CollectionConcurrencyKit", from :"0.2.0"),
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
<img src="https://github.com/swift-server-community/dynamo-db-tables/actions/workflows/swift.yml/badge.svg?branch=main" alt="Build - Main Branch">
</a>
<a href="http://swift.org">
<img src="https://img.shields.io/badge/swift-5.9|5.10-orange.svg?style=flat" alt="Swift 5.9 and 5.10 Tested">
<img src="https://img.shields.io/badge/swift-6.0-orange.svg?style=flat" alt="Swift 6.0 Compatible and Tested">
</a>
<img src="https://img.shields.io/badge/ubuntu-20.04|22.04-yellow.svg?style=flat" alt="Ubuntu 20.04 and 22.04 Tested">
<img src="https://img.shields.io/badge/ubuntu-22.04|24.04-yellow.svg?style=flat" alt="Ubuntu 22.04 and 24.04 Tested">
<img src="https://img.shields.io/badge/license-Apache2-blue.svg?style=flat" alt="Apache 2">
</p>

DynamoDBTables is a library to make it easy to use DynamoDB from Swift-based applications, with a particular focus on usage with polymorphic database tables (tables that don't have a single schema for all rows.
DynamoDBTables is a library to make it easy to use DynamoDB from Swift-based applications, with a particular focus on usage with polymorphic database tables (tables that don't have a single schema for all rows).

DynamoDBTables is a fork of https://github.com/amzn/smoke-dynamodb and acknowledges the authors of that original package.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@

@testable import DynamoDBTables
import Foundation
import XCTest
import Testing

class DynamoDBCompositePrimaryKeyTableClobberVersionedItemWithHistoricalRowTests: XCTestCase {
func testClobberVersionedItemWithHistoricalRow() async throws {
struct DynamoDBCompositePrimaryKeyTableClobberVersionedItemWithHistoricalRowTests {
@Test
func clobberVersionedItemWithHistoricalRow() async throws {
let payload1 = TestTypeA(firstly: "firstly", secondly: "secondly")
let partitionKey = "partitionId"
let historicalPartitionPrefix = "historical"
Expand All @@ -51,16 +52,16 @@ class DynamoDBCompositePrimaryKeyTableClobberVersionedItemWithHistoricalRowTests
// the v0 row, copy of version 1
let key1 = StandardCompositePrimaryKey(partitionKey: partitionKey, sortKey: generateSortKey(withVersion: 0))
let item1: StandardTypedDatabaseItem<RowWithItemVersion<TestTypeA>> = try await table.getItem(forKey: key1)!
XCTAssertEqual(1, item1.rowValue.itemVersion)
XCTAssertEqual(1, item1.rowStatus.rowVersion)
XCTAssertEqual(payload1, item1.rowValue.rowValue)
#expect(1 == item1.rowValue.itemVersion)
#expect(1 == item1.rowStatus.rowVersion)
#expect(payload1 == item1.rowValue.rowValue)

// the v1 row, has version 1
let key2 = StandardCompositePrimaryKey(partitionKey: historicalPartitionKey, sortKey: generateSortKey(withVersion: 1))
let item2: StandardTypedDatabaseItem<RowWithItemVersion<TestTypeA>> = try await table.getItem(forKey: key2)!
XCTAssertEqual(1, item2.rowValue.itemVersion)
XCTAssertEqual(1, item2.rowStatus.rowVersion)
XCTAssertEqual(payload1, item2.rowValue.rowValue)
#expect(1 == item2.rowValue.itemVersion)
#expect(1 == item2.rowStatus.rowVersion)
#expect(payload1 == item2.rowValue.rowValue)

let payload2 = TestTypeA(firstly: "thirdly", secondly: "fourthly")

Expand All @@ -73,22 +74,22 @@ class DynamoDBCompositePrimaryKeyTableClobberVersionedItemWithHistoricalRowTests
// the v0 row, copy of version 2
let key3 = StandardCompositePrimaryKey(partitionKey: partitionKey, sortKey: generateSortKey(withVersion: 0))
let item3: StandardTypedDatabaseItem<RowWithItemVersion<TestTypeA>> = try await table.getItem(forKey: key3)!
XCTAssertEqual(2, item3.rowValue.itemVersion)
XCTAssertEqual(2, item3.rowStatus.rowVersion)
XCTAssertEqual(payload2, item3.rowValue.rowValue)
#expect(2 == item3.rowValue.itemVersion)
#expect(2 == item3.rowStatus.rowVersion)
#expect(payload2 == item3.rowValue.rowValue)

// the v1 row, still has version 1
let key4 = StandardCompositePrimaryKey(partitionKey: historicalPartitionKey, sortKey: generateSortKey(withVersion: 1))
let item4: StandardTypedDatabaseItem<RowWithItemVersion<TestTypeA>> = try await table.getItem(forKey: key4)!
XCTAssertEqual(1, item4.rowValue.itemVersion)
XCTAssertEqual(1, item4.rowStatus.rowVersion)
XCTAssertEqual(payload1, item4.rowValue.rowValue)
#expect(1 == item4.rowValue.itemVersion)
#expect(1 == item4.rowStatus.rowVersion)
#expect(payload1 == item4.rowValue.rowValue)

// the v2 row, has version 2
let key5 = StandardCompositePrimaryKey(partitionKey: historicalPartitionKey, sortKey: generateSortKey(withVersion: 2))
let item5: StandardTypedDatabaseItem<RowWithItemVersion<TestTypeA>> = try await table.getItem(forKey: key5)!
XCTAssertEqual(2, item5.rowValue.itemVersion)
XCTAssertEqual(1, item5.rowStatus.rowVersion)
XCTAssertEqual(payload2, item5.rowValue.rowValue)
#expect(2 == item5.rowValue.itemVersion)
#expect(1 == item5.rowStatus.rowVersion)
#expect(payload2 == item5.rowValue.rowValue)
}
}
Loading

0 comments on commit 6329f26

Please sign in to comment.