Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[alias]
xtask = "run --package xtask --"
312 changes: 139 additions & 173 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,217 +1,183 @@
name: Cargo tests
name: Cargo Tests

on:
push:
branches:
- main
branches: [ main ]
pull_request:


jobs:
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
components: clippy
override: true
- name: Install dependencies
run: sudo apt install -y openssl libkrb5-dev
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --features=all

format:
runs-on: ubuntu-latest
- uses: actions/checkout@v5 # checkout versions have been updated. previous v1/2
- uses: dtolnay/rust-toolchain@stable # changed to stable
with:
components: rustfmt, clippy

steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
components: rustfmt
override: true
- uses: mbrobbel/rustfmt-check@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y libkrb5-dev krb5-user && sudo ln -s /usr/include/krb5/gssapi /usr/include/gssapi

- run: cargo clippy --features=all

- run: cargo fmt --check

cargo-test-linux:
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"

engine: [ 2017, 2019, 2022, "azure" ]
env:
TIBERIUS_TEST_CONNECTION_STRING: "server=tcp:localhost,1433;user=SA;password=<YourStrong@Passw0rd>;TrustServerCertificate=true"
RUSTFLAGS: "-Dwarnings"
TIBERIUS_TEST_INSTANCE: "MSSQLSERVER"
# TIBERIUS_TEST_CONNECTION_STRING: "server=tcp:127.0.0.1,1433;IntegratedSecurity=true;TrustServerCertificate=true"
TIBERIUS_TEST_CONNECTION_STRING: "server=tcp:localhost,1433;IntegratedSecurity=true;TrustServerCertificate=true"

steps:
- uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v5

- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y libkrb5-dev krb5-user && sudo ln -s /usr/include/krb5/gssapi /usr/include/gssapi

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- uses: actions-rs/toolchain@v1
# we use the same cache key irrespective of the
# SQL server version
- name: Setup Cargo build cache
uses: actions/cache@v4
with:
path: target
key: ubuntu-cargo

- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ matrix.features }}
- run: cargo xtask container ${{ matrix.engine }}

- name: Start SQL Server ${{matrix.database}}
run: DOCKER_BUILDKIT=1 docker-compose -f docker-compose.yml up -d mssql-${{matrix.database}}
# Wait for SQL Server
- run: sleep 25

- name: Install dependencies
run: sudo apt install -y openssl libkrb5-dev
- run: cargo xtask test --features=all
- run: cargo xtask test --no-default-features
- run: cargo xtask test --no-default-features --features=chrono
- run: cargo xtask test --no-default-features --features=rustls
- run: cargo xtask test --no-default-features --features=time
- run: cargo xtask test --no-default-features --features=vendored-openssl

- name: Run tests
run: cargo test ${{matrix.features}}
- run: cargo xtask stop ${{ matrix.engine }}

cargo-test-windows:
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"

- 2019
env:
TIBERIUS_TEST_INSTANCE: "MSSQLSERVER"
TIBERIUS_TEST_CONNECTION_STRING: "server=tcp:127.0.0.1,1433;IntegratedSecurity=true;TrustServerCertificate=true"
# TIBERIUS_TEST_CONNECTION_STRING: "server=tcp:127.0.0.1,1433;IntegratedSecurity=true;TrustServerCertificate=true"
TIBERIUS_TEST_CONNECTION_STRING: "server=tcp:localhost,1433;IntegratedSecurity=true;TrustServerCertificate=true"

steps:
- uses: actions/checkout@v2

- uses: actions-rs/toolchain@v1

- name: Set required PowerShell modules
id: psmodulecache
uses: potatoqualitee/psmodulecache@v1
with:
modules-to-cache: SqlServer

- name: Setup PowerShell module cache
id: cacher
uses: actions/cache@v2
with:
path: ${{ steps.psmodulecache.outputs.modulepath }}
key: ${{ steps.psmodulecache.outputs.keygen }}

- name: Setup Chocolatey download cache
id: chococache
uses: actions/cache@v2
with:
path: C:\Users\runneradmin\AppData\Local\Temp\chocolatey\
key: chocolatey-install

- name: Setup Cargo build cache
uses: actions/cache@v2
with:
path: |
C:\Users\runneradmin\.cargo\registry
C:\Users\runneradmin\.cargo\git
target
key: ${{ runner.os }}-cargo

- name: Install required PowerShell modules
if: steps.cacher.outputs.cache-hit != 'true'
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}}
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy

- name: Set required PowerShell modules
id: psmodulecache
uses: potatoqualitee/psmodulecache@v1
with:
modules-to-cache: SqlServer

- name: Setup PowerShell module cache
id: cacher
uses: actions/cache@v4 # cache updated to v4
with:
path: ${{ steps.psmodulecache.outputs.modulepath }}
key: ${{ steps.psmodulecache.outputs.keygen }}

- name: Cache Cargo build cache
uses: actions/cache@v4 # cache command, updated to v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: windows-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Install required PowerShell modules
if: steps.cacher.outputs.cache-hit != 'true'
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

- shell: powershell
run: cargo test --features=all
- shell: powershell
run: cargo test --no-default-features --features=rustls,winauth
- shell: powershell
run: cargo test --no-default-features --features=vendored-openssl,winauth

cargo-test-macos:
runs-on: macos-12
runs-on: macos-26

strategy:
fail-fast: false
matrix:
database:
- 2019
features:
- "--no-default-features --features=rustls,chrono,time,tds73,sql-browser-async-std,sql-browser-tokio,sql-browser-smol,integrated-auth-gssapi,rust_decimal,bigdecimal"
- "--no-default-features --features=vendored-openssl"

env:
TIBERIUS_TEST_CONNECTION_STRING: "server=tcp:localhost,1433;user=SA;password=<YourStrong@Passw0rd>;TrustServerCertificate=true"
- 2019

steps:
- uses: actions/checkout@v2

- uses: actions-rs/toolchain@v1

- uses: docker-practice/actions-setup-docker@master

- name: Start SQL Server ${{matrix.database}}
run: DOCKER_BUILDKIT=1 docker-compose -f docker-compose.yml up -d mssql-${{matrix.database}}
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy

- name: Run tests
run: cargo test ${{matrix.features}}
# For now we're not running the integration tests in macos,
# only running the unit tests
- run: cargo test --no-default-features --features=vendored-openssl --lib
- run: cargo test --no-default-features --features=rustls,chrono,time,tds73,sql-browser-tokio,sql-browser-smol,integrated-auth-gssapi,rust_decimal,bigdecimal --lib
- run: cargo clippy ${{ matrix.features }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ Cargo.lock
.idea
.direnv/
.vscode
mssql.crt
mssql.key
Loading