Skip to content
Snippets Groups Projects
Commit 16480177 authored by Dariusz Rybicki's avatar Dariusz Rybicki
Browse files

Merge branch 'development' into 'main'

Release v1.2.0

See merge request elixxir/client-ios-db!30
parents f8e3e008 6859ec34
Branches main
Tags v1.2.0
1 merge request!30Release v1.2.0
Pipeline #166843 passed
Showing
with 139 additions and 156 deletions
before_script:
- for ip in $(dig @8.8.8.8 github.com +short); do ssh-keyscan github.com,$ip; ssh-keyscan $ip; done 2>/dev/null >> ~/.ssh/known_hosts
- for ip in $(dig @8.8.8.8 git.xx.network +short); do ssh-keyscan git.xx.network,$ip; ssh-keyscan $ip; done 2>/dev/null >> ~/.ssh/known_hosts
- swift --version
- xcodebuild -version
stages:
- test
test-package-macos:
stage: test
tags:
- ios
script:
- ./run-tests.sh macos
retry: 1
test-package-ios:
stage: test
tags:
- ios
script:
- ./run-tests.sh ios
retry: 1
......@@ -5,8 +5,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/groue/GRDB.swift",
"state" : {
"revision" : "fead2ea634c1bf7dd81a3e02f796154992165ffd",
"version" : "5.24.0"
"revision" : "0ac435744a4c67c4ec23a4a671c0d53ce1fee7c6",
"version" : "6.0.0"
}
},
{
......@@ -14,8 +14,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-custom-dump.git",
"state" : {
"revision" : "c4f78db9b90ca57b7b6abc2223e235242739ea3c",
"version" : "0.4.0"
"revision" : "c9b6b940d95c0a925c63f6858943415714d8a981",
"version" : "0.5.2"
}
},
{
......@@ -23,8 +23,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-snapshot-testing.git",
"state" : {
"revision" : "f8a9c997c3c1dab4e216a8ec9014e23144cbab37",
"version" : "1.9.0"
"revision" : "f29e2014f6230cf7d5138fc899da51c7f513d467",
"version" : "1.10.0"
}
},
{
......@@ -32,8 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/xctest-dynamic-overlay",
"state" : {
"revision" : "50a70a9d3583fe228ce672e8923010c8df2deddd",
"version" : "0.2.1"
"revision" : "30314f1ece684dd60679d598a9b89107557b67d9",
"version" : "0.4.1"
}
}
],
......
// swift-tools-version: 5.6
// swift-tools-version: 5.7
import PackageDescription
let swiftSettings: [SwiftSetting] = [
// Uncomment to measure compilation time:
//.unsafeFlags(
// [
// "-Xfrontend",
// "-debug-time-function-bodies",
// "-Xfrontend",
// "-debug-time-expression-type-checking",
// ],
// .when(configuration: .debug)
//),
//.unsafeFlags(["-Xfrontend", "-warn-concurrency"], .when(configuration: .debug)),
//.unsafeFlags(["-Xfrontend", "-debug-time-function-bodies"], .when(configuration: .debug)),
//.unsafeFlags(["-Xfrontend", "-debug-time-expression-type-checking"], .when(configuration: .debug)),
]
let package = Package(
......@@ -21,77 +14,47 @@ let package = Package(
.macOS(.v12),
],
products: [
.library(
name: "XXModels",
targets: ["XXModels"]
),
.library(
name: "XXLegacyDatabaseMigrator",
targets: ["XXLegacyDatabaseMigrator"]
),
.library(
name: "XXDatabase",
targets: ["XXDatabase"]
),
.library(name: "XXModels", targets: ["XXModels"]),
.library(name: "XXLegacyDatabaseMigrator", targets: ["XXLegacyDatabaseMigrator"]),
.library(name: "XXDatabase", targets: ["XXDatabase"]),
],
dependencies: [
.package(
url: "https://github.com/groue/GRDB.swift",
.upToNextMajor(from: "5.24.0")
),
.package(
url: "https://github.com/pointfreeco/swift-custom-dump.git",
.upToNextMajor(from: "0.4.0")
),
.package(
url: "https://github.com/pointfreeco/swift-snapshot-testing.git",
.upToNextMajor(from: "1.9.0")
),
.package(url: "https://github.com/groue/GRDB.swift", .upToNextMajor(from: "6.0.0")),
.package(url: "https://github.com/pointfreeco/swift-custom-dump.git", .upToNextMajor(from: "0.5.2")),
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing.git", .upToNextMajor(from: "1.10.0")),
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay.git", .upToNextMajor(from: "0.4.1")),
],
targets: [
.target(
name: "XXModels",
dependencies: [
.product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay"),
],
swiftSettings: swiftSettings
),
.testTarget(
name: "XXModelsTests",
dependencies: [
.target(
name: "XXModels"
),
.target(name: "XXModels"),
],
swiftSettings: swiftSettings
),
.target(
name: "XXLegacyDatabaseMigrator",
dependencies: [
.target(
name: "XXDatabase"
),
.target(
name: "XXModels"
),
.product(
name: "GRDB",
package: "GRDB.swift"
),
.target(name: "XXDatabase"),
.target(name: "XXModels"),
.product(name: "GRDB", package: "GRDB.swift"),
.product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay"),
],
swiftSettings: swiftSettings
),
.testTarget(
name: "XXLegacyDatabaseMigratorTests",
dependencies: [
.target(
name: "XXLegacyDatabaseMigrator"
),
.product(
name: "CustomDump",
package: "swift-custom-dump"
),
.product(
name: "SnapshotTesting",
package: "swift-snapshot-testing"
),
.target(name: "XXLegacyDatabaseMigrator"),
.product(name: "CustomDump", package: "swift-custom-dump"),
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
],
exclude: [
"__Snapshots__",
......@@ -107,26 +70,16 @@ let package = Package(
.target(
name: "XXDatabase",
dependencies: [
.target(
name: "XXModels"
),
.product(
name: "GRDB",
package: "GRDB.swift"
),
.target(name: "XXModels"),
.product(name: "GRDB", package: "GRDB.swift"),
],
swiftSettings: swiftSettings
),
.testTarget(
name: "XXDatabaseTests",
dependencies: [
.target(
name: "XXDatabase"
),
.product(
name: "CustomDump",
package: "swift-custom-dump"
),
.target(name: "XXDatabase"),
.product(name: "CustomDump", package: "swift-custom-dump"),
],
swiftSettings: swiftSettings
),
......
# xx-client-ios-db
![Swift 5.6](https://img.shields.io/badge/swift-5.6-orange.svg)
![Swift 5.7](https://img.shields.io/badge/swift-5.7-orange.svg)
![platform iOS macOS](https://img.shields.io/badge/platform-iOS_macOS-blue.svg)
Database layer for xx Messenger iOS app.
## 🛠 Development
Open `Package.swift` in Xcode (≥13).
Open `Package.swift` in Xcode (≥14).
### Package structure
......
......@@ -119,9 +119,7 @@ extension Message: FetchableRecord, MutablePersistableRecord {
return columnAssignments
}
public mutating func didInsert(with rowID: Int64, for column: String?) {
if column == Column.id.rawValue {
id = rowID
}
public mutating func didInsert(_ inserted: InsertionSuccess) {
id = inserted.rowID
}
}
......@@ -37,9 +37,7 @@ extension Contact: FetchableRecord, MutablePersistableRecord {
static let databaseTableName = "contacts"
mutating func didInsert(with rowID: Int64, for column: String?) {
if column == Column.id.rawValue {
id = rowID
}
mutating func didInsert(_ inserted: InsertionSuccess) {
id = inserted.rowID
}
}
......@@ -17,9 +17,7 @@ extension FileTransfer: FetchableRecord, MutablePersistableRecord {
static let databaseTableName = "transfers"
mutating func didInsert(with rowID: Int64, for column: String?) {
if column == Column.id.rawValue {
id = rowID
}
mutating func didInsert(_ inserted: InsertionSuccess) {
id = inserted.rowID
}
}
......@@ -25,9 +25,7 @@ extension Group: FetchableRecord, MutablePersistableRecord {
static let databaseTableName = "groups"
mutating func didInsert(with rowID: Int64, for column: String?) {
if column == Column.id.rawValue {
id = rowID
}
mutating func didInsert(_ inserted: InsertionSuccess) {
id = inserted.rowID
}
}
......@@ -20,9 +20,7 @@ extension GroupMember: FetchableRecord, MutablePersistableRecord {
case id, photo, status, userId, groupId, username
}
mutating func didInsert(with rowID: Int64, for column: String?) {
if column == Column.id.rawValue {
id = rowID
}
mutating func didInsert(_ inserted: InsertionSuccess) {
id = inserted.rowID
}
}
......@@ -30,9 +30,7 @@ extension GroupMessage: FetchableRecord, MutablePersistableRecord {
static let databaseTableName = "groupMessages"
mutating func didInsert(with rowID: Int64, for column: String?) {
if column == Column.id.rawValue {
id = rowID
}
mutating func didInsert(_ inserted: InsertionSuccess) {
id = inserted.rowID
}
}
......@@ -33,9 +33,7 @@ extension Message: FetchableRecord, MutablePersistableRecord {
static let databaseTableName = "messages"
mutating func didInsert(with rowID: Int64, for column: String?) {
if column == Column.id.rawValue {
id = rowID
}
mutating func didInsert(_ inserted: InsertionSuccess) {
id = inserted.rowID
}
}
......@@ -70,7 +70,11 @@ extension Migrator {
}
#if DEBUG
import XCTestDynamicOverlay
extension Migrator {
public static let failing = Migrator { _, _, _, _ in fatalError() }
public static let unimplemented = Migrator(
run: XCTUnimplemented("\(Self.self)")
)
}
#endif
......@@ -177,37 +177,37 @@ public struct Database {
#if DEBUG
extension Database {
static public let failing = Database(
fetchChatInfos: .failing(),
fetchChatInfosPublisher: .failing(),
fetchContacts: .failing(),
fetchContactsPublisher: .failing(),
saveContact: .failing(),
bulkUpdateContacts: .failing(),
deleteContact: .failing(),
fetchContactChatInfos: .failing(),
fetchContactChatInfosPublisher: .failing(),
fetchGroups: .failing(),
fetchGroupsPublisher: .failing(),
saveGroup: .failing(),
deleteGroup: .failing(),
fetchGroupChatInfos: .failing(),
fetchGroupChatInfosPublisher: .failing(),
fetchGroupInfos: .failing(),
fetchGroupInfosPublisher: .failing(),
saveGroupMember: .failing(),
deleteGroupMember: .failing(),
fetchMessages: .failing(),
fetchMessagesPublisher: .failing(),
saveMessage: .failing(),
bulkUpdateMessages: .failing(),
deleteMessage: .failing(),
deleteMessages: .failing(),
fetchFileTransfers: .failing(),
fetchFileTransfersPublisher: .failing(),
saveFileTransfer: .failing(),
deleteFileTransfer: .failing(),
drop: .failing
static public let unimplemented = Database(
fetchChatInfos: .unimplemented(),
fetchChatInfosPublisher: .unimplemented(),
fetchContacts: .unimplemented(),
fetchContactsPublisher: .unimplemented(),
saveContact: .unimplemented(),
bulkUpdateContacts: .unimplemented(),
deleteContact: .unimplemented(),
fetchContactChatInfos: .unimplemented(),
fetchContactChatInfosPublisher: .unimplemented(),
fetchGroups: .unimplemented(),
fetchGroupsPublisher: .unimplemented(),
saveGroup: .unimplemented(),
deleteGroup: .unimplemented(),
fetchGroupChatInfos: .unimplemented(),
fetchGroupChatInfosPublisher: .unimplemented(),
fetchGroupInfos: .unimplemented(),
fetchGroupInfosPublisher: .unimplemented(),
saveGroupMember: .unimplemented(),
deleteGroupMember: .unimplemented(),
fetchMessages: .unimplemented(),
fetchMessagesPublisher: .unimplemented(),
saveMessage: .unimplemented(),
bulkUpdateMessages: .unimplemented(),
deleteMessage: .unimplemented(),
deleteMessages: .unimplemented(),
fetchFileTransfers: .unimplemented(),
fetchFileTransfersPublisher: .unimplemented(),
saveFileTransfer: .unimplemented(),
deleteFileTransfer: .unimplemented(),
drop: .unimplemented
)
}
#endif
......@@ -22,9 +22,11 @@ public struct BulkUpdate<Query, Assignments> {
}
#if DEBUG
import XCTestDynamicOverlay
extension BulkUpdate {
public static func failing<Query, Assignments>() -> BulkUpdate<Query, Assignments> {
BulkUpdate<Query, Assignments> { _, _ in fatalError() }
public static func unimplemented<Query, Assignments>() -> BulkUpdate<Query, Assignments> {
BulkUpdate<Query, Assignments>(run: XCTUnimplemented("\(Self.self)"))
}
}
#endif
......@@ -22,9 +22,11 @@ public struct Delete<Model> {
}
#if DEBUG
import XCTestDynamicOverlay
extension Delete {
public static func failing<Model>() -> Delete<Model> {
Delete<Model> { _ in fatalError() }
public static func unimplemented<Model>() -> Delete<Model> {
Delete<Model>(run: XCTUnimplemented("\(Self.self)"))
}
}
#endif
......@@ -21,9 +21,11 @@ public struct DeleteMany<Model, Query> {
}
#if DEBUG
import XCTestDynamicOverlay
extension DeleteMany {
public static func failing<Model, Query>() -> DeleteMany<Model, Query> {
DeleteMany<Model, Query> { _ in fatalError() }
public static func unimplemented<Model>() -> DeleteMany<Model, Query> {
DeleteMany<Model, Query>(run: XCTUnimplemented("\(Self.self)"))
}
}
#endif
......@@ -20,7 +20,9 @@ public struct Drop {
}
#if DEBUG
import XCTestDynamicOverlay
extension Drop {
public static let failing = Drop { fatalError() }
public static let unimplemented = Drop(run: XCTUnimplemented("\(Self.self)"))
}
#endif
......@@ -22,9 +22,11 @@ public struct Fetch<Model, Query> {
}
#if DEBUG
import XCTestDynamicOverlay
extension Fetch {
public static func failing<Model, Query>() -> Fetch<Model, Query> {
Fetch<Model, Query> { _ in fatalError() }
public static func unimplemented<Model, Query>() -> Fetch<Model, Query> {
Fetch<Model, Query>(run: XCTUnimplemented("\(Self.self)"))
}
}
#endif
......@@ -23,9 +23,13 @@ public struct FetchPublisher<Model, Query> {
}
#if DEBUG
import XCTestDynamicOverlay
extension FetchPublisher {
public static func failing<Model, Query>() -> FetchPublisher<Model, Query> {
FetchPublisher<Model, Query> { _ in fatalError() }
public static func unimplemented<Model, Query>() -> FetchPublisher<Model, Query> {
FetchPublisher<Model, Query>(
run: XCTUnimplemented("\(Self.self)", placeholder: Empty().eraseToAnyPublisher())
)
}
}
#endif
......@@ -25,9 +25,11 @@ public struct Save<Model> {
}
#if DEBUG
import XCTestDynamicOverlay
extension Save {
public static func failing<Model>() -> Save<Model> {
Save<Model> { _ in fatalError() }
public static func unimplemented<Model>() -> Save<Model> {
Save<Model>(run: XCTUnimplemented("\(Self.self)"))
}
}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment