Skip to content

Commit 26f142d

Browse files
authored
Update package for Sendable and 100% test coverage (#223)
* Package structure, CI, and docs updates. Min Swift updated to 5.8. * Add Sendable and ExistentialAny correctness. Fix forwarding of data encoder/decoders to the SQLKit layer. Add support for new SQLKit functionality. Throw DecodingErrors instead of fatalErrors(). Remove unused properties and files. * Add 100% documentation coverage * Achieve 100% test coverage. Make tests async and Sendable-correct. Add missing FluentBenchmark test set. Use singleton ELG and thread pool for tests. * Add updated repo logo
1 parent 986f129 commit 26f142d

20 files changed

+707
-467
lines changed

.github/CONTRIBUTING.md

-66
This file was deleted.

.github/workflows/api-docs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ jobs:
1111
with:
1212
package_name: fluent-mysql-driver
1313
modules: FluentMySQLDriver
14-
pathsToInvalidate: /fluentmysqldriver
14+
pathsToInvalidate: /fluentmysqldriver/*

.github/workflows/test.yml

+29-35
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,17 @@ env:
2424

2525
jobs:
2626
api-breakage:
27-
if: ${{ !(github.event.pull_request.draft || false) }}
27+
if: ${{ github.event_name == 'pull_request' && !(github.event.pull_request.draft || false) }}
2828
runs-on: ubuntu-latest
29-
container: swift:5.8-jammy
29+
container: swift:jammy
3030
steps:
31-
- name: Check out package
32-
uses: actions/checkout@v3
31+
- name: Checkout
32+
uses: actions/checkout@v4
3333
with: { 'fetch-depth': 0 }
34-
- name: Run API breakage check action
35-
uses: vapor/ci/.github/actions/ci-swift-check-api-breakage@reusable-workflows
34+
- name: API breaking changes
35+
run: |
36+
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
37+
swift package diagnose-api-breaking-changes origin/main
3638
3739
linux-unit:
3840
if: ${{ !(github.event.pull_request.draft || false) }}
@@ -42,17 +44,17 @@ jobs:
4244
dbimage:
4345
- mysql:5.7
4446
- mysql:8.0
47+
- mysql:8.3
4548
- mariadb:10.4
4649
- mariadb:11
4750
- percona:8.0
4851
runner:
49-
- swift:5.6-focal
50-
- swift:5.7-jammy
51-
- swift:5.8-jammy
52-
- swiftlang/swift:nightly-5.9-jammy
53-
- swiftlang/swift:nightly-main-jammy
54-
runs-on: ubuntu-latest
52+
# List is deliberately incomplete; we want to avoid running 50 jobs on every commit
53+
- swift:5.8-focal
54+
- swift:5.10-jammy
55+
- swiftlang/swift:nightly-6.0-jammy
5556
container: ${{ matrix.runner }}
57+
runs-on: ubuntu-latest
5658
services:
5759
mysql-a:
5860
image: ${{ matrix.dbimage }}
@@ -69,43 +71,35 @@ jobs:
6971
MYSQL_PASSWORD: test_password
7072
MYSQL_DATABASE: test_database
7173
steps:
72-
- name: Display versions
73-
shell: bash
74-
run: |
75-
echo MYSQL_VERSION='${{ matrix.dbimage }}' >> $GITHUB_ENV
76-
if [[ '${{ contains(matrix.container, 'nightly') }}' == 'true' ]]; then
77-
SWIFT_PLATFORM="$(source /etc/os-release && echo "${ID}${VERSION_ID}")" SWIFT_VERSION="$(cat /.swift_tag)"
78-
printf 'SWIFT_PLATFORM=%s\nSWIFT_VERSION=%s\n' "${SWIFT_PLATFORM}" "${SWIFT_VERSION}" >>"${GITHUB_ENV}"
79-
fi
80-
printf 'OS: %s\nTag: %s\nVersion:\n' "${SWIFT_PLATFORM}-${RUNNER_ARCH}" "${SWIFT_VERSION}" && swift --version
8174
- name: Check out package
82-
uses: actions/checkout@v3
83-
- name: Run tests with Thread Sanitizer and coverage
84-
run: swift test --sanitize=thread --enable-code-coverage
75+
uses: actions/checkout@v4
76+
- name: Run local tests with coverage and TSan
77+
run: swift test --enable-code-coverage --sanitize=thread
8578
- name: Submit coverage report to Codecov.io
86-
uses: vapor/swift-codecov-action@v0.2
79+
uses: vapor/swift-codecov-action@v0.3
8780
with:
88-
cc_env_vars: 'SWIFT_VERSION,SWIFT_PLATFORM,RUNNER_OS,RUNNER_ARCH,MYSQL_VERSION'
81+
codecov_token: ${{ secrets.CODECOV_TOKEN }}
8982

9083
macos-unit:
9184
if: ${{ !(github.event.pull_request.draft || false) }}
9285
strategy:
9386
fail-fast: false
9487
matrix:
9588
include:
96-
- dbimage: [email protected]
97-
macos: macos-13
98-
xcode: latest-stable
99-
runs-on: ${{ matrix.macos }}
89+
- macos-version: macos-13
90+
xcode-version: '~14.3'
91+
- macos-version: macos-14
92+
xcode-version: latest
93+
runs-on: ${{ matrix.macos-version }}
10094
steps:
10195
- name: Select latest available Xcode
10296
uses: maxim-lobanov/setup-xcode@v1
103-
with:
104-
xcode-version: ${{ matrix.xcode }}
97+
with:
98+
xcode-version: ${{ matrix.xcode-version }}
10599
- name: Install MySQL server from Homebrew
106-
run: brew install ${{ matrix.dbimage }} && brew link --force ${{ matrix.dbimage }}
100+
run: brew install mysql && brew link --force mysql
107101
- name: Start MySQL server
108-
run: brew services start ${{ matrix.dbimage }}
102+
run: brew services start mysql
109103
- name: Wait for MySQL server to be ready
110104
run: until echo | mysql -uroot; do sleep 1; done
111105
timeout-minutes: 5
@@ -117,7 +111,7 @@ jobs:
117111
CREATE DATABASE test_database_b; GRANT ALL PRIVILEGES ON test_database_b.* TO test_username@localhost;
118112
SQL
119113
- name: Check out code
120-
uses: actions/checkout@v3
114+
uses: actions/checkout@v4
121115
- name: Run tests with Thread Sanitizer
122116
run: swift test --sanitize=thread
123117
env:

Package.swift

+28-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.6
1+
// swift-tools-version:5.8
22
import PackageDescription
33

44
let package = Package(
@@ -13,20 +13,35 @@ let package = Package(
1313
.library(name: "FluentMySQLDriver", targets: ["FluentMySQLDriver"]),
1414
],
1515
dependencies: [
16-
.package(url: "https://github.com/vapor/fluent-kit.git", from: "1.43.0"),
16+
.package(url: "https://github.com/vapor/fluent-kit.git", from: "1.48.1"),
1717
.package(url: "https://github.com/vapor/mysql-kit.git", from: "4.7.1"),
18-
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.2"),
18+
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.4"),
1919
],
2020
targets: [
21-
.target(name: "FluentMySQLDriver", dependencies: [
22-
.product(name: "FluentKit", package: "fluent-kit"),
23-
.product(name: "FluentSQL", package: "fluent-kit"),
24-
.product(name: "Logging", package: "swift-log"),
25-
.product(name: "MySQLKit", package: "mysql-kit"),
26-
]),
27-
.testTarget(name: "FluentMySQLDriverTests", dependencies: [
28-
.product(name: "FluentBenchmark", package: "fluent-kit"),
29-
.target(name: "FluentMySQLDriver"),
30-
]),
21+
.target(
22+
name: "FluentMySQLDriver",
23+
dependencies: [
24+
.product(name: "FluentKit", package: "fluent-kit"),
25+
.product(name: "FluentSQL", package: "fluent-kit"),
26+
.product(name: "Logging", package: "swift-log"),
27+
.product(name: "MySQLKit", package: "mysql-kit"),
28+
],
29+
swiftSettings: swiftSettings
30+
),
31+
.testTarget(
32+
name: "FluentMySQLDriverTests",
33+
dependencies: [
34+
.product(name: "FluentBenchmark", package: "fluent-kit"),
35+
.target(name: "FluentMySQLDriver"),
36+
],
37+
swiftSettings: swiftSettings
38+
),
3139
]
3240
)
41+
42+
var swiftSettings: [SwiftSetting] { [
43+
.enableUpcomingFeature("ConciseMagicFile"),
44+
.enableUpcomingFeature("ForwardTrailingClosures"),
45+
.enableUpcomingFeature("DisableOutwardActorInference"),
46+
.enableExperimentalFeature("StrictConcurrency=complete"),
47+
] }

[email protected]

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// swift-tools-version:5.9
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "fluent-mysql-driver",
6+
platforms: [
7+
.macOS(.v10_15),
8+
.iOS(.v13),
9+
.watchOS(.v6),
10+
.tvOS(.v13),
11+
],
12+
products: [
13+
.library(name: "FluentMySQLDriver", targets: ["FluentMySQLDriver"]),
14+
],
15+
dependencies: [
16+
.package(url: "https://github.com/vapor/fluent-kit.git", from: "1.48.1"),
17+
.package(url: "https://github.com/vapor/mysql-kit.git", from: "4.7.1"),
18+
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.4"),
19+
],
20+
targets: [
21+
.target(
22+
name: "FluentMySQLDriver",
23+
dependencies: [
24+
.product(name: "FluentKit", package: "fluent-kit"),
25+
.product(name: "FluentSQL", package: "fluent-kit"),
26+
.product(name: "Logging", package: "swift-log"),
27+
.product(name: "MySQLKit", package: "mysql-kit"),
28+
],
29+
swiftSettings: swiftSettings
30+
),
31+
.testTarget(
32+
name: "FluentMySQLDriverTests",
33+
dependencies: [
34+
.product(name: "FluentBenchmark", package: "fluent-kit"),
35+
.target(name: "FluentMySQLDriver"),
36+
],
37+
swiftSettings: swiftSettings
38+
),
39+
]
40+
)
41+
42+
var swiftSettings: [SwiftSetting] { [
43+
.enableUpcomingFeature("ExistentialAny"),
44+
.enableUpcomingFeature("ConciseMagicFile"),
45+
.enableUpcomingFeature("ForwardTrailingClosures"),
46+
.enableUpcomingFeature("DisableOutwardActorInference"),
47+
.enableExperimentalFeature("StrictConcurrency=complete"),
48+
] }

README.md

+33-25
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,35 @@
11
<p align="center">
2-
<img
3-
src="https://user-images.githubusercontent.com/1342803/75593351-1176b880-5a53-11ea-96ac-b9212e7471e9.png"
4-
height="64"
5-
alt="FluentMySQLDriver"
6-
>
7-
<br>
8-
<br>
9-
<a href="https://docs.vapor.codes/4.0/">
10-
<img src="http://img.shields.io/badge/read_the-docs-2196f3.svg" alt="Documentation">
11-
</a>
12-
<a href="https://discord.gg/vapor">
13-
<img src="https://img.shields.io/discord/431917998102675485.svg" alt="Team Chat">
14-
</a>
15-
<a href="LICENSE">
16-
<img src="http://img.shields.io/badge/license-MIT-brightgreen.svg" alt="MIT License">
17-
</a>
18-
<a href="https://github.com/vapor/fluent-mysql-driver/actions/workflows/test.yml">
19-
<img src="https://github.com/vapor/fluent-mysql-driver/actions/workflows/test.yml/badge.svg?event=push" alt="Continuous Integration">
20-
</a>
21-
<a href="https://codecov.io/gh/vapor/fluent-mysql-driver">
22-
<img src="https://codecov.io/gh/vapor/fluent-mysql-driver/branch/main/graph/badge.svg?token=AobVT2XIMt" alt="Test Coverage">
23-
</a>
24-
<a href="https://swift.org">
25-
<img src="http://img.shields.io/badge/swift-5.6-brightgreen.svg" alt="Swift 5.6">
26-
</a>
2+
<picture>
3+
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/vapor/fluent-mysql-driver/assets/1130717/2810939b-2d77-4d39-9485-8e11b8f5dab4">
4+
<source media="(prefers-color-scheme: light)" srcset="https://github.com/vapor/fluent-mysql-driver/assets/1130717/ab442fbf-baf1-4cfe-8639-23141fb26e5a">
5+
<img src="https://github.com/vapor/fluent-mysql-driver/assets/1130717/ab442fbf-baf1-4cfe-8639-23141fb26e5a" height="96" alt="FluentMySQLDriver">
6+
</picture>
7+
<br>
8+
<br>
9+
<a href="https://docs.vapor.codes/4.0/"><img src="https://design.vapor.codes/images/readthedocs.svg" alt="Documentation"></a>
10+
<a href="https://discord.gg/vapor"><img src="https://design.vapor.codes/images/discordchat.svg" alt="Team Chat"></a>
11+
<a href="LICENSE"><img src="https://design.vapor.codes/images/mitlicense.svg" alt="MIT License"></a>
12+
<a href="https://github.com/vapor/fluent-mysql-driver/actions/workflows/test.yml"><img src="https://img.shields.io/github/actions/workflow/status/vapor/fluent-mysql-driver/test.yml?event=push&style=plastic&logo=github&label=tests&logoColor=%23ccc" alt="Continuous Integration"></a>
13+
<a href="https://codecov.io/github/vapor/fluent-mysql-driver"><img src="https://img.shields.io/codecov/c/github/vapor/fluent-mysql-driver?style=plastic&logo=codecov&label=codecov"></a>
14+
<a href="https://swift.org"><img src="https://design.vapor.codes/images/swift58up.svg" alt="Swift 5.8+"></a>
2715
</p>
16+
17+
<br>
18+
19+
FluentMySQLDriver is a [FluentKit] driver for MySQL clients. It provides support for using the Fluent ORM with MySQL databases, and uses [MySQLKit] to provide [SQLKit] driver services, [MySQLNIO] to connect and communicate with the database server asynchronously, and [AsyncKit] to provide connection pooling.
20+
21+
[FluentKit]: https://github.com/vapor/fluent-kit
22+
[SQLKit]: https://github.com/vapor/sql-kit
23+
[MySQLKit]: https://github.com/vapor/mysql-kit
24+
[MySQLNIO]: https://github.com/vapor/mysql-nio
25+
[AsyncKit]: https://github.com/vapor/async-kit
26+
27+
### Usage
28+
29+
Use the SPM string to easily include the dependendency in your `Package.swift` file:
30+
31+
```swift
32+
.package(url: "https://github.com/vapor/fluent-mysql-driver.git", from: "4.0.0")
33+
```
34+
35+
For additional information, see [the Fluent documentation](https://docs.vapor.codes/fluent/overview/).
Loading
+12-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
11
# ``FluentMySQLDriver``
22

3-
FluentMySQLDriver is a package to integrate MySQLNIO and and MySQLKit with FluentKit to make it easy to use and write MySQL database operations in Swift.
3+
FluentMySQLDriver is a [FluentKit] driver for MySQL clients.
4+
5+
## Overview
6+
7+
FluentMySQLDriver provides support for using the Fluent ORM with MySQL databases. It uses [MySQLKit] to provide [SQLKit] driver services, [MySQLNIO] to connect and communicate with the database server asynchronously, and [AsyncKit] to provide connection pooling.
8+
9+
[FluentKit]: https://github.com/vapor/fluent-kit
10+
[SQLKit]: https://github.com/vapor/sql-kit
11+
[MySQLKit]: https://github.com/vapor/mysql-kit
12+
[MySQLNIO]: https://github.com/vapor/mysql-nio
13+
[AsyncKit]: https://github.com/vapor/async-kit
14+

0 commit comments

Comments
 (0)