Skip to content

Commit f4933c5

Browse files
Merge pull request #55 from vapor/configure-database-id
Configure SQLiteConnectionSource with Database ID
2 parents 6cd8f11 + d53ef9c commit f4933c5

File tree

3 files changed

+55
-25
lines changed

3 files changed

+55
-25
lines changed

.github/workflows/test.yml

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,49 @@
1-
name: test
2-
on:
3-
- pull_request
1+
name: Test Matrix
2+
on: ['pull_request']
43
jobs:
5-
fluent-sqlite-driver_macos:
6-
runs-on: macos-latest
7-
steps:
8-
- run: sudo xcode-select -s /Applications/Xcode_11.4.app/Contents/Developer
9-
- uses: actions/checkout@v2
10-
- run: xcrun swift test --enable-test-discovery --sanitize=thread
11-
fluent-sqlite-driver_bionic:
12-
container:
13-
image: vapor/swift:5.2-bionic-ci
4+
PR-tests-linux:
5+
strategy:
6+
fail-fast: false
7+
matrix:
8+
runner: [
9+
'swift:5.2-xenial', 'swift:5.2-bionic',
10+
'swiftlang/swift:nightly-5.2-xenial', 'swiftlang/swift:nightly-5.2-bionic',
11+
'swiftlang/swift:nightly-5.3-xenial', 'swiftlang/swift:nightly-5.3-bionic',
12+
'swiftlang/swift:nightly-master-xenial', 'swiftlang/swift:nightly-master-bionic',
13+
'swiftlang/swift:nightly-master-focal',
14+
'swiftlang/swift:nightly-master-centos8',
15+
'swiftlang/swift:nightly-master-amazonlinux2'
16+
]
17+
include:
18+
- installcmd: 'apt-get -q update && apt-get -q install -y libsqlite3-dev'
19+
- { 'runner': 'swiftlang/swift:nightly-master-centos8', 'installcmd': 'dnf install -y zlib-devel sqlite-devel' }
20+
- { 'runner': 'swiftlang/swift:nightly-master-amazonlinux2', 'installcmd': 'yum install -y zlib-devel sqlite-devel' }
21+
container: ${{ matrix.runner }}
1422
runs-on: ubuntu-latest
1523
steps:
16-
- run: apt update -y; apt install -y libsqlite3-dev
17-
- uses: actions/checkout@v2
18-
- run: swift test --enable-test-discovery --sanitize=thread
19-
fluent-sqlite-driver_xenial:
20-
container:
21-
image: vapor/swift:5.2-xenial-ci
22-
runs-on: ubuntu-latest
24+
- name: Install dependencies
25+
run: ${{ matrix.installcmd }}
26+
- name: Update AmazonLinux2's too-old SQLite
27+
if: ${{ endsWith(matrix.runner, 'amazonlinux2') }}
28+
working-directory: /root
29+
# Cribbed from the Fedora RPM, leaves out a lot. System's Tcl is too old to run SQLite's tests.
30+
run: |
31+
yum install -y file tcl-devel make
32+
curl -L 'https://www.sqlite.org/src/tarball/sqlite.tar.gz?r=release' | tar xz && cd sqlite
33+
export CFLAGS="-DSQLITE_DISABLE_DIRSYNC=1 -DSQLITE_SECURE_DELETE=1"
34+
./configure --prefix=/usr --libdir=/usr/lib64 --enable-fts3 --enable-all --with-tcl=/usr/lib64
35+
make all install
36+
- name: Check out code
37+
uses: actions/checkout@v2
38+
- name: Run tests with Thread Sanitizer
39+
run: swift test --enable-test-discovery --sanitize=thread
40+
PR-tests-macos:
41+
runs-on: macos-latest
2342
steps:
24-
- run: apt update -y; apt install -y libsqlite3-dev
25-
- uses: actions/checkout@v2
26-
- run: swift test --enable-test-discovery --sanitize=thread
43+
- name: Select latest available Xcode
44+
uses: maxim-lobanov/setup-xcode@1.0
45+
with: { 'xcode-version': 'latest' }
46+
- name: Check out code
47+
uses: actions/checkout@v2
48+
- name: Run tests with Thread Sanitizer
49+
run: swift test --enable-test-discovery --sanitize=thread

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ let package = Package(
1010
.library(name: "FluentSQLiteDriver", targets: ["FluentSQLiteDriver"]),
1111
],
1212
dependencies: [
13-
.package(url: "https://github.com/vapor/fluent-kit.git", from: "1.0.0-rc.1"),
13+
.package(url: "https://github.com/vapor/fluent-kit.git", .from: "1.0.0-rc.1"),
1414
.package(url: "https://github.com/vapor/sqlite-kit.git", from: "4.0.0-rc.1"),
1515
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
1616
],

Tests/FluentSQLiteDriverTests/FluentSQLiteDriverTests.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,18 @@ final class FluentSQLiteDriverTests: XCTestCase {
7676
var eventLoopGroup: EventLoopGroup!
7777
var dbs: Databases!
7878

79+
let benchmarkPath = FileManager.default.temporaryDirectory.appendingPathComponent("benchmark.sqlite").absoluteString
80+
7981
override func setUpWithError() throws {
8082
try super.setUpWithError()
81-
83+
8284
XCTAssert(isLoggingConfigured)
8385
self.eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1)
8486
self.threadPool = .init(numberOfThreads: 2)
8587
self.threadPool.start()
8688
self.dbs = Databases(threadPool: self.threadPool, on: self.eventLoopGroup)
8789
self.dbs.use(.sqlite(.memory), as: .sqlite)
90+
self.dbs.use(.sqlite(.file(self.benchmarkPath)), as: .benchmark)
8891
}
8992

9093
override func tearDownWithError() throws {
@@ -94,7 +97,7 @@ final class FluentSQLiteDriverTests: XCTestCase {
9497
self.threadPool = nil
9598
try self.eventLoopGroup.syncShutdownGracefully()
9699
self.eventLoopGroup = nil
97-
100+
98101
try super.tearDownWithError()
99102
}
100103
}
@@ -111,3 +114,7 @@ let isLoggingConfigured: Bool = {
111114
}
112115
return true
113116
}()
117+
118+
extension DatabaseID {
119+
static let benchmark = DatabaseID(string: "benchmark")
120+
}

0 commit comments

Comments
 (0)