Skip to content

Refactor ODBC driver installation in CI workflow and update driver na… #89

Refactor ODBC driver installation in CI workflow and update driver na…

Refactor ODBC driver installation in CI workflow and update driver na… #89

Workflow file for this run

name: Tests
on: [push, pull_request]
env:
CARGO_TERM_COLOR: always
jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Run formatter
run: cargo fmt
- name: Commit changes
run: |
if [[ `git status --porcelain` ]]; then
git config user.name "github-actions[bot]"
# Make formatting commits look lie they'r authored by the official github-actions[bot]
# instead of an anonymous user account.
# For the id see: https://api.github.com/users/github-actions%5Bbot%5D
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "style: formattig"
git push
fi
test:
needs: [format]
name: ${{ matrix.features || 'dynamic unixodbc' }} on ${{ matrix.target }}
runs-on: ${{ contains(matrix.target, 'windows') && 'windows-latest' || contains(matrix.target, 'darwin') && 'macos-latest' || 'ubuntu-latest' }}
strategy:
matrix:
target: ["x86_64-unknown-linux-gnu", "aarch64-apple-darwin"]
features: ["", "iodbc", "vendored-unix-odbc"]
include: # windows always links dynamically to the system's driver manager
- target: "x86_64-pc-windows-msvc"
features: ""
- target: "i686-pc-windows-msvc"
features: ""
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: "recursive"
- if: ${{ contains(matrix.target, 'linux') }}
run: sudo apt-get update && sudo apt-get install -y libsqliteodbc ${{ matrix.features == '' && 'unixodbc-dev' || matrix.features == 'iodbc' && 'libiodbc2-dev' || '' }}
- if: ${{ contains(matrix.target, 'darwin') }}
run: |
brew install sqliteodbc ${{ matrix.features == '' && 'unixodbc' || matrix.features == 'iodbc' && 'libiodbc' || '' }}
cat > /tmp/sqlite3_driver.ini << 'EOF'
[SQLite3]
Description=SQLite ODBC Driver
Driver=/opt/homebrew/lib/libsqlite3odbc.dylib
Setup=/opt/homebrew/lib/libsqlite3odbc.dylib
EOF
odbcinst -i -d -f /tmp/sqlite3_driver.ini
- if: ${{ contains(matrix.target, 'windows') }}
run: |
$arch = "${{ contains(matrix.target, 'x86_64') && '_w64' || '' }}"
$installPath = if ($arch -eq "_w64") { "C:\Program Files\SQLite ODBC Driver" } else { "C:\Program Files (x86)\SQLite ODBC Driver" }
Invoke-WebRequest "http://www.ch-werner.de/sqliteodbc/sqliteodbc$arch.exe" -OutFile C:\sqliteodbc.exe
7z x C:\sqliteodbc.exe -o"$installPath"
REG ADD "HKLM\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers" /v SQLite3 /t REG_SZ /d Installed /f
REG ADD "HKLM\SOFTWARE\ODBC\ODBCINST.INI\SQLite3" /v "Driver" /t REG_SZ /d "$installPath\sqlite3odbc.dll" /f
REG ADD "HKLM\SOFTWARE\ODBC\ODBCINST.INI\SQLite3" /v "Setup" /t REG_SZ /d "$installPath\sqlite3odbc.dll" /f
REG ADD "HKLM\SOFTWARE\ODBC\ODBCINST.INI\SQLite3" /v "UsageCount" /t REG_DWORD /d 1 /f
- run: cargo clippy --all-targets --features "${{ matrix.features }}" -- -D warnings
- run: cargo test -p odbc-sys
--target "${{ matrix.target }}"
--features "${{ matrix.features }}"
-- ${{ matrix.features != 'iodbc' && '--include-ignored' || '' }} # ignored tests depend on the sqlite driver
# Verify that the build script does nothing nasty, which would prevent publishing to crates.io
test_publish_unix_odbc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Test publish to crates.io
run: cargo publish -p unix-odbc --dry-run