Skip to content

Commit

Permalink
Update for the nested subpath changes in FluentKit (#218)
Browse files Browse the repository at this point in the history
Remove no longer needed (well, never needed, really) nested subpath support in SQL converter delegate. General tidying and CI.
  • Loading branch information
gwynne committed Jul 11, 2023
1 parent 3be29eb commit acfd0e7
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 90 deletions.
8 changes: 8 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
@@ -0,0 +1,8 @@
* @gwynne
/.github/CONTRIBUTING.md @gwynne @0xTim
/.github/workflows/*.yml @gwynne @0xTim
/.github/workflows/test.yml @gwynne
/.spi.yml @gwynne @0xTim
/.gitignore @gwynne @0xTim
/LICENSE @gwynne @0xTim
/README.md @gwynne @0xTim
File renamed without changes.
111 changes: 33 additions & 78 deletions .github/workflows/test.yml
@@ -1,10 +1,13 @@
name: test
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request: { branches: ['*'] }
pull_request: { types: [opened, reopened, synchronize, ready_for_review] }
push: { branches: [ main ] }

env:
LOG_LEVEL: debug
LOG_LEVEL: info
SWIFT_DETERMINISTIC_HASHING: 1
MYSQL_HOSTNAME: 'mysql-a'
MYSQL_HOSTNAME_A: 'mysql-a'
Expand All @@ -20,73 +23,27 @@ env:
MYSQL_PASSWORD_B: 'test_password'

jobs:

codecov:
strategy:
# For MySQL we have to run coverage baselines against multiple DB versions thanks to
# the driver's behavior changing notably depending on the server.
matrix: { dbimage: ['mysql:5.7', 'mysql:8.0', 'mariadb:10.7'] }
runs-on: ubuntu-latest
container: swift:5.7-jammy
services:
mysql-a:
image: ${{ matrix.dbimage }}
env:
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
MYSQL_USER: test_username
MYSQL_PASSWORD: test_password
MYSQL_DATABASE: test_database
mysql-b:
image: ${{ matrix.dbimage }}
env:
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
MYSQL_USER: test_username
MYSQL_PASSWORD: test_password
MYSQL_DATABASE: test_database
steps:
- name: Save MySQL version to env
run: |
echo MYSQL_VERSION='${{ matrix.dbimage }}' >> $GITHUB_ENV
- name: Check out package
uses: actions/checkout@v3
- name: Run local tests with coverage
run: swift test --enable-code-coverage
- name: Submit coverage report to Codecov.io
uses: vapor/swift-codecov-action@v0.2
with:
cc_flags: 'unittests'
cc_env_vars: 'SWIFT_VERSION,SWIFT_PLATFORM,RUNNER_OS,RUNNER_ARCH,MYSQL_VERSION'
cc_fail_ci_if_error: true
cc_verbose: true
cc_dry_run: false

# Check for API breakage versus main
api-breakage:
if: github.event_name == 'pull_request'
if: ${{ !(github.event.pull_request.draft || false) }}
runs-on: ubuntu-latest
container: swift:5.8-jammy
steps:
- name: Check out package
uses: actions/checkout@v3
with:
fetch-depth: 0
# https://github.com/actions/checkout/issues/766
- name: Mark the workspace as safe
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
- name: Check for API breaking changes
run: swift package diagnose-api-breaking-changes origin/main
with: { 'fetch-depth': 0 }
- name: Run API breakage check action
uses: vapor/ci/.github/actions/ci-swift-check-api-breakage@reusable-workflows

# Unit tests (Linux)
linux-unit:
if: ${{ github.event_name == 'pull_request' }}
if: ${{ !(github.event.pull_request.draft || false) }}
strategy:
fail-fast: false
matrix:
dbimage:
- mysql:5.7
- mysql:8.0
- mariadb:10.4
- mariadb:10.11
- mariadb:11
- percona:8.0
runner:
- swift:5.6-focal
Expand All @@ -112,33 +69,43 @@ 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
run: swift test --sanitize=thread
- name: Run tests with Thread Sanitizer and coverage
run: swift test --sanitize=thread --enable-code-coverage
- name: Submit coverage report to Codecov.io
uses: vapor/swift-codecov-action@v0.2
with:
cc_env_vars: 'SWIFT_VERSION,SWIFT_PLATFORM,RUNNER_OS,RUNNER_ARCH,MYSQL_VERSION'

# Unit tests (macOS)
macos-unit:
if: ${{ github.event_name == 'pull_request' }}
if: ${{ !(github.event.pull_request.draft || false) }}
strategy:
fail-fast: false
matrix:
formula:
- mysql@8.0
macos:
- macos-12
xcode:
- latest-stable
include:
- dbimage: mysql@8.0
macos: macos-13
xcode: latest-stable
runs-on: ${{ matrix.macos }}
steps:
- name: Select latest available Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ matrix.xcode }}
- name: Install MySQL server from Homebrew
run: brew install ${{ matrix.formula }} && brew link --force ${{ matrix.formula }}
run: brew install ${{ matrix.dbimage }} && brew link --force ${{ matrix.dbimage }}
- name: Start MySQL server
run: brew services start ${{ matrix.formula }}
run: brew services start ${{ matrix.dbimage }}
- name: Wait for MySQL server to be ready
run: until echo | mysql -uroot; do sleep 1; done
timeout-minutes: 5
Expand All @@ -158,15 +125,3 @@ jobs:
MYSQL_HOSTNAME_B: '127.0.0.1'
MYSQL_DATABASE_A: test_database_a
MYSQL_DATABASE_B: test_database_b

test-exports:
name: Test exports
runs-on: ubuntu-latest
container: swift:5.8-jammy
steps:
- name: Check out Vapor
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Build
run: swift build -Xswiftc -DBUILDING_DOCC
6 changes: 3 additions & 3 deletions Package.swift
Expand Up @@ -13,9 +13,9 @@ let package = Package(
.library(name: "FluentMySQLDriver", targets: ["FluentMySQLDriver"]),
],
dependencies: [
.package(url: "https://github.com/vapor/fluent-kit.git", from: "1.27.0"),
.package(url: "https://github.com/vapor/mysql-kit.git", from: "4.0.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
.package(url: "https://github.com/vapor/fluent-kit.git", from: "1.43.0"),
.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.2"),
],
targets: [
.target(name: "FluentMySQLDriver", dependencies: [
Expand Down
11 changes: 7 additions & 4 deletions README.md
Expand Up @@ -2,7 +2,7 @@
<img
src="https://user-images.githubusercontent.com/1342803/75593351-1176b880-5a53-11ea-96ac-b9212e7471e9.png"
height="64"
alt="Fluent MySQL"
alt="FluentMySQLDriver"
>
<br>
<br>
Expand All @@ -15,10 +15,13 @@
<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">
<img src="https://github.com/vapor/fluent-mysql-driver/workflows/test/badge.svg" alt="Continuous Integration">
<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.2-brightgreen.svg" alt="Swift 5.2">
<img src="http://img.shields.io/badge/swift-5.6-brightgreen.svg" alt="Swift 5.6">
</a>
</p>
5 changes: 0 additions & 5 deletions Sources/FluentMySQLDriver/MySQLConverterDelegate.swift
@@ -1,11 +1,6 @@
import FluentSQL

struct MySQLConverterDelegate: SQLConverterDelegate {
func nestedFieldExpression(_ column: String, _ path: [String]) -> SQLExpression {
let path = path.joined(separator: ".")
return SQLRaw("JSON_EXTRACT(\(column), '$.\(path)')")
}

func customDataType(_ dataType: DatabaseSchema.DataType) -> SQLExpression? {
switch dataType {
case .string: return SQLRaw("VARCHAR(255)")
Expand Down

0 comments on commit acfd0e7

Please sign in to comment.