Skip to content

fix: add CSQLite system library for Linux SQLite3 support #2

fix: add CSQLite system library for Linux SQLite3 support

fix: add CSQLite system library for Linux SQLite3 support #2

Workflow file for this run

name: CI
on:
push:
branches: [main, develop]
paths-ignore:
- '**.md'
- '.spi.yml'
- 'Sources/**/*.docc/**'
pull_request:
branches: [main]
paths-ignore:
- '**.md'
- '.spi.yml'
- 'Sources/**/*.docc/**'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# ─────────────────────────────────────────────────────────────────────────────
# Environment variables shared across all jobs
# ─────────────────────────────────────────────────────────────────────────────
env:
SWIFT_VERSION: "6.0"
jobs:
# ───────────────────────────────────────────────────────────────────────────
# 1. Build + SQLite tests — macOS and Linux, multiple Swift versions
# No Docker needed — SQLite uses an in-memory database.
# ───────────────────────────────────────────────────────────────────────────
test-sqlite:
name: SQLite — ${{ matrix.os }} / Swift ${{ matrix.swift }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-15, ubuntu-24.04]
swift: ["5.10", "6.0"]
exclude:
# macOS 15 ships with Swift 6 (Xcode 16); skip redundant 5.10 run
- os: macos-15
swift: "5.10"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Swift ${{ matrix.swift }}
if: runner.os == 'Linux'
uses: swift-actions/setup-swift@v2
with:
swift-version: ${{ matrix.swift }}
- name: Cache SPM
uses: actions/cache@v4
with:
path: .build
key: ${{ runner.os }}-spm-${{ matrix.swift }}-${{ hashFiles('Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-${{ matrix.swift }}-
- name: Install SQLite (Linux)
if: runner.os == 'Linux'
run: sudo apt-get install -y libsqlite3-dev
- name: Build
run: swift build --configuration debug 2>&1
- name: Run SQLite tests
run: swift test --filter SQLiteNioTests 2>&1
- name: Run Core tests
run: swift test --filter SQLNioCoreTests 2>&1
# ───────────────────────────────────────────────────────────────────────────
# 2. SQL Server integration tests
# Uses GitHub Actions service container — Linux only.
# ───────────────────────────────────────────────────────────────────────────
test-mssql:
name: SQL Server integration tests
runs-on: ubuntu-24.04
services:
mssql:
image: mcr.microsoft.com/mssql/server:2022-latest
env:
ACCEPT_EULA: "Y"
SA_PASSWORD: "aBCD111!"
MSSQL_PID: Developer
ports:
- 1433:1433
options: >-
--health-cmd "/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P 'aBCD111!' -Q 'SELECT 1' -C"
--health-interval 10s
--health-timeout 5s
--health-retries 15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Swift
uses: swift-actions/setup-swift@v2
with:
swift-version: ${{ env.SWIFT_VERSION }}
- name: Install SQLite
run: sudo apt-get install -y libsqlite3-dev
- name: Cache SPM
uses: actions/cache@v4
with:
path: .build
key: ${{ runner.os }}-spm-mssql-${{ hashFiles('Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-mssql-
- name: Create test database
run: |
until /opt/mssql-tools18/bin/sqlcmd -S 127.0.0.1 -U sa -P 'aBCD111!' -C \
-Q "CREATE DATABASE MSSQLNioTestDb" 2>/dev/null; do
echo "Waiting for SQL Server..."; sleep 3
done
- name: Run MSSQL tests
env:
MSSQL_TEST_HOST: "127.0.0.1"
MSSQL_TEST_PASS: "aBCD111!"
MSSQL_TEST_DB: "MSSQLNioTestDb"
MSSQL_TEST_USER: "sa"
run: swift test --filter MSSQLNioTests 2>&1
# ───────────────────────────────────────────────────────────────────────────
# 3. PostgreSQL integration tests
# ───────────────────────────────────────────────────────────────────────────
test-postgres:
name: PostgreSQL integration tests
runs-on: ubuntu-24.04
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_DB: PostgresNioTestDb
POSTGRES_USER: pguser
POSTGRES_PASSWORD: pgPass123
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U pguser"
--health-interval 5s
--health-timeout 3s
--health-retries 10
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Swift
uses: swift-actions/setup-swift@v2
with:
swift-version: ${{ env.SWIFT_VERSION }}
- name: Install SQLite
run: sudo apt-get install -y libsqlite3-dev
- name: Cache SPM
uses: actions/cache@v4
with:
path: .build
key: ${{ runner.os }}-spm-pg-${{ hashFiles('Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-pg-
- name: Run PostgreSQL tests
env:
PG_TEST_HOST: "127.0.0.1"
PG_TEST_DB: PostgresNioTestDb
PG_TEST_USER: pguser
PG_TEST_PASS: pgPass123
run: swift test --filter PostgresNioTests 2>&1
# ───────────────────────────────────────────────────────────────────────────
# 4. MySQL integration tests
# ───────────────────────────────────────────────────────────────────────────
test-mysql:
name: MySQL integration tests
runs-on: ubuntu-24.04
services:
mysql:
image: mysql:8
env:
MYSQL_DATABASE: MySQLNioTestDb
MYSQL_USER: mysqluser
MYSQL_PASSWORD: mysqlPass123
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: >-
--health-cmd "mysqladmin ping -u mysqluser -pmysqlPass123"
--health-interval 5s
--health-timeout 3s
--health-retries 15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Swift
uses: swift-actions/setup-swift@v2
with:
swift-version: ${{ env.SWIFT_VERSION }}
- name: Install SQLite
run: sudo apt-get install -y libsqlite3-dev
- name: Cache SPM
uses: actions/cache@v4
with:
path: .build
key: ${{ runner.os }}-spm-mysql-${{ hashFiles('Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-mysql-
- name: Run MySQL tests
env:
MYSQL_TEST_HOST: "127.0.0.1"
MYSQL_TEST_DB: MySQLNioTestDb
MYSQL_TEST_USER: mysqluser
MYSQL_TEST_PASS: mysqlPass123
run: swift test --filter MySQLNioTests 2>&1
# ───────────────────────────────────────────────────────────────────────────
# 5. Summary / Required status check
# PRs cannot be merged until all four test jobs pass.
# ───────────────────────────────────────────────────────────────────────────
ci-success:
name: All tests passed
runs-on: ubuntu-24.04
needs: [test-sqlite, test-mssql, test-postgres, test-mysql]
if: always()
steps:
- name: Check results
run: |
if [[ "${{ needs.test-sqlite.result }}" != "success" || \
"${{ needs.test-mssql.result }}" != "success" || \
"${{ needs.test-postgres.result }}" != "success" || \
"${{ needs.test-mysql.result }}" != "success" ]]; then
echo "One or more test jobs failed."
exit 1
fi
echo "All test jobs passed."