From c86cc0ed9c7b5ac4c07cae9f19ca28a0377c9bdd Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Thu, 13 Jul 2023 17:57:08 +1000 Subject: [PATCH] CI tweaks and incremented build number Added the XCBeautify pod (so the CI doesn't need to separately install something) Updated the CI build script to use XCBeautify Fixed some broken unit tests --- .drone.jsonnet | 24 ++-------- Podfile | 3 ++ Podfile.lock | 7 ++- Session.xcodeproj/project.pbxproj | 12 ++--- SessionMessagingKit/Configuration.swift | 7 +-- .../Open Groups/OpenGroupAPISpec.swift | 6 +-- .../Open Groups/OpenGroupManagerSpec.swift | 6 +-- .../MessageReceiverDecryptionSpec.swift | 6 +-- .../MessageSenderEncryptionSpec.swift | 6 +-- SessionSnodeKit/Configuration.swift | 5 ++- ...eadDisappearingMessagesViewModelSpec.swift | 10 ++--- .../ThreadSettingsViewModelSpec.swift | 10 ++--- .../NotificationContentViewModelSpec.swift | 10 ++--- SessionUIKit/Configuration.swift | 5 ++- SessionUtilitiesKit/Configuration.swift | 5 ++- SessionUtilitiesKit/Database/Storage.swift | 45 ++++++++++++------- .../Database/Types/TargetMigrations.swift | 5 +++ .../Database/Models/IdentitySpec.swift | 4 +- .../PersistableRecordUtilitiesSpec.swift | 20 ++++++--- SignalUtilitiesKit/Utilities/AppSetup.swift | 10 ++--- 20 files changed, 113 insertions(+), 93 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index b18251c5a..f6b9eb6d4 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -71,13 +71,7 @@ local update_cocoapods_cache = { name: 'Run Unit Tests', commands: [ 'mkdir build', - ||| - if command -v xcpretty >/dev/null 2>&1; then - xcodebuild test -workspace Session.xcworkspace -scheme Session -destination "platform=iOS Simulator,name=iPhone 14 Pro" | xcpretty - else - xcodebuild test -workspace Session.xcworkspace -scheme Session -destination "platform=iOS Simulator,name=iPhone 14 Pro" - fi - ||| + 'NSUnbufferedIO=YES set -o pipefail && xcodebuild test -workspace Session.xcworkspace -scheme Session -destination "platform=iOS Simulator,name=iPhone 14 Pro" -maximum-test-execution-time-allowance 2 -collect-test-diagnostics never 2>&1 | ./Pods/xcbeautify/xcbeautify' ], }, update_cocoapods_cache @@ -97,13 +91,7 @@ local update_cocoapods_cache = { name: 'Build', commands: [ 'mkdir build', - ||| - if command -v xcpretty >/dev/null 2>&1; then - xcodebuild archive -workspace Session.xcworkspace -scheme Session -configuration 'App Store Release' -sdk iphonesimulator -archivePath ./build/Session_sim.xcarchive -destination "generic/platform=iOS Simulator" | xcpretty - else - xcodebuild archive -workspace Session.xcworkspace -scheme Session -configuration 'App Store Release' -sdk iphonesimulator -archivePath ./build/Session_sim.xcarchive -destination "generic/platform=iOS Simulator" - fi - ||| + 'xcodebuild archive -workspace Session.xcworkspace -scheme Session -configuration 'App Store Release' -sdk iphonesimulator -archivePath ./build/Session_sim.xcarchive -destination "generic/platform=iOS Simulator" | ./Pods/xcbeautify/xcbeautify' ], }, update_cocoapods_cache, @@ -129,13 +117,7 @@ local update_cocoapods_cache = { name: 'Build', commands: [ 'mkdir build', - ||| - if command -v xcpretty >/dev/null 2>&1; then - xcodebuild archive -workspace Session.xcworkspace -scheme Session -configuration 'App Store Release' -sdk iphoneos -archivePath ./build/Session.xcarchive -destination "generic/platform=iOS" -allowProvisioningUpdates | xcpretty - else - xcodebuild archive -workspace Session.xcworkspace -scheme Session -configuration 'App Store Release' -sdk iphoneos -archivePath ./build/Session.xcarchive -destination "generic/platform=iOS" -allowProvisioningUpdates - fi - ||| + 'xcodebuild archive -workspace Session.xcworkspace -scheme Session -configuration 'App Store Release' -sdk iphoneos -archivePath ./build/Session.xcarchive -destination "generic/platform=iOS" -allowProvisioningUpdates | ./Pods/xcbeautify/xcbeautify' ], }, update_cocoapods_cache, diff --git a/Podfile b/Podfile index 69fbc174f..201db8853 100644 --- a/Podfile +++ b/Podfile @@ -5,6 +5,9 @@ inhibit_all_warnings! install! 'cocoapods', :warn_for_unused_master_specs_repo => false +# CI Dependencies +pod 'xcbeautify' + # Dependencies to be included in the app and all extensions/frameworks abstract_target 'GlobalDependencies' do # FIXME: If https://github.com/jedisct1/swift-sodium/pull/249 gets resolved then revert this back to the standard pod diff --git a/Podfile.lock b/Podfile.lock index a2e1e4dae..4a101f497 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -42,6 +42,7 @@ PODS: - SQLCipher/common - SwiftProtobuf (1.5.0) - WebRTC-lib (114.0.0) + - xcbeautify (0.17.0) - YapDatabase/SQLCipher (3.1.1): - YapDatabase/SQLCipher/Core (= 3.1.1) - YapDatabase/SQLCipher/Extensions (= 3.1.1) @@ -124,6 +125,7 @@ DEPENDENCIES: - SQLCipher (~> 4.5.3) - SwiftProtobuf (~> 1.5.0) - WebRTC-lib + - xcbeautify - YapDatabase/SQLCipher (from `https://github.com/oxen-io/session-ios-yap-database.git`, branch `signal-release`) - YYImage/libwebp (from `https://github.com/signalapp/YYImage`) @@ -143,6 +145,8 @@ SPEC REPOS: - SQLCipher - SwiftProtobuf - WebRTC-lib + trunk: + - xcbeautify EXTERNAL SOURCES: Curve25519Kit: @@ -195,9 +199,10 @@ SPEC CHECKSUMS: SQLCipher: 57fa9f863fa4a3ed9dd3c90ace52315db8c0fdca SwiftProtobuf: 241400280f912735c1e1b9fe675fdd2c6c4d42e2 WebRTC-lib: d83df8976fa608b980f1d85796b3de66d60a1953 + xcbeautify: 6e2f57af5c3a86d490376d5758030a8dcc201c1b YapDatabase: b418a4baa6906e8028748938f9159807fd039af4 YYImage: f1ddd15ac032a58b78bbed1e012b50302d318331 -PODFILE CHECKSUM: f56c28baefe3077effcb3a2ea5941b52c4cc6e86 +PODFILE CHECKSUM: dd814a5a92577bb2a94dac6a1cc482f193721cdf COCOAPODS: 1.12.1 diff --git a/Session.xcodeproj/project.pbxproj b/Session.xcodeproj/project.pbxproj index 927af5747..8dd26fc33 100644 --- a/Session.xcodeproj/project.pbxproj +++ b/Session.xcodeproj/project.pbxproj @@ -6366,7 +6366,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 418; + CURRENT_PROJECT_VERSION = 419; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; @@ -6438,7 +6438,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 418; + CURRENT_PROJECT_VERSION = 419; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = SUQ8J2PCT7; ENABLE_NS_ASSERTIONS = NO; @@ -6503,7 +6503,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 418; + CURRENT_PROJECT_VERSION = 419; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; @@ -6577,7 +6577,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 418; + CURRENT_PROJECT_VERSION = 419; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = SUQ8J2PCT7; ENABLE_NS_ASSERTIONS = NO; @@ -7537,7 +7537,7 @@ CODE_SIGN_ENTITLEMENTS = Session/Meta/Signal.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 418; + CURRENT_PROJECT_VERSION = 419; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -7608,7 +7608,7 @@ CODE_SIGN_ENTITLEMENTS = Session/Meta/Signal.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 418; + CURRENT_PROJECT_VERSION = 419; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", diff --git a/SessionMessagingKit/Configuration.swift b/SessionMessagingKit/Configuration.swift index c6d92487c..384aa7249 100644 --- a/SessionMessagingKit/Configuration.swift +++ b/SessionMessagingKit/Configuration.swift @@ -1,8 +1,9 @@ import Foundation +import GRDB import SessionUtilitiesKit -public enum SNMessagingKit { // Just to make the external API nice - public static func migrations() -> TargetMigrations { +public enum SNMessagingKit: MigratableTarget { // Just to make the external API nice + public static func migrations(_ db: Database) -> TargetMigrations { return TargetMigrations( identifier: .messagingKit, migrations: [ @@ -33,7 +34,7 @@ public enum SNMessagingKit { // Just to make the external API nice // Wait until the feature is turned on before doing the migration that generates // the config dump data // FIXME: Remove this once `useSharedUtilForUserConfig` is permanent - (Features.useSharedUtilForUserConfig() ? + (Features.useSharedUtilForUserConfig(db) ? _014_GenerateInitialUserConfigDumps.self : (nil as Migration.Type?) ) diff --git a/SessionMessagingKitTests/Open Groups/OpenGroupAPISpec.swift b/SessionMessagingKitTests/Open Groups/OpenGroupAPISpec.swift index c74bf5c2c..d87bfdca3 100644 --- a/SessionMessagingKitTests/Open Groups/OpenGroupAPISpec.swift +++ b/SessionMessagingKitTests/Open Groups/OpenGroupAPISpec.swift @@ -37,9 +37,9 @@ class OpenGroupAPISpec: QuickSpec { beforeEach { mockStorage = Storage( customWriter: try! DatabaseQueue(), - customMigrations: [ - SNUtilitiesKit.migrations(), - SNMessagingKit.migrations() + customMigrationTargets: [ + SNUtilitiesKit.self, + SNMessagingKit.self ] ) mockSodium = MockSodium() diff --git a/SessionMessagingKitTests/Open Groups/OpenGroupManagerSpec.swift b/SessionMessagingKitTests/Open Groups/OpenGroupManagerSpec.swift index cfc807596..5386c3207 100644 --- a/SessionMessagingKitTests/Open Groups/OpenGroupManagerSpec.swift +++ b/SessionMessagingKitTests/Open Groups/OpenGroupManagerSpec.swift @@ -103,9 +103,9 @@ class OpenGroupManagerSpec: QuickSpec { mockGeneralCache = MockGeneralCache() mockStorage = Storage( customWriter: try! DatabaseQueue(), - customMigrations: [ - SNUtilitiesKit.migrations(), - SNMessagingKit.migrations() + customMigrationTargets: [ + SNUtilitiesKit.self, + SNMessagingKit.self ] ) mockSodium = MockSodium() diff --git a/SessionMessagingKitTests/Sending & Receiving/MessageReceiverDecryptionSpec.swift b/SessionMessagingKitTests/Sending & Receiving/MessageReceiverDecryptionSpec.swift index b9066ba26..7f9a45a13 100644 --- a/SessionMessagingKitTests/Sending & Receiving/MessageReceiverDecryptionSpec.swift +++ b/SessionMessagingKitTests/Sending & Receiving/MessageReceiverDecryptionSpec.swift @@ -27,9 +27,9 @@ class MessageReceiverDecryptionSpec: QuickSpec { beforeEach { mockStorage = Storage( customWriter: try! DatabaseQueue(), - customMigrations: [ - SNUtilitiesKit.migrations(), - SNMessagingKit.migrations() + customMigrationTargets: [ + SNUtilitiesKit.self, + SNMessagingKit.self ] ) mockSodium = MockSodium() diff --git a/SessionMessagingKitTests/Sending & Receiving/MessageSenderEncryptionSpec.swift b/SessionMessagingKitTests/Sending & Receiving/MessageSenderEncryptionSpec.swift index 6334229a1..f937b3744 100644 --- a/SessionMessagingKitTests/Sending & Receiving/MessageSenderEncryptionSpec.swift +++ b/SessionMessagingKitTests/Sending & Receiving/MessageSenderEncryptionSpec.swift @@ -24,9 +24,9 @@ class MessageSenderEncryptionSpec: QuickSpec { beforeEach { mockStorage = Storage( customWriter: try! DatabaseQueue(), - customMigrations: [ - SNUtilitiesKit.migrations(), - SNMessagingKit.migrations() + customMigrationTargets: [ + SNUtilitiesKit.self, + SNMessagingKit.self ] ) mockBox = MockBox() diff --git a/SessionSnodeKit/Configuration.swift b/SessionSnodeKit/Configuration.swift index dcf685839..7f8a597d4 100644 --- a/SessionSnodeKit/Configuration.swift +++ b/SessionSnodeKit/Configuration.swift @@ -1,10 +1,11 @@ // Copyright © 2022 Rangeproof Pty Ltd. All rights reserved. import Foundation +import GRDB import SessionUtilitiesKit -public enum SNSnodeKit { // Just to make the external API nice - public static func migrations() -> TargetMigrations { +public enum SNSnodeKit: MigratableTarget { // Just to make the external API nice + public static func migrations(_ db: Database) -> TargetMigrations { return TargetMigrations( identifier: .snodeKit, migrations: [ diff --git a/SessionTests/Conversations/Settings/ThreadDisappearingMessagesViewModelSpec.swift b/SessionTests/Conversations/Settings/ThreadDisappearingMessagesViewModelSpec.swift index 89d8453f7..0a9dfcf21 100644 --- a/SessionTests/Conversations/Settings/ThreadDisappearingMessagesViewModelSpec.swift +++ b/SessionTests/Conversations/Settings/ThreadDisappearingMessagesViewModelSpec.swift @@ -26,11 +26,11 @@ class ThreadDisappearingMessagesSettingsViewModelSpec: QuickSpec { beforeEach { mockStorage = Storage( customWriter: try! DatabaseQueue(), - customMigrations: [ - SNUtilitiesKit.migrations(), - SNSnodeKit.migrations(), - SNMessagingKit.migrations(), - SNUIKit.migrations() + customMigrationTargets: [ + SNUtilitiesKit.self, + SNSnodeKit.self, + SNMessagingKit.self, + SNUIKit.self ] ) dependencies = Dependencies( diff --git a/SessionTests/Conversations/Settings/ThreadSettingsViewModelSpec.swift b/SessionTests/Conversations/Settings/ThreadSettingsViewModelSpec.swift index eaf4b915b..60ed929db 100644 --- a/SessionTests/Conversations/Settings/ThreadSettingsViewModelSpec.swift +++ b/SessionTests/Conversations/Settings/ThreadSettingsViewModelSpec.swift @@ -28,11 +28,11 @@ class ThreadSettingsViewModelSpec: QuickSpec { beforeEach { mockStorage = SynchronousStorage( customWriter: try! DatabaseQueue(), - customMigrations: [ - SNUtilitiesKit.migrations(), - SNSnodeKit.migrations(), - SNMessagingKit.migrations(), - SNUIKit.migrations() + customMigrationTargets: [ + SNUtilitiesKit.self, + SNSnodeKit.self, + SNMessagingKit.self, + SNUIKit.self ] ) mockGeneralCache = MockGeneralCache() diff --git a/SessionTests/Settings/NotificationContentViewModelSpec.swift b/SessionTests/Settings/NotificationContentViewModelSpec.swift index 81a838f15..e6d1e5999 100644 --- a/SessionTests/Settings/NotificationContentViewModelSpec.swift +++ b/SessionTests/Settings/NotificationContentViewModelSpec.swift @@ -25,11 +25,11 @@ class NotificationContentViewModelSpec: QuickSpec { beforeEach { mockStorage = Storage( customWriter: try! DatabaseQueue(), - customMigrations: [ - SNUtilitiesKit.migrations(), - SNSnodeKit.migrations(), - SNMessagingKit.migrations(), - SNUIKit.migrations() + customMigrationTargets: [ + SNUtilitiesKit.self, + SNSnodeKit.self, + SNMessagingKit.self, + SNUIKit.self ] ) viewModel = NotificationContentViewModel(storage: mockStorage, scheduling: .immediate) diff --git a/SessionUIKit/Configuration.swift b/SessionUIKit/Configuration.swift index d305968e9..798ba98eb 100644 --- a/SessionUIKit/Configuration.swift +++ b/SessionUIKit/Configuration.swift @@ -1,10 +1,11 @@ // Copyright © 2022 Rangeproof Pty Ltd. All rights reserved. import Foundation +import GRDB import SessionUtilitiesKit -public enum SNUIKit { - public static func migrations() -> TargetMigrations { +public enum SNUIKit: MigratableTarget { + public static func migrations(_ db: Database) -> TargetMigrations { return TargetMigrations( identifier: .uiKit, migrations: [ diff --git a/SessionUtilitiesKit/Configuration.swift b/SessionUtilitiesKit/Configuration.swift index 616e27ed3..df5b5b366 100644 --- a/SessionUtilitiesKit/Configuration.swift +++ b/SessionUtilitiesKit/Configuration.swift @@ -1,9 +1,10 @@ // Copyright © 2022 Rangeproof Pty Ltd. All rights reserved. import Foundation +import GRDB -public enum SNUtilitiesKit { // Just to make the external API nice - public static func migrations() -> TargetMigrations { +public enum SNUtilitiesKit: MigratableTarget { // Just to make the external API nice + public static func migrations(_ db: Database) -> TargetMigrations { return TargetMigrations( identifier: .utilitiesKit, migrations: [ diff --git a/SessionUtilitiesKit/Database/Storage.swift b/SessionUtilitiesKit/Database/Storage.swift index 1667f1384..c00a2a45f 100644 --- a/SessionUtilitiesKit/Database/Storage.swift +++ b/SessionUtilitiesKit/Database/Storage.swift @@ -47,14 +47,14 @@ open class Storage { public init( customWriter: DatabaseWriter? = nil, - customMigrations: [TargetMigrations]? = nil + customMigrationTargets: [MigratableTarget.Type]? = nil ) { - configureDatabase(customWriter: customWriter, customMigrations: customMigrations) + configureDatabase(customWriter: customWriter, customMigrationTargets: customMigrationTargets) } private func configureDatabase( customWriter: DatabaseWriter? = nil, - customMigrations: [TargetMigrations]? = nil + customMigrationTargets: [MigratableTarget.Type]? = nil ) { // Create the database directory if needed and ensure it's protection level is set before attempting to // create the database KeySpec or the database itself @@ -66,7 +66,12 @@ open class Storage { dbWriter = customWriter isValid = true Storage.internalHasCreatedValidInstance.mutate { $0 = true } - perform(migrations: (customMigrations ?? []), async: false, onProgressUpdate: nil, onComplete: { _, _ in }) + perform( + migrationTargets: (customMigrationTargets ?? []), + async: false, + onProgressUpdate: nil, + onComplete: { _, _ in } + ) return } @@ -128,7 +133,7 @@ open class Storage { } public func perform( - migrations: [TargetMigrations], + migrationTargets: [MigratableTarget.Type], async: Bool = true, onProgressUpdate: ((CGFloat, TimeInterval) -> ())?, onComplete: @escaping (Swift.Result, Bool) -> () @@ -141,18 +146,28 @@ open class Storage { } typealias MigrationInfo = (identifier: TargetMigrations.Identifier, migrations: TargetMigrations.MigrationSet) - let sortedMigrationInfo: [MigrationInfo] = migrations - .sorted() - .reduce(into: [[MigrationInfo]]()) { result, next in - next.migrations.enumerated().forEach { index, migrationSet in - if result.count <= index { - result.append([]) - } + let maybeSortedMigrationInfo: [MigrationInfo]? = try? dbWriter + .read { db -> [MigrationInfo] in + migrationTargets + .map { target -> TargetMigrations in target.migrations(db) } + .sorted() + .reduce(into: [[MigrationInfo]]()) { result, next in + next.migrations.enumerated().forEach { index, migrationSet in + if result.count <= index { + result.append([]) + } - result[index] = (result[index] + [(next.identifier, migrationSet)]) - } + result[index] = (result[index] + [(next.identifier, migrationSet)]) + } + } + .reduce(into: []) { result, next in result.append(contentsOf: next) } } - .reduce(into: []) { result, next in result.append(contentsOf: next) } + + guard let sortedMigrationInfo: [MigrationInfo] = maybeSortedMigrationInfo else { + SNLog("[Database Error] Statup failed with error: Unable to prepare migrations") + onComplete(.failure(StorageError.startupFailed), false) + return + } // Setup and run any required migrations migrator = { [weak self] in diff --git a/SessionUtilitiesKit/Database/Types/TargetMigrations.swift b/SessionUtilitiesKit/Database/Types/TargetMigrations.swift index ad305ab73..f9627a7e8 100644 --- a/SessionUtilitiesKit/Database/Types/TargetMigrations.swift +++ b/SessionUtilitiesKit/Database/Types/TargetMigrations.swift @@ -1,6 +1,11 @@ // Copyright © 2022 Rangeproof Pty Ltd. All rights reserved. import Foundation +import GRDB + +public protocol MigratableTarget { + static func migrations(_ db: Database) -> TargetMigrations +} public struct TargetMigrations: Comparable { /// This identifier is used to determine the order each set of migrations should run in. diff --git a/SessionUtilitiesKitTests/Database/Models/IdentitySpec.swift b/SessionUtilitiesKitTests/Database/Models/IdentitySpec.swift index 7f5ed9da6..7eeb39293 100644 --- a/SessionUtilitiesKitTests/Database/Models/IdentitySpec.swift +++ b/SessionUtilitiesKitTests/Database/Models/IdentitySpec.swift @@ -18,8 +18,8 @@ class IdentitySpec: QuickSpec { beforeEach { mockStorage = Storage( customWriter: try! DatabaseQueue(), - customMigrations: [ - SNUtilitiesKit.migrations() + customMigrationTargets: [ + SNUtilitiesKit.self ] ) } diff --git a/SessionUtilitiesKitTests/Database/Utilities/PersistableRecordUtilitiesSpec.swift b/SessionUtilitiesKitTests/Database/Utilities/PersistableRecordUtilitiesSpec.swift index 2c7b09ce4..e17536fe7 100644 --- a/SessionUtilitiesKitTests/Database/Utilities/PersistableRecordUtilitiesSpec.swift +++ b/SessionUtilitiesKitTests/Database/Utilities/PersistableRecordUtilitiesSpec.swift @@ -84,6 +84,17 @@ class PersistableRecordUtilitiesSpec: QuickSpec { } } + private struct TestTarget: MigratableTarget { + static func migrations(_ db: Database) -> TargetMigrations { + return TargetMigrations( + identifier: .test, + migrations: (0..<100) + .map { _ in [] } + .appending([TestInsertTestTypeMigration.self]) + ) + } + } + // MARK: - Spec override func spec() { @@ -96,13 +107,8 @@ class PersistableRecordUtilitiesSpec: QuickSpec { PersistableRecordUtilitiesSpec.customWriter = customWriter mockStorage = Storage( customWriter: customWriter, - customMigrations: [ - TargetMigrations( - identifier: .test, - migrations: (0..<100) - .map { _ in [] } - .appending([TestInsertTestTypeMigration.self]) - ) + customMigrationTargets: [ + TestTarget.self ] ) } diff --git a/SignalUtilitiesKit/Utilities/AppSetup.swift b/SignalUtilitiesKit/Utilities/AppSetup.swift index efc6d1c25..58f0c6856 100644 --- a/SignalUtilitiesKit/Utilities/AppSetup.swift +++ b/SignalUtilitiesKit/Utilities/AppSetup.swift @@ -66,11 +66,11 @@ public enum AppSetup { var backgroundTask: OWSBackgroundTask? = (backgroundTask ?? OWSBackgroundTask(labelStr: #function)) Storage.shared.perform( - migrations: [ - SNUtilitiesKit.migrations(), - SNSnodeKit.migrations(), - SNMessagingKit.migrations(), - SNUIKit.migrations() + migrationTargets: [ + SNUtilitiesKit.self, + SNSnodeKit.self, + SNMessagingKit.self, + SNUIKit.self ], onProgressUpdate: migrationProgressChanged, onComplete: { result, needsConfigSync in