From dd118e907f9981f7c521309f2ab0a5bc1bda9250 Mon Sep 17 00:00:00 2001 From: Siemen Sikkema Date: Wed, 17 Jun 2020 12:56:53 +0200 Subject: [PATCH 1/4] Update Fluent --- Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index 5db7855..74bae9b 100644 --- a/Package.swift +++ b/Package.swift @@ -15,7 +15,7 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/vapor/vapor.git", from: "4.0.0"), - .package(url: "https://github.com/vapor/fluent.git", from: "4.0.0-rc.3"), + .package(url: "https://github.com/vapor/fluent.git", from: "4.0.0"), .package(url: "https://github.com/vapor/sql-kit.git", from: "3.1.0"), .package(url: "https://github.com/vapor/queues.git", from: "1.1.0"), ], From ab67bcf17fee67945144064e9e1d73e449fc42c7 Mon Sep 17 00:00:00 2001 From: Siemen Sikkema Date: Wed, 17 Jun 2020 12:57:06 +0200 Subject: [PATCH 2/4] Minor cleanups --- Sources/QueuesFluentDriver/FluentQueue.swift | 4 +--- Sources/QueuesFluentDriver/FluentQueuesDriver.swift | 4 ++-- Sources/QueuesFluentDriver/PopQueries/MySQLPopQuery.swift | 2 +- Sources/QueuesFluentDriver/PopQueries/PostgresPopQuery.swift | 2 +- Sources/QueuesFluentDriver/PopQueries/SqlitePopQuery.swift | 2 +- Sources/QueuesFluentDriver/SQLExpressionExtensions.swift | 2 +- 6 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Sources/QueuesFluentDriver/FluentQueue.swift b/Sources/QueuesFluentDriver/FluentQueue.swift index dfba208..57da5f3 100644 --- a/Sources/QueuesFluentDriver/FluentQueue.swift +++ b/Sources/QueuesFluentDriver/FluentQueue.swift @@ -23,15 +23,13 @@ extension FluentQueue: Queue { } public func set(_ id: JobIdentifier, to jobStorage: JobData) -> EventLoopFuture { - //let data = try! JSONEncoder().encode(jobStorage) do { let jobModel = try JobModel(jobId: id.string, queue: queueName.string, data: jobStorage) return jobModel.save(on: db) } catch { return db.eventLoop.makeFailedFuture(QueuesFluentError.jobDataEncodingError(error.localizedDescription)) - } - + } } public func clear(_ id: JobIdentifier) -> EventLoopFuture { diff --git a/Sources/QueuesFluentDriver/FluentQueuesDriver.swift b/Sources/QueuesFluentDriver/FluentQueuesDriver.swift index 1e438d1..8691254 100644 --- a/Sources/QueuesFluentDriver/FluentQueuesDriver.swift +++ b/Sources/QueuesFluentDriver/FluentQueuesDriver.swift @@ -13,10 +13,10 @@ public struct FluentQueuesDriver { let useSoftDeletes: Bool let eventLoopGroup: EventLoopGroup - init(on databaseId: DatabaseID? = nil, useSoftDeletes: Bool, on: EventLoopGroup) { + init(on databaseId: DatabaseID? = nil, useSoftDeletes: Bool, on eventLoopGroup: EventLoopGroup) { self.databaseId = databaseId self.useSoftDeletes = useSoftDeletes - self.eventLoopGroup = on + self.eventLoopGroup = eventLoopGroup } } diff --git a/Sources/QueuesFluentDriver/PopQueries/MySQLPopQuery.swift b/Sources/QueuesFluentDriver/PopQueries/MySQLPopQuery.swift index 4d36527..2977889 100644 --- a/Sources/QueuesFluentDriver/PopQueries/MySQLPopQuery.swift +++ b/Sources/QueuesFluentDriver/PopQueries/MySQLPopQuery.swift @@ -2,7 +2,7 @@ import Foundation import SQLKit import Fluent -final class MySQLPop : PopQueryProtocol { +final class MySQLPop: PopQueryProtocol { // MySQL is a bit challenging since it doesn't support updating a table that is // used in a subquery. // So we first select, then update, with the whole process wrapped in a transaction. diff --git a/Sources/QueuesFluentDriver/PopQueries/PostgresPopQuery.swift b/Sources/QueuesFluentDriver/PopQueries/PostgresPopQuery.swift index b4f425c..124b71e 100644 --- a/Sources/QueuesFluentDriver/PopQueries/PostgresPopQuery.swift +++ b/Sources/QueuesFluentDriver/PopQueries/PostgresPopQuery.swift @@ -3,7 +3,7 @@ import Foundation import SQLKit import Fluent -final class PostgresPop : PopQueryProtocol { +final class PostgresPop: PopQueryProtocol { func pop(db: Database, select: SQLExpression) -> EventLoopFuture { let db = db as! SQLDatabase let subQueryGroup = SQLGroupExpression.init(select) diff --git a/Sources/QueuesFluentDriver/PopQueries/SqlitePopQuery.swift b/Sources/QueuesFluentDriver/PopQueries/SqlitePopQuery.swift index d38c818..1fa0d53 100644 --- a/Sources/QueuesFluentDriver/PopQueries/SqlitePopQuery.swift +++ b/Sources/QueuesFluentDriver/PopQueries/SqlitePopQuery.swift @@ -2,7 +2,7 @@ import Foundation import SQLKit import Fluent -final class SqlitePop : PopQueryProtocol { +final class SqlitePop: PopQueryProtocol { func pop(db: Database, select: SQLExpression) -> EventLoopFuture { db.transaction { transaction in let database = transaction as! SQLDatabase diff --git a/Sources/QueuesFluentDriver/SQLExpressionExtensions.swift b/Sources/QueuesFluentDriver/SQLExpressionExtensions.swift index 147560b..719e141 100644 --- a/Sources/QueuesFluentDriver/SQLExpressionExtensions.swift +++ b/Sources/QueuesFluentDriver/SQLExpressionExtensions.swift @@ -16,7 +16,7 @@ enum SQLSkipLocked: SQLExpression { } } -enum SqlReturning : SQLExpression { +enum SqlReturning: SQLExpression { /// `RETURNING *` case all case column(_ column: FieldKey) From cee021b9c5f996051e6b7e9dfd464d12af48fdd2 Mon Sep 17 00:00:00 2001 From: Siemen Sikkema Date: Wed, 17 Jun 2020 13:20:44 +0200 Subject: [PATCH 3/4] Update CI --- .github/workflows/swift.yml | 19 -------------- .github/workflows/test.yml | 26 +++++++++++++++++++ Tests/LinuxMain.swift | 8 +----- .../QueuesFluentDriverTests.swift | 4 --- .../XCTestManifests.swift | 9 ------- 5 files changed, 27 insertions(+), 39 deletions(-) delete mode 100644 .github/workflows/swift.yml create mode 100644 .github/workflows/test.yml delete mode 100644 Tests/QueuesFluentDriverTests/XCTestManifests.swift diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml deleted file mode 100644 index 5dbdb4f..0000000 --- a/.github/workflows/swift.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Swift - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - - runs-on: macos-latest - - steps: - - uses: actions/checkout@v2 - - name: Build - run: swift build -v - - name: Run tests - run: swift test -v diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..2ef9b86 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,26 @@ +name: test +on: + pull_request: + push: + branches: + - master +jobs: + linux: + runs-on: ubuntu-latest + container: swift:5.2-bionic + steps: + - name: Check out code + uses: actions/checkout@v2 + - name: Run tests with Thread Sanitizer + run: swift test --enable-test-discovery --sanitize=thread + macOS: + runs-on: macos-latest + steps: + - name: Select latest available Xcode + uses: maxim-lobanov/setup-xcode@1.0 + with: + xcode-version: latest + - name: Check out code + uses: actions/checkout@v2 + - name: Run tests with Thread Sanitizer + run: swift test --enable-test-discovery --sanitize=thread \ No newline at end of file diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift index 5f0b1ee..6493e32 100644 --- a/Tests/LinuxMain.swift +++ b/Tests/LinuxMain.swift @@ -1,7 +1 @@ -import XCTest - -import QueuesFluentDriverTests - -var tests = [XCTestCaseEntry]() -tests += QueuesFluentDriverTests.allTests() -XCTMain(tests) +fatalError("Please use swift test --enable-test-discovery to run the tests instead") diff --git a/Tests/QueuesFluentDriverTests/QueuesFluentDriverTests.swift b/Tests/QueuesFluentDriverTests/QueuesFluentDriverTests.swift index a6d681c..2e9ca3c 100644 --- a/Tests/QueuesFluentDriverTests/QueuesFluentDriverTests.swift +++ b/Tests/QueuesFluentDriverTests/QueuesFluentDriverTests.swift @@ -8,8 +8,4 @@ final class QueuesFluentDriverTests: XCTestCase { // results. //XCTAssertEqual(QueuesFluentDriver().text, "Hello, World!") } - - static var allTests = [ - ("testExample", testExample), - ] } diff --git a/Tests/QueuesFluentDriverTests/XCTestManifests.swift b/Tests/QueuesFluentDriverTests/XCTestManifests.swift deleted file mode 100644 index b67c21b..0000000 --- a/Tests/QueuesFluentDriverTests/XCTestManifests.swift +++ /dev/null @@ -1,9 +0,0 @@ -import XCTest - -#if !canImport(ObjectiveC) -public func allTests() -> [XCTestCaseEntry] { - return [ - testCase(QueuesFluentDriverTests.allTests), - ] -} -#endif From 7d1ea8e1bca6b5c3530437fc08a5790911991637 Mon Sep 17 00:00:00 2001 From: Siemen Sikkema Date: Wed, 17 Jun 2020 13:31:39 +0200 Subject: [PATCH 4/4] Enable test target --- Package.swift | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Package.swift b/Package.swift index 74bae9b..d839c02 100644 --- a/Package.swift +++ b/Package.swift @@ -29,9 +29,10 @@ let package = Package( .product(name: "Queues", package: "queues") ], path: "Sources" - ) - /*.testTarget( + ), + .testTarget( name: "QueuesFluentDriverTests", - dependencies: ["QueuesFluentDriver"]),*/ + dependencies: ["QueuesFluentDriver"] + ), ] )