Skip to content

Commit acfd0e7

Browse files
authored
Update for the nested subpath changes in FluentKit (#218)
Remove no longer needed (well, never needed, really) nested subpath support in SQL converter delegate. General tidying and CI.
1 parent 3be29eb commit acfd0e7

File tree

6 files changed

+51
-90
lines changed

6 files changed

+51
-90
lines changed

Diff for: .github/CODEOWNERS

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
* @gwynne
2+
/.github/CONTRIBUTING.md @gwynne @0xTim
3+
/.github/workflows/*.yml @gwynne @0xTim
4+
/.github/workflows/test.yml @gwynne
5+
/.spi.yml @gwynne @0xTim
6+
/.gitignore @gwynne @0xTim
7+
/LICENSE @gwynne @0xTim
8+
/README.md @gwynne @0xTim
File renamed without changes.

Diff for: .github/workflows/test.yml

+33-78
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
name: test
2+
concurrency:
3+
group: ${{ github.workflow }}-${{ github.ref }}
4+
cancel-in-progress: true
25
on:
3-
pull_request: { branches: ['*'] }
6+
pull_request: { types: [opened, reopened, synchronize, ready_for_review] }
47
push: { branches: [ main ] }
58

69
env:
7-
LOG_LEVEL: debug
10+
LOG_LEVEL: info
811
SWIFT_DETERMINISTIC_HASHING: 1
912
MYSQL_HOSTNAME: 'mysql-a'
1013
MYSQL_HOSTNAME_A: 'mysql-a'
@@ -20,73 +23,27 @@ env:
2023
MYSQL_PASSWORD_B: 'test_password'
2124

2225
jobs:
23-
24-
codecov:
25-
strategy:
26-
# For MySQL we have to run coverage baselines against multiple DB versions thanks to
27-
# the driver's behavior changing notably depending on the server.
28-
matrix: { dbimage: ['mysql:5.7', 'mysql:8.0', 'mariadb:10.7'] }
29-
runs-on: ubuntu-latest
30-
container: swift:5.7-jammy
31-
services:
32-
mysql-a:
33-
image: ${{ matrix.dbimage }}
34-
env:
35-
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
36-
MYSQL_USER: test_username
37-
MYSQL_PASSWORD: test_password
38-
MYSQL_DATABASE: test_database
39-
mysql-b:
40-
image: ${{ matrix.dbimage }}
41-
env:
42-
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
43-
MYSQL_USER: test_username
44-
MYSQL_PASSWORD: test_password
45-
MYSQL_DATABASE: test_database
46-
steps:
47-
- name: Save MySQL version to env
48-
run: |
49-
echo MYSQL_VERSION='${{ matrix.dbimage }}' >> $GITHUB_ENV
50-
- name: Check out package
51-
uses: actions/checkout@v3
52-
- name: Run local tests with coverage
53-
run: swift test --enable-code-coverage
54-
- name: Submit coverage report to Codecov.io
55-
uses: vapor/[email protected]
56-
with:
57-
cc_flags: 'unittests'
58-
cc_env_vars: 'SWIFT_VERSION,SWIFT_PLATFORM,RUNNER_OS,RUNNER_ARCH,MYSQL_VERSION'
59-
cc_fail_ci_if_error: true
60-
cc_verbose: true
61-
cc_dry_run: false
62-
63-
# Check for API breakage versus main
6426
api-breakage:
65-
if: github.event_name == 'pull_request'
27+
if: ${{ !(github.event.pull_request.draft || false) }}
6628
runs-on: ubuntu-latest
6729
container: swift:5.8-jammy
6830
steps:
6931
- name: Check out package
7032
uses: actions/checkout@v3
71-
with:
72-
fetch-depth: 0
73-
# https://github.com/actions/checkout/issues/766
74-
- name: Mark the workspace as safe
75-
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
76-
- name: Check for API breaking changes
77-
run: swift package diagnose-api-breaking-changes origin/main
33+
with: { 'fetch-depth': 0 }
34+
- name: Run API breakage check action
35+
uses: vapor/ci/.github/actions/ci-swift-check-api-breakage@reusable-workflows
7836

79-
# Unit tests (Linux)
8037
linux-unit:
81-
if: ${{ github.event_name == 'pull_request' }}
38+
if: ${{ !(github.event.pull_request.draft || false) }}
8239
strategy:
8340
fail-fast: false
8441
matrix:
8542
dbimage:
8643
- mysql:5.7
8744
- mysql:8.0
8845
- mariadb:10.4
89-
- mariadb:10.11
46+
- mariadb:11
9047
- percona:8.0
9148
runner:
9249
- swift:5.6-focal
@@ -112,33 +69,43 @@ jobs:
11269
MYSQL_PASSWORD: test_password
11370
MYSQL_DATABASE: test_database
11471
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
11581
- name: Check out package
11682
uses: actions/checkout@v3
117-
- name: Run tests with Thread Sanitizer
118-
run: swift test --sanitize=thread
83+
- name: Run tests with Thread Sanitizer and coverage
84+
run: swift test --sanitize=thread --enable-code-coverage
85+
- name: Submit coverage report to Codecov.io
86+
uses: vapor/[email protected]
87+
with:
88+
cc_env_vars: 'SWIFT_VERSION,SWIFT_PLATFORM,RUNNER_OS,RUNNER_ARCH,MYSQL_VERSION'
11989

120-
# Unit tests (macOS)
12190
macos-unit:
122-
if: ${{ github.event_name == 'pull_request' }}
91+
if: ${{ !(github.event.pull_request.draft || false) }}
12392
strategy:
12493
fail-fast: false
12594
matrix:
126-
formula:
127-
128-
macos:
129-
- macos-12
130-
xcode:
131-
- latest-stable
95+
include:
96+
- dbimage: [email protected]
97+
macos: macos-13
98+
xcode: latest-stable
13299
runs-on: ${{ matrix.macos }}
133100
steps:
134101
- name: Select latest available Xcode
135102
uses: maxim-lobanov/setup-xcode@v1
136103
with:
137104
xcode-version: ${{ matrix.xcode }}
138105
- name: Install MySQL server from Homebrew
139-
run: brew install ${{ matrix.formula }} && brew link --force ${{ matrix.formula }}
106+
run: brew install ${{ matrix.dbimage }} && brew link --force ${{ matrix.dbimage }}
140107
- name: Start MySQL server
141-
run: brew services start ${{ matrix.formula }}
108+
run: brew services start ${{ matrix.dbimage }}
142109
- name: Wait for MySQL server to be ready
143110
run: until echo | mysql -uroot; do sleep 1; done
144111
timeout-minutes: 5
@@ -158,15 +125,3 @@ jobs:
158125
MYSQL_HOSTNAME_B: '127.0.0.1'
159126
MYSQL_DATABASE_A: test_database_a
160127
MYSQL_DATABASE_B: test_database_b
161-
162-
test-exports:
163-
name: Test exports
164-
runs-on: ubuntu-latest
165-
container: swift:5.8-jammy
166-
steps:
167-
- name: Check out Vapor
168-
uses: actions/checkout@v3
169-
with:
170-
fetch-depth: 0
171-
- name: Build
172-
run: swift build -Xswiftc -DBUILDING_DOCC

Diff for: Package.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ let package = Package(
1313
.library(name: "FluentMySQLDriver", targets: ["FluentMySQLDriver"]),
1414
],
1515
dependencies: [
16-
.package(url: "https://github.com/vapor/fluent-kit.git", from: "1.27.0"),
17-
.package(url: "https://github.com/vapor/mysql-kit.git", from: "4.0.0"),
18-
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
16+
.package(url: "https://github.com/vapor/fluent-kit.git", from: "1.43.0"),
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.2"),
1919
],
2020
targets: [
2121
.target(name: "FluentMySQLDriver", dependencies: [

Diff for: README.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<img
33
src="https://user-images.githubusercontent.com/1342803/75593351-1176b880-5a53-11ea-96ac-b9212e7471e9.png"
44
height="64"
5-
alt="Fluent MySQL"
5+
alt="FluentMySQLDriver"
66
>
77
<br>
88
<br>
@@ -15,10 +15,13 @@
1515
<a href="LICENSE">
1616
<img src="http://img.shields.io/badge/license-MIT-brightgreen.svg" alt="MIT License">
1717
</a>
18-
<a href="https://github.com/vapor/fluent-mysql-driver/actions">
19-
<img src="https://github.com/vapor/fluent-mysql-driver/workflows/test/badge.svg" alt="Continuous Integration">
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">
2023
</a>
2124
<a href="https://swift.org">
22-
<img src="http://img.shields.io/badge/swift-5.2-brightgreen.svg" alt="Swift 5.2">
25+
<img src="http://img.shields.io/badge/swift-5.6-brightgreen.svg" alt="Swift 5.6">
2326
</a>
2427
</p>

Diff for: Sources/FluentMySQLDriver/MySQLConverterDelegate.swift

-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import FluentSQL
22

33
struct MySQLConverterDelegate: SQLConverterDelegate {
4-
func nestedFieldExpression(_ column: String, _ path: [String]) -> SQLExpression {
5-
let path = path.joined(separator: ".")
6-
return SQLRaw("JSON_EXTRACT(\(column), '$.\(path)')")
7-
}
8-
94
func customDataType(_ dataType: DatabaseSchema.DataType) -> SQLExpression? {
105
switch dataType {
116
case .string: return SQLRaw("VARCHAR(255)")

0 commit comments

Comments
 (0)