diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..9f8d71f --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,18 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + groups: + dependencies: + patterns: + - "*" + - package-ecosystem: "swift" + directory: "/" + schedule: + interval: "daily" + groups: + dependencies: + patterns: + - "*" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a3caf9e..161fa8e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,57 +7,17 @@ on: push: { branches: [ main ] } jobs: - linux-unit: - if: ${{ !(github.event.pull_request.draft || false) }} - strategy: - fail-fast: false - matrix: - swift: - - swift:6.0-noble - - swift:6.1-noble - - swift:6.2-noble - runs-on: ubuntu-latest - container: ${{ matrix.swift }} - steps: - - name: Ensure curl is available - run: apt-get update -y && apt-get install -y curl - - name: Check out code - uses: actions/checkout@v5 - - name: Run unit tests - env: - TRAITS_FLAG: ${{ matrix.swift != 'swift:6.0-noble' && '--enable-all-traits' || '' }} - run: | - swift test --enable-code-coverage --explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable -Xswiftc -warnings-as-errors ${TRAITS_FLAG} - - name: Upload coverage data - uses: vapor/swift-codecov-action@v0.3 - with: - codecov_token: ${{ secrets.CODECOV_TOKEN || '' }} + unit-tests: + permissions: + contents: read + uses: vapor/ci/.github/workflows/run-unit-tests.yml@main + with: + enable_all_traits: true + secrets: inherit - macos-unit: - if: ${{ !(github.event.pull_request.draft || false) }} - strategy: - fail-fast: false - matrix: - include: - - macos-version: macos-15 - xcode-version: latest-stable - - macos-version: macos-26 - xcode-version: latest-stable - runs-on: ${{ matrix.macos-version }} - steps: - - name: Select appropriate Xcode version - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: ${{ matrix.xcode-version }} - - name: Check out code - uses: actions/checkout@v5 - - name: Run unit tests - run: | - swift test --enable-code-coverage --explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable -Xswiftc -warnings-as-errors --enable-all-traits - - name: Upload coverage data - uses: vapor/swift-codecov-action@v0.3 - with: - codecov_token: ${{ secrets.CODECOV_TOKEN || '' }} - - # Can't test on Windows, uses NIO - # Can't test Musl because of FluentBenchmarks and SQLKitBenchmarks + submit-dependencies: + permissions: + contents: write + if: ${{ github.event_name == 'push' }} + uses: vapor/ci/.github/workflows/submit-deps.yml@main + secrets: inherit diff --git a/Sources/FluentKitExtras/AliasProperty.swift b/Sources/FluentKitExtras/AliasProperty.swift index 5a80e7e..d7d03d1 100644 --- a/Sources/FluentKitExtras/AliasProperty.swift +++ b/Sources/FluentKitExtras/AliasProperty.swift @@ -164,10 +164,9 @@ public struct AliasProperty: Sendable /// Having to explicitly add the conformance to any additional property types anyone else might /// have implemented elsewhere is another reason it's unfortunate that we need the protocol. /// -/// > Note: ``AliasProperty`` and ``UnwrappingAliasProperty`` are omitted from this list deliberately; -/// > they are the only properties which are _not_ aliasable, partially due to their lack of conformance -/// > the `Property` protocol. (It's probably possible to make aliases that can be chained, but it doesn't -/// > seem worth the effort.) +/// > Note: ``AliasProperty`` is omitted from this list deliberately; it is the only property which +/// > is _not_ aliasable, partially due to its lack of conformance to the `Property` protocol. (It's +/// > probably possible to make aliases that can be chained, but it doesn't seem worth the effort.) extension FluentKit.IDProperty: AliasableProperty {} extension FluentKit.CompositeIDProperty: AliasableProperty {} diff --git a/Sources/FluentKitExtras/FlatGroupProperty.swift b/Sources/FluentKitExtras/FlatGroupProperty.swift index cb64357..ea473b2 100644 --- a/Sources/FluentKitExtras/FlatGroupProperty.swift +++ b/Sources/FluentKitExtras/FlatGroupProperty.swift @@ -54,9 +54,9 @@ extension Model { public final class FlatGroupProperty where Model: FluentKit.Fields, Value: FluentKit.Fields { - /// The underlying storage of the properties nested on ``Value``. It is optional - /// only because ``FluentKit/Property``'s ``value`` requirement must always be - /// optional. It will never actually be `nil` in practice at runtime. + /// The underlying storage of the properties nested on `Value`. It is optional + /// only because `Property`'s `value` requirement must always be optional. It will + /// never actually be `nil` in practice at runtime. public var value: Value? /// Fluent property wrappers must return `self` as their ``projectedValue``. @@ -123,7 +123,7 @@ public final class FlatGroupProperty /// Provide `@FlatGroup` properties with a description which includes all of the relevant types in the result. extension FlatGroupProperty: CustomStringConvertible { - /// See ``Swift/CustomStringConvertible/description``. + // See `CustomStringConvertible.description`. public var description: String { "@\(Model.self).FlatGroup<\(Value.self)>()" } @@ -138,17 +138,17 @@ extension FlatGroupProperty: AnyProperty, Property {} /// `@FlatGroup` has content that interacts with database queries (i.e. the properties it contains). extension FlatGroupProperty: AnyDatabaseProperty { - /// See ``FluentKit/AnyDatabaseProperty/keys``. + // See `AnyDatabaseProperty.keys`. public var keys: [FieldKey] { Value.keys } - /// See ``FluentKit/AnyDatabaseProperty/input(to:)``. + // See `AnyDatabaseProperty.input(to:)`. public func input(to input: any DatabaseInput) { self.value!.input(to: input) } - /// See ``FluentKit/AnyDatabaseProperty/output(from:)``. + // See `AnyDatabaseProperty.output(from:)`. public func output(from output: any DatabaseOutput) throws { try self.value!.output(from: output) } @@ -159,13 +159,13 @@ extension FlatGroupProperty: AnyDatabaseProperty { /// `@FlatGroup` participates in ``FluentKit/Fields``'s ``Swift/Codable`` conformance (i.e. by /// passing it on to its contained properties). extension FlatGroupProperty: AnyCodableProperty { - /// See ``FluentKit/AnyCodableProperty/encode(to:)``. + // See `AnyCodableProperty.encode(to:)`. public func encode(to encoder: any Encoder) throws { var container = encoder.singleValueContainer() try container.encode(self.value!) } - /// See ``FluentKit/AnyCodableProperty/decode(from:)``. + // See `AnyCodableProperty.decode(from:)`. public func decode(from decoder: any Decoder) throws { let container = try decoder.singleValueContainer() self.value = try .some(container.decode(Value.self)) diff --git a/Sources/SQLKitExtras/SQLKitExtras/Expressions/SQLCastExpression.swift b/Sources/SQLKitExtras/SQLKitExtras/Expressions/SQLCastExpression.swift index e207476..fabda1a 100644 --- a/Sources/SQLKitExtras/SQLKitExtras/Expressions/SQLCastExpression.swift +++ b/Sources/SQLKitExtras/SQLKitExtras/Expressions/SQLCastExpression.swift @@ -11,8 +11,8 @@ public struct SQLCastExpression: SQLExpression { /// Create a new ``SQLCastExpression``. /// /// - Parameters: - /// - original: The original expression to be cast. - /// - desiredType: The desired type to cast the original expression to. + /// - expr: The original expression to be cast. + /// - castType: The desired type to cast the original expression to. public init(expr: some SQLExpression, castType: some SQLExpression) { self.original = expr self.desiredType = castType @@ -22,7 +22,7 @@ public struct SQLCastExpression: SQLExpression { /// /// - Parameters: /// - original: The original expression to be cast. - /// - desiredType: The desired type to cast the original expression to, represented as a string. + /// - type: The desired type to cast the original expression to, represented as a string. public init(_ original: some SQLExpression, to type: some StringProtocol) { self.init(expr: original, castType: .identifier(type)) } diff --git a/Tests/FluentKitExtrasTests/FluentKitExtrasTests.swift b/Tests/FluentKitExtrasTests/FluentKitExtrasTests.swift index e1510d6..686d4d1 100644 --- a/Tests/FluentKitExtrasTests/FluentKitExtrasTests.swift +++ b/Tests/FluentKitExtrasTests/FluentKitExtrasTests.swift @@ -315,7 +315,7 @@ final class MockFluentDatabase: Database { let context: DatabaseContext = .init( configuration: MockConfiguration(), logger: .init(label: "mockdb", factory: ModifiedStreamLogHandler.standardOutput(label:)), - eventLoop: EmbeddedEventLoop() + eventLoop: NIOAsyncTestingEventLoop() ) let inTransaction = false @@ -327,7 +327,13 @@ final class MockFluentDatabase: Database { func execute(query: DatabaseQuery, onOutput: @escaping @Sendable (any DatabaseOutput) -> ()) -> EventLoopFuture { if !self.outputs.isEmpty { - for output in self.outputs.removeFirst() { onOutput(output) } + // This nonsense is because QueryBuilder expects its output function to be called on the event loop, + // and NIOAsyncTestingEventLoop doesn't return true unconditionally like EmbeddedEventLoop did + return self.eventLoop.makeFutureWithTask { + try await (self.eventLoop as! NIOAsyncTestingEventLoop).executeInContext { + for output in self.outputs.removeFirst() { onOutput(output) } + } + } } return self.eventLoop.makeSucceededVoidFuture() }