-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
20 changed files
with
707 additions
and
467 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,15 +24,17 @@ env: | |
|
||
jobs: | ||
api-breakage: | ||
if: ${{ !(github.event.pull_request.draft || false) }} | ||
if: ${{ github.event_name == 'pull_request' && !(github.event.pull_request.draft || false) }} | ||
runs-on: ubuntu-latest | ||
container: swift:5.8-jammy | ||
container: swift:jammy | ||
steps: | ||
- name: Check out package | ||
uses: actions/checkout@v3 | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: { 'fetch-depth': 0 } | ||
- name: Run API breakage check action | ||
uses: vapor/ci/.github/actions/ci-swift-check-api-breakage@reusable-workflows | ||
- name: API breaking changes | ||
run: | | ||
git config --global --add safe.directory "${GITHUB_WORKSPACE}" | ||
swift package diagnose-api-breaking-changes origin/main | ||
linux-unit: | ||
if: ${{ !(github.event.pull_request.draft || false) }} | ||
|
@@ -42,17 +44,17 @@ jobs: | |
dbimage: | ||
- mysql:5.7 | ||
- mysql:8.0 | ||
- mysql:8.3 | ||
- mariadb:10.4 | ||
- mariadb:11 | ||
- percona:8.0 | ||
runner: | ||
- swift:5.6-focal | ||
- swift:5.7-jammy | ||
- swift:5.8-jammy | ||
- swiftlang/swift:nightly-5.9-jammy | ||
- swiftlang/swift:nightly-main-jammy | ||
runs-on: ubuntu-latest | ||
# List is deliberately incomplete; we want to avoid running 50 jobs on every commit | ||
- swift:5.8-focal | ||
- swift:5.10-jammy | ||
- swiftlang/swift:nightly-6.0-jammy | ||
container: ${{ matrix.runner }} | ||
runs-on: ubuntu-latest | ||
services: | ||
mysql-a: | ||
image: ${{ matrix.dbimage }} | ||
|
@@ -69,43 +71,35 @@ jobs: | |
MYSQL_PASSWORD: test_password | ||
MYSQL_DATABASE: test_database | ||
steps: | ||
- name: Display versions | ||
shell: bash | ||
run: | | ||
echo MYSQL_VERSION='${{ matrix.dbimage }}' >> $GITHUB_ENV | ||
if [[ '${{ contains(matrix.container, 'nightly') }}' == 'true' ]]; then | ||
SWIFT_PLATFORM="$(source /etc/os-release && echo "${ID}${VERSION_ID}")" SWIFT_VERSION="$(cat /.swift_tag)" | ||
printf 'SWIFT_PLATFORM=%s\nSWIFT_VERSION=%s\n' "${SWIFT_PLATFORM}" "${SWIFT_VERSION}" >>"${GITHUB_ENV}" | ||
fi | ||
printf 'OS: %s\nTag: %s\nVersion:\n' "${SWIFT_PLATFORM}-${RUNNER_ARCH}" "${SWIFT_VERSION}" && swift --version | ||
- name: Check out package | ||
uses: actions/checkout@v3 | ||
- name: Run tests with Thread Sanitizer and coverage | ||
run: swift test --sanitize=thread --enable-code-coverage | ||
uses: actions/checkout@v4 | ||
- name: Run local tests with coverage and TSan | ||
run: swift test --enable-code-coverage --sanitize=thread | ||
- name: Submit coverage report to Codecov.io | ||
uses: vapor/swift-codecov-action@v0.2 | ||
uses: vapor/swift-codecov-action@v0.3 | ||
with: | ||
cc_env_vars: 'SWIFT_VERSION,SWIFT_PLATFORM,RUNNER_OS,RUNNER_ARCH,MYSQL_VERSION' | ||
codecov_token: ${{ secrets.CODECOV_TOKEN }} | ||
|
||
macos-unit: | ||
if: ${{ !(github.event.pull_request.draft || false) }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- dbimage: [email protected] | ||
macos: macos-13 | ||
xcode: latest-stable | ||
runs-on: ${{ matrix.macos }} | ||
- macos-version: macos-13 | ||
xcode-version: '~14.3' | ||
- macos-version: macos-14 | ||
xcode-version: latest | ||
runs-on: ${{ matrix.macos-version }} | ||
steps: | ||
- name: Select latest available Xcode | ||
uses: maxim-lobanov/setup-xcode@v1 | ||
with: | ||
xcode-version: ${{ matrix.xcode }} | ||
with: | ||
xcode-version: ${{ matrix.xcode-version }} | ||
- name: Install MySQL server from Homebrew | ||
run: brew install ${{ matrix.dbimage }} && brew link --force ${{ matrix.dbimage }} | ||
run: brew install mysql && brew link --force mysql | ||
- name: Start MySQL server | ||
run: brew services start ${{ matrix.dbimage }} | ||
run: brew services start mysql | ||
- name: Wait for MySQL server to be ready | ||
run: until echo | mysql -uroot; do sleep 1; done | ||
timeout-minutes: 5 | ||
|
@@ -117,7 +111,7 @@ jobs: | |
CREATE DATABASE test_database_b; GRANT ALL PRIVILEGES ON test_database_b.* TO test_username@localhost; | ||
SQL | ||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
- name: Run tests with Thread Sanitizer | ||
run: swift test --sanitize=thread | ||
env: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// swift-tools-version:5.9 | ||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "fluent-mysql-driver", | ||
platforms: [ | ||
.macOS(.v10_15), | ||
.iOS(.v13), | ||
.watchOS(.v6), | ||
.tvOS(.v13), | ||
], | ||
products: [ | ||
.library(name: "FluentMySQLDriver", targets: ["FluentMySQLDriver"]), | ||
], | ||
dependencies: [ | ||
.package(url: "https://github.com/vapor/fluent-kit.git", from: "1.48.1"), | ||
.package(url: "https://github.com/vapor/mysql-kit.git", from: "4.7.1"), | ||
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.4"), | ||
], | ||
targets: [ | ||
.target( | ||
name: "FluentMySQLDriver", | ||
dependencies: [ | ||
.product(name: "FluentKit", package: "fluent-kit"), | ||
.product(name: "FluentSQL", package: "fluent-kit"), | ||
.product(name: "Logging", package: "swift-log"), | ||
.product(name: "MySQLKit", package: "mysql-kit"), | ||
], | ||
swiftSettings: swiftSettings | ||
), | ||
.testTarget( | ||
name: "FluentMySQLDriverTests", | ||
dependencies: [ | ||
.product(name: "FluentBenchmark", package: "fluent-kit"), | ||
.target(name: "FluentMySQLDriver"), | ||
], | ||
swiftSettings: swiftSettings | ||
), | ||
] | ||
) | ||
|
||
var swiftSettings: [SwiftSetting] { [ | ||
.enableUpcomingFeature("ExistentialAny"), | ||
.enableUpcomingFeature("ConciseMagicFile"), | ||
.enableUpcomingFeature("ForwardTrailingClosures"), | ||
.enableUpcomingFeature("DisableOutwardActorInference"), | ||
.enableExperimentalFeature("StrictConcurrency=complete"), | ||
] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,35 @@ | ||
<p align="center"> | ||
<img | ||
src="https://user-images.githubusercontent.com/1342803/75593351-1176b880-5a53-11ea-96ac-b9212e7471e9.png" | ||
height="64" | ||
alt="FluentMySQLDriver" | ||
> | ||
<br> | ||
<br> | ||
<a href="https://docs.vapor.codes/4.0/"> | ||
<img src="http://img.shields.io/badge/read_the-docs-2196f3.svg" alt="Documentation"> | ||
</a> | ||
<a href="https://discord.gg/vapor"> | ||
<img src="https://img.shields.io/discord/431917998102675485.svg" alt="Team Chat"> | ||
</a> | ||
<a href="LICENSE"> | ||
<img src="http://img.shields.io/badge/license-MIT-brightgreen.svg" alt="MIT License"> | ||
</a> | ||
<a href="https://github.com/vapor/fluent-mysql-driver/actions/workflows/test.yml"> | ||
<img src="https://github.com/vapor/fluent-mysql-driver/actions/workflows/test.yml/badge.svg?event=push" alt="Continuous Integration"> | ||
</a> | ||
<a href="https://codecov.io/gh/vapor/fluent-mysql-driver"> | ||
<img src="https://codecov.io/gh/vapor/fluent-mysql-driver/branch/main/graph/badge.svg?token=AobVT2XIMt" alt="Test Coverage"> | ||
</a> | ||
<a href="https://swift.org"> | ||
<img src="http://img.shields.io/badge/swift-5.6-brightgreen.svg" alt="Swift 5.6"> | ||
</a> | ||
<picture> | ||
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/vapor/fluent-mysql-driver/assets/1130717/2810939b-2d77-4d39-9485-8e11b8f5dab4"> | ||
<source media="(prefers-color-scheme: light)" srcset="https://github.com/vapor/fluent-mysql-driver/assets/1130717/ab442fbf-baf1-4cfe-8639-23141fb26e5a"> | ||
<img src="https://github.com/vapor/fluent-mysql-driver/assets/1130717/ab442fbf-baf1-4cfe-8639-23141fb26e5a" height="96" alt="FluentMySQLDriver"> | ||
</picture> | ||
<br> | ||
<br> | ||
<a href="https://docs.vapor.codes/4.0/"><img src="https://design.vapor.codes/images/readthedocs.svg" alt="Documentation"></a> | ||
<a href="https://discord.gg/vapor"><img src="https://design.vapor.codes/images/discordchat.svg" alt="Team Chat"></a> | ||
<a href="LICENSE"><img src="https://design.vapor.codes/images/mitlicense.svg" alt="MIT License"></a> | ||
<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> | ||
<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> | ||
<a href="https://swift.org"><img src="https://design.vapor.codes/images/swift58up.svg" alt="Swift 5.8+"></a> | ||
</p> | ||
|
||
<br> | ||
|
||
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. | ||
|
||
[FluentKit]: https://github.com/vapor/fluent-kit | ||
[SQLKit]: https://github.com/vapor/sql-kit | ||
[MySQLKit]: https://github.com/vapor/mysql-kit | ||
[MySQLNIO]: https://github.com/vapor/mysql-nio | ||
[AsyncKit]: https://github.com/vapor/async-kit | ||
|
||
### Usage | ||
|
||
Use the SPM string to easily include the dependendency in your `Package.swift` file: | ||
|
||
```swift | ||
.package(url: "https://github.com/vapor/fluent-mysql-driver.git", from: "4.0.0") | ||
``` | ||
|
||
For additional information, see [the Fluent documentation](https://docs.vapor.codes/fluent/overview/). |
21 changes: 21 additions & 0 deletions
21
Sources/FluentMySQLDriver/Docs.docc/Resources/vapor-fluentmysqldriver-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
# ``FluentMySQLDriver`` | ||
|
||
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. | ||
FluentMySQLDriver is a [FluentKit] driver for MySQL clients. | ||
|
||
## Overview | ||
|
||
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. | ||
|
||
[FluentKit]: https://github.com/vapor/fluent-kit | ||
[SQLKit]: https://github.com/vapor/sql-kit | ||
[MySQLKit]: https://github.com/vapor/mysql-kit | ||
[MySQLNIO]: https://github.com/vapor/mysql-nio | ||
[AsyncKit]: https://github.com/vapor/async-kit | ||
|
Oops, something went wrong.