Skip to content

fix: add --batch to gpg in Install sqlcmd step to avoid /dev/tty error #14

fix: add --batch to gpg in Install sqlcmd step to avoid /dev/tty error

fix: add --batch to gpg in Install sqlcmd step to avoid /dev/tty error #14

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: ["6.0"]
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
# Connects to Mac via frpc tunnel on VPS (no service container).
# ───────────────────────────────────────────────────────────────────────────
test-mssql:
name: SQL Server integration tests
runs-on: ubuntu-24.04
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: Install sqlcmd
run: |
curl -fsSL https://packages.microsoft.com/keys/microsoft.asc \
| sudo gpg --batch --dearmor -o /usr/share/keyrings/microsoft-prod.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft-prod.gpg] \
https://packages.microsoft.com/ubuntu/24.04/prod noble main" \
| sudo tee /etc/apt/sources.list.d/mssql-release.list
sudo apt-get update -q
sudo ACCEPT_EULA=Y apt-get install -y sqlcmd
- 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: |
sqlcmd -S "${{ secrets.DB_HOST }},1433" -U sa \
-P "${{ secrets.MSSQL_TEST_PASS }}" \
--trust-server-certificate \
-Q "IF DB_ID('MSSQLNioTestDb') IS NULL CREATE DATABASE MSSQLNioTestDb"
- name: Seed SQL Server database
run: |
sqlcmd -S "${{ secrets.DB_HOST }},1433" -U sa \
-P "${{ secrets.MSSQL_TEST_PASS }}" \
--trust-server-certificate \
-i Tests/Resources/mssql_seed.sql
- name: Run MSSQL tests
env:
MSSQL_TEST_HOST: ${{ secrets.DB_HOST }}
MSSQL_TEST_PASS: ${{ secrets.MSSQL_TEST_PASS }}
MSSQL_TEST_DB: "MSSQLNioTestDb"
MSSQL_TEST_USER: "sa"
run: swift test --filter MSSQLNioTests 2>&1
# ───────────────────────────────────────────────────────────────────────────
# 3. PostgreSQL integration tests
# Connects to Mac via frpc tunnel on VPS (no service container).
# ───────────────────────────────────────────────────────────────────────────
test-postgres:
name: PostgreSQL integration tests
runs-on: ubuntu-24.04
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 and psql
run: sudo apt-get install -y libsqlite3-dev postgresql-client
- 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: Seed PostgreSQL database
run: |
PGPASSWORD="${{ secrets.PG_TEST_PASS }}" psql \
-h "${{ secrets.DB_HOST }}" -U pguser -d PostgresNioTestDb \
-f Tests/Resources/postgres_seed.sql
- name: Run PostgreSQL tests
env:
PG_TEST_HOST: ${{ secrets.DB_HOST }}
PG_TEST_DB: PostgresNioTestDb
PG_TEST_USER: pguser
PG_TEST_PASS: ${{ secrets.PG_TEST_PASS }}
run: swift test --filter PostgresNioTests 2>&1
# ───────────────────────────────────────────────────────────────────────────
# 4. MySQL integration tests
# Connects to Mac via frpc tunnel on VPS (no service container).
# ───────────────────────────────────────────────────────────────────────────
test-mysql:
name: MySQL integration tests
runs-on: ubuntu-24.04
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 and mysql client
run: sudo apt-get install -y libsqlite3-dev default-mysql-client
- 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: Seed MySQL database
run: |
mysql -h "${{ secrets.DB_HOST }}" \
-u mysqluser -p"${{ secrets.MYSQL_TEST_PASS }}" \
MySQLNioTestDb < Tests/Resources/mysql_seed.sql
- name: Run MySQL tests
env:
MYSQL_TEST_HOST: ${{ secrets.DB_HOST }}
MYSQL_TEST_DB: MySQLNioTestDb
MYSQL_TEST_USER: mysqluser
MYSQL_TEST_PASS: ${{ secrets.MYSQL_TEST_PASS }}
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."