Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
2778f1f
updated deps
viaszkadi Apr 15, 2024
7ff7155
formatted
viaszkadi Apr 15, 2024
b044aee
Update run-tests.yml
viaszkadi Apr 15, 2024
37069b7
updated workflow
viaszkadi Apr 16, 2024
4a63534
updated test workflow
viaszkadi Apr 16, 2024
56d6b01
updated workflow
viaszkadi Apr 17, 2024
d7d1124
formatted
viaszkadi Apr 17, 2024
b3f53d8
updated workflow
viaszkadi Apr 17, 2024
a3a8e3f
updated workflow
viaszkadi Apr 17, 2024
cf451ce
updated workflow
viaszkadi Apr 17, 2024
3f8c60c
updated workflow
viaszkadi Apr 17, 2024
763adef
updated workflow
viaszkadi Apr 17, 2024
ff48ba0
updated workflow
viaszkadi Apr 17, 2024
b56ba49
updated workflow
viaszkadi Apr 17, 2024
d971a7e
updated workflow
viaszkadi Apr 17, 2024
a2c4244
updated workflow
viaszkadi Apr 17, 2024
4a2de61
updated workflow
viaszkadi Apr 17, 2024
24cab09
updated workflow
viaszkadi Apr 17, 2024
c2c96e1
updated workflow
viaszkadi Apr 17, 2024
78d0f40
updated workflow
viaszkadi Apr 17, 2024
d9c2cf1
updated workflow
viaszkadi Apr 17, 2024
b5f1aa6
updated workflow
viaszkadi Apr 17, 2024
846473c
updated workflow
viaszkadi Apr 17, 2024
80e56f8
updated workflow
viaszkadi Apr 17, 2024
bd5a133
updated workflow
viaszkadi Apr 17, 2024
63f379e
updated workflow
viaszkadi Apr 17, 2024
6078353
updated workflow
viaszkadi Apr 17, 2024
b01bdbb
updated workflow
viaszkadi Apr 17, 2024
8ef676c
updated workflow
viaszkadi Apr 17, 2024
e0d0986
updated workflow
viaszkadi Apr 17, 2024
302997b
updated workflow
viaszkadi Apr 17, 2024
9ceb12a
updated workflow
viaszkadi Apr 17, 2024
b6ffbab
updated workflow
viaszkadi Apr 17, 2024
54e8b89
updated workflow
viaszkadi Apr 17, 2024
d64483c
updated workflow
viaszkadi Apr 17, 2024
6f45af7
updated workflow
viaszkadi Apr 17, 2024
7efa3a8
updated workflow
viaszkadi Apr 17, 2024
e76711c
updated workflow
viaszkadi Apr 18, 2024
681a262
updated workflow
viaszkadi Apr 18, 2024
01c51f6
updated workflow
viaszkadi Apr 18, 2024
fdfd41c
updated workflow
viaszkadi Apr 18, 2024
5d555f7
updated workflow
viaszkadi Apr 18, 2024
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
26 changes: 26 additions & 0 deletions .github/workflows/run-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Run checks

on:
pull_request:
branches:
- main

jobs:

run-checks:
# runs-on: macOS-latest
runs-on: self-hosted
steps:

- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Install Dependencies
run: |
brew install mint
mint install NickLockwood/[email protected] --no-link

- name: run script
run: ./scripts/run-checks.sh
73 changes: 73 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Run tests

on:
push:
branches:
- main
paths:
- '**.swift'
pull_request:
branches:
- main

