Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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:
- "*"
66 changes: 13 additions & 53 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 3 additions & 4 deletions Sources/FluentKitExtras/AliasProperty.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,9 @@ public struct AliasProperty<Model, Original>: 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 {}
Expand Down
18 changes: 9 additions & 9 deletions Sources/FluentKitExtras/FlatGroupProperty.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ extension Model {
public final class FlatGroupProperty<Model, Value>
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``.
Expand Down Expand Up @@ -123,7 +123,7 @@ public final class FlatGroupProperty<Model, Value>

/// 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)>()"
}
Expand All @@ -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)
}
Expand All @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
}
Expand Down
10 changes: 8 additions & 2 deletions Tests/FluentKitExtrasTests/FluentKitExtrasTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -327,7 +327,13 @@ final class MockFluentDatabase: Database {

func execute(query: DatabaseQuery, onOutput: @escaping @Sendable (any DatabaseOutput) -> ()) -> EventLoopFuture<Void> {
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()
}
Expand Down
Loading