name: Cargo tests
on:
push:
branches:
- main
- qa
pull_request:
workflow_dispatch:
jobs:
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 with:
toolchain: stable
components: clippy
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 - name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y openssl libkrb5-dev
- name: Clippy
run: cargo clippy --features=all
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 with:
toolchain: stable
components: rustfmt
- name: Rustfmt
run: cargo fmt --check
msrv:
name: MSRV (1.88)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 with:
toolchain: "1.88"
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 - name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y openssl libkrb5-dev
- name: Check on MSRV
run: cargo check --features all
rustls-features:
name: rustls trust-store (unit)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 with:
toolchain: stable
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 - name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y openssl libkrb5-dev
- name: Unit tests (rustls)
run: cargo test --no-default-features --features rustls,chrono,time,tds73 --lib
- name: Unit tests (rustls-webpki-roots)
run: cargo test --no-default-features --features rustls-webpki-roots,chrono,time,tds73 --lib
semver:
name: semver-checks (advisory)
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
persist-credentials: false
fetch-depth: 0
- uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 with:
toolchain: stable
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 - name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y openssl libkrb5-dev
- name: Install cargo-semver-checks
uses: taiki-e/install-action@cargo-semver-checks
- name: Fetch baseline branch
run: git fetch --no-tags --depth=100 origin "${{ github.base_ref }}"
- name: Check for semver-breaking changes
run: >-
cargo semver-checks --baseline-rev FETCH_HEAD
--only-explicit-features
--features rustls,chrono,time,tds73,rust_decimal,bigdecimal
smoke:
name: integration smoke (SQL 2022)
if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/dev')
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
database:
- 2017
- 2019
- 2022
- azure-sql-edge
features:
- "--features=all"
- "--no-default-features"
- "--no-default-features --features=chrono"
- "--no-default-features --features=time"
- "--no-default-features --features=rustls"
- "--no-default-features --features=vendored-openssl"
- "--no-default-features --features=rustls,chrono,time,tds73,rust_decimal,bigdecimal"
env:
TIBERIUS_TEST_CONNECTION_STRING: "server=tcp:localhost,1433;user=SA;password=<YourStrong@Passw0rd>;TrustServerCertificate=true"
RUSTFLAGS: "-Dwarnings"
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 with:
toolchain: stable
- name: Compute cache key
shell: bash
run: |
key="${{ matrix.features }}"
key="${key//,/+}"
echo "RUST_CACHE_KEY=$key" >> "$GITHUB_ENV"
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 with:
shared-key: ${{ env.RUST_CACHE_KEY }}
- name: Start SQL Server ${{matrix.database}}
run: DOCKER_BUILDKIT=1 docker compose -f docker-compose.yml up -d mssql-${{matrix.database}}
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y openssl libkrb5-dev
- name: Wait for SQL Server
run: |
pw='<YourStrong@Passw0rd>'
for _ in $(seq 1 60); do
if docker run --rm --network host mcr.microsoft.com/mssql-tools \
/opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P "$pw" -Q "SELECT 1" >/dev/null 2>&1; then
echo "SQL Server ready (authenticated login succeeded)"; exit 0
fi
sleep 3
done
echo "SQL Server did not accept an authenticated login in time" >&2
docker compose -f docker-compose.yml logs mssql-${{matrix.database}} || true
exit 1
- name: Run tests
run: cargo test ${{matrix.features}}
integration-macos:
name: macos (SQL 2022 via colima)
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/qa')
runs-on: macos-15-intel
continue-on-error: ${{ matrix.soft_fail }}
strategy:
fail-fast: false
matrix:
include:
- features: "--no-default-features --features=rustls,chrono,time,tds73,rust_decimal,bigdecimal"
soft_fail: false
- features: "--no-default-features --features=vendored-openssl,chrono,time,tds73,rust_decimal,bigdecimal"
soft_fail: false
env:
TIBERIUS_TEST_CONNECTION_STRING: "server=tcp:localhost,1433;user=SA;password=<YourStrong@Passw0rd>;TrustServerCertificate=true"
RUSTFLAGS: "-Dwarnings"
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 with:
toolchain: stable
- name: Compute cache key
run: |
key="${{ matrix.features }}"
key="${key//,/+}"
echo "RUST_CACHE_KEY=$key" >> "$GITHUB_ENV"
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 with:
shared-key: ${{ env.RUST_CACHE_KEY }}
- name: Install build dependencies (openssl, krb5)
run: |
brew install openssl krb5
# krb5 is keg-only; expose its pkg-config so integrated-auth-gssapi
# and any openssl-linking features build against Homebrew's copy.
echo "PKG_CONFIG_PATH=$(brew --prefix krb5)/lib/pkgconfig:$(brew --prefix openssl)/lib/pkgconfig" >> "$GITHUB_ENV"
- name: Start Docker (colima)
run: |
brew install colima docker docker-compose
# SQL Server wants ~2 GB RAM; give the VM headroom for it + the build.
colima start --cpu 3 --memory 6 --disk 20
docker version
- name: Start SQL Server 2022
run: docker compose -f docker-compose.yml up -d mssql-2022
- name: Wait for SQL Server
run: |
pw='<YourStrong@Passw0rd>'
for _ in $(seq 1 60); do
for bin in /opt/mssql-tools18/bin/sqlcmd /opt/mssql-tools/bin/sqlcmd; do
if docker compose -f docker-compose.yml exec -T mssql-2022 \
"$bin" -S localhost -U SA -P "$pw" -C -Q "SELECT 1" >/dev/null 2>&1; then
echo "SQL Server ready (authenticated login succeeded)"; exit 0
fi
done
sleep 3
done
echo "SQL Server did not accept an authenticated login in time" >&2
docker compose -f docker-compose.yml logs mssql-2022 || true
exit 1
- name: Run tests
run: cargo test ${{ matrix.features }}
integration-windows:
name: windows (SQL 2019, integrated auth)
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/qa')
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
database:
- 2019
features:
- "--features=all"
- "--no-default-features --features=rustls,winauth"
- "--no-default-features --features=vendored-openssl,winauth"
env:
TIBERIUS_TEST_INSTANCE: "MSSQLSERVER"
TIBERIUS_TEST_CONNECTION_STRING: "server=tcp:127.0.0.1,1433;IntegratedSecurity=true;TrustServerCertificate=true"
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 with:
toolchain: stable
- name: Compute cache key
shell: bash
run: |
key="${{ matrix.features }}"
key="${key//,/+}"
echo "RUST_CACHE_KEY=$key" >> "$GITHUB_ENV"
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 with:
shared-key: ${{ env.RUST_CACHE_KEY }}
- name: Set required PowerShell modules
id: psmodulecache
uses: potatoqualitee/psmodulecache@ee5e9494714abf56f6efbfa51527b2aec5c761b8 with:
modules-to-cache: SqlServer
- name: Setup Chocolatey download cache
id: chococache
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae with:
path: C:\Users\runneradmin\AppData\Local\Temp\chocolatey\
key: chocolatey-install
- name: Install required PowerShell modules
shell: powershell
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module SqlServer
- name: Install SQL Server ${{matrix.database}}
shell: powershell
run: |
choco feature disable --name="'exitOnRebootDetected'"
$ErrorActionPreference = 'SilentlyContinue'
choco install sql-server-${{matrix.database}} --params="'/IgnorePendingReboot'"
- name: Setup SQL Server ${{matrix.database}}
shell: powershell
run: |
Import-Module 'sqlps'
[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | Out-Null
[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.SqlWmiManagement") | Out-Null
$serverName = $env:COMPUTERNAME
$instanceName = "MSSQLSERVER"
$smo = 'Microsoft.SqlServer.Management.Smo.'
$wmi = new-object ($smo + 'Wmi.ManagedComputer')
$wmi
# Enable TCP/IP
echo "Enabling TCP/IP"
$Tcp = $wmi.GetSmoObject("ManagedComputer[@Name='$serverName']/ServerInstance[@Name='$instanceName']/ServerProtocol[@Name='Tcp']")
$Tcp.IsEnabled = $true
$Tcp.alter()
$Tcp
# Enable named pipes
echo "Enabling named pipes"
$Np = $wmi.GetSmoObject("ManagedComputer[@Name='$serverName']/ServerInstance[@Name='$instanceName']/ServerProtocol[@Name='Np']")
$Np.IsEnabled = $true
$Np.Alter()
$Np
# Set Alias
echo "Setting the alias"
New-Item HKLM:\SOFTWARE\Microsoft\MSSQLServer\Client -Name ConnectTo | Out-Null
Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\MSSQLServer\Client\ConnectTo -Name '(local)' -Value "DBMSSOCN,$serverName\$instanceName" | Out-Null
# Start services
echo "Starting services"
Set-Service SQLBrowser -StartupType Manual
Start-Service SQLBrowser
net stop MSSQLSERVER
net start MSSQLSERVER
- name: Run normal tests
shell: powershell
run: cargo test ${{matrix.features}}