Skip to content

Commit

Permalink
Configure SQLiteConnectionSource with Database ID vapor#55
Browse files Browse the repository at this point in the history
  • Loading branch information
gwynne authored and runner committed May 16, 2020
1 parent a95577d commit ab373a8
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 24 deletions.
67 changes: 45 additions & 22 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,49 @@
name: test
on:
- pull_request
name: Test Matrix
on: ['pull_request']
jobs:
fluent-sqlite-driver_macos:
runs-on: macos-latest
steps:
- run: sudo xcode-select -s /Applications/Xcode_11.4.app/Contents/Developer
- uses: actions/checkout@v2
- run: xcrun swift test --enable-test-discovery --sanitize=thread
fluent-sqlite-driver_bionic:
container:
image: vapor/swift:5.2-bionic-ci
PR-tests-linux:
strategy:
fail-fast: false
matrix:
runner: [
'swift:5.2-xenial', 'swift:5.2-bionic',
'swiftlang/swift:nightly-5.2-xenial', 'swiftlang/swift:nightly-5.2-bionic',
'swiftlang/swift:nightly-5.3-xenial', 'swiftlang/swift:nightly-5.3-bionic',
'swiftlang/swift:nightly-master-xenial', 'swiftlang/swift:nightly-master-bionic',
'swiftlang/swift:nightly-master-focal',
'swiftlang/swift:nightly-master-centos8',
'swiftlang/swift:nightly-master-amazonlinux2'
]
include:
- installcmd: 'apt-get -q update && apt-get -q install -y libsqlite3-dev'
- { 'runner': 'swiftlang/swift:nightly-master-centos8', 'installcmd': 'dnf install -y zlib-devel sqlite-devel' }
- { 'runner': 'swiftlang/swift:nightly-master-amazonlinux2', 'installcmd': 'yum install -y zlib-devel sqlite-devel' }
container: ${{ matrix.runner }}
runs-on: ubuntu-latest
steps:
- run: apt update -y; apt install -y libsqlite3-dev
- uses: actions/checkout@v2
- run: swift test --enable-test-discovery --sanitize=thread
fluent-sqlite-driver_xenial:
container:
image: vapor/swift:5.2-xenial-ci
runs-on: ubuntu-latest
- name: Install dependencies
run: ${{ matrix.installcmd }}
- name: Update AmazonLinux2's too-old SQLite
if: ${{ endsWith(matrix.runner, 'amazonlinux2') }}
working-directory: /root
# Cribbed from the Fedora RPM, leaves out a lot. System's Tcl is too old to run SQLite's tests.
run: |
yum install -y file tcl-devel make
curl -L 'https://www.sqlite.org/src/tarball/sqlite.tar.gz?r=release' | tar xz && cd sqlite
export CFLAGS="-DSQLITE_DISABLE_DIRSYNC=1 -DSQLITE_SECURE_DELETE=1"
./configure --prefix=/usr --libdir=/usr/lib64 --enable-fts3 --enable-all --with-tcl=/usr/lib64
make all install
- name: Check out code
uses: actions/checkout@v2
- name: Run tests with Thread Sanitizer
run: swift test --enable-test-discovery --sanitize=thread
PR-tests-macos:
runs-on: macos-latest
steps:
- run: apt update -y; apt install -y libsqlite3-dev
- uses: actions/checkout@v2
- run: swift test --enable-test-discovery --sanitize=thread
- name: Select latest available Xcode
uses: maxim-lobanov/setup-xcode@1.0
with: { 'xcode-version': 'latest' }
- name: Check out code
uses: actions/checkout@v2
- name: Run tests with Thread Sanitizer
run: swift test --enable-test-discovery --sanitize=thread
11 changes: 9 additions & 2 deletions Tests/FluentSQLiteDriverTests/FluentSQLiteDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,18 @@ final class FluentSQLiteDriverTests: XCTestCase {
var eventLoopGroup: EventLoopGroup!
var dbs: Databases!

let benchmarkPath = FileManager.default.temporaryDirectory.appendingPathComponent("benchmark.sqlite").absoluteString

override func setUpWithError() throws {
try super.setUpWithError()

XCTAssert(isLoggingConfigured)
self.eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1)
self.threadPool = .init(numberOfThreads: 2)
self.threadPool.start()
self.dbs = Databases(threadPool: self.threadPool, on: self.eventLoopGroup)
self.dbs.use(.sqlite(.memory), as: .sqlite)
self.dbs.use(.sqlite(.file(self.benchmarkPath)), as: .benchmark)
}

override func tearDownWithError() throws {
Expand All @@ -94,7 +97,7 @@ final class FluentSQLiteDriverTests: XCTestCase {
self.threadPool = nil
try self.eventLoopGroup.syncShutdownGracefully()
self.eventLoopGroup = nil

try super.tearDownWithError()
}
}
Expand All @@ -107,3 +110,7 @@ let isLoggingConfigured: Bool = {
}
return true
}()

extension DatabaseID {
static let benchmark = DatabaseID(string: "benchmark")
}

0 comments on commit ab373a8

Please sign in to comment.