odbc-sys 0.31.2

ODBC ffi bindings
Documentation
name: Tests

on: [push, pull_request]

env:
  CARGO_TERM_COLOR: always

jobs:
  format:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # 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 }}
    # libiodbc2 3.52.16-2 (Ubuntu 26.04) is built with -std=c17, which hides the strdup prototype and
    # truncates pointers. It segfaults on the first SQLAllocHandle call, even from plain C. Keep the
    # iodbc job on 24.04 (libiodbc2 3.52.9) until the Debian/Ubuntu package is fixed.
    runs-on: ${{ contains(matrix.target, 'windows') && 'windows-latest' || contains(matrix.target, 'darwin') && 'macos-latest' || matrix.features == 'iodbc' && 'ubuntu-24.04' || '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@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          submodules: "recursive"
      - if: ${{ contains(matrix.target, 'linux') && matrix.features == '' }}
        run: sudo apt-get update && sudo apt-get install -y unixodbc-dev
      - if: ${{ contains(matrix.target, 'linux') && matrix.features == 'iodbc' }}
        run: sudo apt-get update && sudo apt-get install -y libiodbc2-dev
      - if: ${{ contains(matrix.target, 'darwin') && matrix.features == '' }}
        run: brew install unixodbc
      - if: ${{ contains(matrix.target, 'darwin') && matrix.features == 'iodbc' }}
        run: brew install libiodbc
      - run: cargo clippy --all-targets --features "${{ matrix.features }}" -- -D warnings
      - run: cargo test -p odbc-sys --target "${{ matrix.target }}" --features "${{ matrix.features }}"

  # 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@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
      - name: Test publish to crates.io
        run: cargo publish -p unix-odbc --dry-run