jobs:
linux-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
swift:
- 'swift:5.9'
- 'swift:5.10'
database:
- mysql:8.2
container:
image: ${{ matrix.swift }}
services:
mysql:
image: ${{ matrix.database }}
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_HOST: 127.0.0.1
MYSQL_DATABASE: test_database
MYSQL_USER: test_user
MYSQL_PASSWORD: test_password
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Test
env:
MYSQL_HOST: mysql
MYSQL_DB: test_database
MYSQL_USER: test_user
MYSQL_PASS: test_password
run: swift test --parallel --enable-code-coverage
macOS-tests:
runs-on: self-hosted
steps:
- name: Setup MySQL DB
shell: bash
env:
MYSQL_DATABASE: ${{ secrets.MYSQL_DATABASE }}
MYSQL_USER: ${{ secrets.MYSQL_USER }}
MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}
run: |
brew install mysql && brew link --force mysql
brew services start mysql
until echo | mysql -u root; do sleep 1; done
mysql -u root --batch <<-SQL
CREATE USER IF NOT EXISTS ${MYSQL_USER}@localhost IDENTIFIED BY '${MYSQL_PASSWORD}';
DROP DATABASE IF EXISTS ${MYSQL_DATABASE};
CREATE DATABASE ${MYSQL_DATABASE};
GRANT ALL PRIVILEGES ON ${MYSQL_DATABASE}.* TO ${MYSQL_USER}@localhost;
SQL
- name: Checkout
uses: actions/checkout@v4
- name: Test
env:
MYSQL_HOST: ${{ secrets.MYSQL_HOST }}
MYSQL_DB: ${{ secrets.MYSQL_DATABASE }}
MYSQL_USER: ${{ secrets.MYSQL_USER }}
MYSQL_PASS: ${{ secrets.MYSQL_PASSWORD }}
run: swift test --parallel --enable-code-coverage
114 changes: 60 additions & 54 deletions .swift-format
Original file line number Diff line number Diff line change
@@ -1,58 +1,64 @@
{
"fileScopedDeclarationPrivacy" : {
"accessLevel" : "private"
"version": 1,
"lineLength": 80,
"maximumBlankLines": 1,
"fileScopedDeclarationPrivacy": {
"accessLevel": "private"
},
"indentation" : {
"spaces" : 4
"tabWidth": 4,
"indentation": {
"spaces": 4
},
"indentConditionalCompilationBlocks" : false,
"indentSwitchCaseLabels" : false,
"lineBreakAroundMultilineExpressionChainComponents" : true,
"lineBreakBeforeControlFlowKeywords" : true,
"lineBreakBeforeEachArgument" : true,
"lineBreakBeforeEachGenericRequirement" : true,
"lineLength" : 80,
"maximumBlankLines" : 1,
"prioritizeKeepingFunctionOutputTogether" : false,
"respectsExistingLineBreaks" : true,
"rules" : {
"AllPublicDeclarationsHaveDocumentation" : true,
"AlwaysUseLowerCamelCase" : false,
"AmbiguousTrailingClosureOverload" : true,
"BeginDocumentationCommentWithOneLineSummary" : false,
"DoNotUseSemicolons" : true,
"DontRepeatTypeInStaticProperties" : false,
"FileScopedDeclarationPrivacy" : true,
"FullyIndirectEnum" : true,
"GroupNumericLiterals" : true,
"IdentifiersMustBeASCII" : true,
"NeverForceUnwrap" : false,
"NeverUseForceTry" : false,
"NeverUseImplicitlyUnwrappedOptionals" : false,
"NoAccessLevelOnExtensionDeclaration" : false,
"NoAssignmentInExpressions" : true,
"NoBlockComments" : true,
"NoCasesWithOnlyFallthrough" : true,
"NoEmptyTrailingClosureParentheses" : true,
"NoLabelsInCasePatterns" : false,
"NoLeadingUnderscores" : false,
"NoParensAroundConditions" : true,
"NoVoidReturnOnFunctionSignature" : true,
"OneCasePerLine" : true,
"OneVariableDeclarationPerLine" : true,
"OnlyOneTrailingClosureArgument" : true,
"OrderedImports" : false,
"ReturnVoidInsteadOfEmptyTuple" : true,
"UseEarlyExits" : false,
"UseLetInEveryBoundCaseVariable" : false,
"UseShorthandTypeNames" : true,
"UseSingleLinePropertyGetter" : false,
"UseSynthesizedInitializer" : true,
"UseTripleSlashForDocumentationComments" : true,
"UseWhereClausesInForLoops" : false,
"ValidateDocumentationComments" : true
},
"spacesAroundRangeFormationOperators" : false,
"tabWidth" : 4,
"version" : 1
"indentConditionalCompilationBlocks": false,
"indentSwitchCaseLabels": false,
"lineBreakAroundMultilineExpressionChainComponents": true,
"lineBreakBeforeControlFlowKeywords": true,
"lineBreakBeforeEachArgument": true,
"lineBreakBeforeEachGenericRequirement": true,
"prioritizeKeepingFunctionOutputTogether": false,
"respectsExistingLineBreaks": true,
"spacesAroundRangeFormationOperators": false,
"multiElementCollectionTrailingCommas": true,
"rules": {
"AllPublicDeclarationsHaveDocumentation": false,
"AlwaysUseLiteralForEmptyCollectionInit": true,
"AlwaysUseLowerCamelCase": false,
"AmbiguousTrailingClosureOverload": true,
"BeginDocumentationCommentWithOneLineSummary": true,
"DoNotUseSemicolons": true,
"DontRepeatTypeInStaticProperties": true,
"FileScopedDeclarationPrivacy": true,
"FullyIndirectEnum": true,
"GroupNumericLiterals": true,
"IdentifiersMustBeASCII": true,
"NeverForceUnwrap": false,
"NeverUseForceTry": true,
"NeverUseImplicitlyUnwrappedOptionals": true,
"NoAccessLevelOnExtensionDeclaration": true,
"NoAssignmentInExpressions": true,
"NoBlockComments": true,
"NoCasesWithOnlyFallthrough": true,
"NoEmptyTrailingClosureParentheses": true,
"NoLabelsInCasePatterns": true,
"NoLeadingUnderscores": true,
"NoParensAroundConditions": true,
"NoPlaygroundLiterals": true,
"NoVoidReturnOnFunctionSignature": true,
"OmitExplicitReturns": true,
"OneCasePerLine": true,
"OneVariableDeclarationPerLine": true,
"OnlyOneTrailingClosureArgument": true,
"OrderedImports": true,
"ReplaceForEachWithForLoop": true,
"ReturnVoidInsteadOfEmptyTuple": true,
"TypeNamesShouldBeCapitalized": true,
"UseEarlyExits": true,
"UseLetInEveryBoundCaseVariable": true,
"UseShorthandTypeNames": true,
"UseSingleLinePropertyGetter": true,
"UseSynthesizedInitializer": true,
"UseTripleSlashForDocumentationComments": true,
"UseWhereClausesInForLoops": true,
"ValidateDocumentationComments": true
}
}
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
SHELL=/bin/bash

build:
swift build

Expand All @@ -13,5 +15,8 @@ test-with-coverage:
clean:
rm -rf .build

check:
./scripts/run-checks.sh

format:
swift-format -i -r ./Sources && swift-format -i -r ./Tests
./scripts/run-swift-format.sh --fix
26 changes: 4 additions & 22 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let package = Package(
.library(name: "FeatherRelationalDatabaseDriverMySQL", targets: ["FeatherRelationalDatabaseDriverMySQL"]),
],
dependencies: [
.package(url: "https://github.com/feather-framework/feather-relational-database", .upToNextMinor(from: "0.2.0")),
.package(url: "https://github.com/feather-framework/feather-relational-database", .upToNextMinor(from: "0.3.0")),
.package(url: "https://github.com/vapor/mysql-kit", from: "4.7.0"),
],
targets: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,27 @@
// Created by Tibor Bodecs on 03/12/2023.
//

import AsyncKit
import FeatherComponent
import FeatherRelationalDatabase
import SQLKit
import MySQLKit
@preconcurrency import AsyncKit
import SQLKit

@dynamicMemberLookup
struct MySQLRelationalDatabaseComponent: RelationalDatabaseComponent {

public let config: ComponentConfig
let pool: EventLoopGroupConnectionPool<MySQLConnectionSource>

subscript<T>(
dynamicMember keyPath: KeyPath<MySQLRelationalDatabaseComponentContext, T>
dynamicMember keyPath: KeyPath<
MySQLRelationalDatabaseComponentContext, T
>
) -> T {
let context = config.context as! MySQLRelationalDatabaseComponentContext
return context[keyPath: keyPath]
}

init(
config: ComponentConfig,
pool: EventLoopGroupConnectionPool<MySQLConnectionSource>
) {
self.config = config
self.pool = pool
}

public func connection() async throws -> SQLKit.SQLDatabase {
pool.database(logger: self.logger).sql()
self.pool.database(logger: self.logger).sql()
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// SQLDatabaseContext.swift
// FeatherComponentTests
//
// Created by Tibor Bodecs on 18/11/2023.
//

import FeatherComponent
@preconcurrency import MySQLKit

public struct MySQLRelationalDatabaseComponentContext: ComponentContext {

let pool: EventLoopGroupConnectionPool<MySQLConnectionSource>

public init(
pool: EventLoopGroupConnectionPool<MySQLConnectionSource>
) {
self.pool = pool
}

public func make() throws -> ComponentFactory {
MySQLRelationalDatabaseComponentFactory(context: self)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// SQLDatabaseDriver.swift
// FeatherComponentTests
//
// Created by Tibor Bodecs on 18/11/2023.
//

import AsyncKit
import FeatherComponent
import MySQLKit

struct MySQLRelationalDatabaseComponentFactory: ComponentFactory {

let context: MySQLRelationalDatabaseComponentContext

func build(using config: ComponentConfig) throws -> Component {
MySQLRelationalDatabaseComponent(config: config)
}
}
Loading