sqlx-odbc 0.0.1

ODBC driver implementation for SQLx.
Documentation
name: ODBC

on:
  pull_request:
  push:
    branches:
      - main
    tags:
      - v*

defaults:
  run:
    shell: bash

jobs:
  static:
    name: Static checks
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v5

      - uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy, rustfmt

      - uses: Swatinem/rust-cache@v2

      - name: Install ODBC headers
        run: sudo apt-get update && sudo apt-get install -y unixodbc-dev

      - name: Run static checks
        run: scripts/ci.sh

  odbc-drivers:
    name: ODBC driver / ${{ matrix.driver }}
    runs-on: ubuntu-latest

    strategy:
      fail-fast: false
      matrix:
        driver:
          - duckdb
          - postgres

    services:
      postgres:
        image: postgres:17
        env:
          POSTGRES_PASSWORD: postgres
        ports:
          - 5432:5432
        options: >-
          --health-cmd pg_isready
          --health-interval 5s
          --health-timeout 5s
          --health-retries 20

    env:
      DUCKDB_ODBC_VERSION: v1.5.3.0

    steps:
      - uses: actions/checkout@v5

      - uses: dtolnay/rust-toolchain@stable

      - uses: Swatinem/rust-cache@v2
        with:
          key: odbc-${{ matrix.driver }}

      - name: Install ODBC runtime
        run: sudo apt-get update && sudo apt-get install -y curl odbc-postgresql unixodbc-dev unzip

      - name: Install DuckDB ODBC driver
        if: matrix.driver == 'duckdb'
        run: |
          curl -L \
            --fail \
            --output "$RUNNER_TEMP/duckdb_odbc.zip" \
            "https://github.com/duckdb/duckdb-odbc/releases/download/${DUCKDB_ODBC_VERSION}/duckdb_odbc-linux-amd64.zip"
          unzip -q "$RUNNER_TEMP/duckdb_odbc.zip" -d "$RUNNER_TEMP/duckdb_odbc"
          duckdb_driver="$(find "$RUNNER_TEMP/duckdb_odbc" -type f -name libduckdb_odbc.so -print -quit)"
          test -n "$duckdb_driver"
          echo "DUCKDB_ODBC_DRIVER=$duckdb_driver" >> "$GITHUB_ENV"

      - name: Run ODBC integration tests
        run: scripts/test-driver.sh "${{ matrix.driver }}"

  publish:
    name: Publish
    runs-on: ubuntu-latest
    needs:
      - static
      - odbc-drivers
    if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')

    steps:
      - uses: actions/checkout@v5

      - uses: dtolnay/rust-toolchain@stable

      - uses: Swatinem/rust-cache@v2

      - name: Install ODBC headers
        run: sudo apt-get update && sudo apt-get install -y unixodbc-dev

      - name: Publish to crates.io
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
        run: scripts/publish.sh