exarrow-rs 0.7.3

ADBC-compatible driver for Exasol with Arrow data format support
Documentation
name: CI

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

env:
  CARGO_TERM_COLOR: always
  EXASOL_HOST: localhost
  EXASOL_PORT: 8563
  EXASOL_USER: sys
  EXASOL_PASSWORD: exasol

jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@1.92.0
        with:
          components: clippy, rustfmt, llvm-tools-preview

      - name: Cache cargo registry and build artifacts
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-

      - name: Build (debug)
        run: cargo build --verbose

      - name: Build with FFI (release)
        run: cargo build --release --features ffi

  lint:
    name: Lint
    needs: [build]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@1.92.0
        with:
          components: clippy, rustfmt

      - name: Restore cache
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-

      - name: Check formatting
        run: cargo fmt --all -- --check

      - name: Clippy
        run: cargo clippy --all-targets -- -D warnings

  licenses:
    name: License Check
    needs: [build]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install cargo-deny
        uses: taiki-e/install-action@cargo-deny

      - name: Check licenses
        run: cargo deny check licenses

  unit-tests:
    name: Unit Tests
    needs: [build]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@1.92.0
        with:
          components: llvm-tools-preview

      - name: Install cargo-llvm-cov
        uses: taiki-e/install-action@cargo-llvm-cov

      - name: Restore cache
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-

      - name: Run unit tests with coverage
        run: cargo llvm-cov --lib --lcov --output-path lcov-unit.info

  integration-tests:
    name: Integration Tests
    needs: [lint, licenses, unit-tests]
    runs-on: ubuntu-latest
    timeout-minutes: 30
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@1.92.0
        with:
          components: llvm-tools-preview

      - name: Install cargo-llvm-cov
        uses: taiki-e/install-action@cargo-llvm-cov

      - name: Restore cache
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-

      - name: Start Exasol container
        run: |
          docker run -d \
            --name exasol-test \
            --privileged \
            --shm-size=1g \
            -p 8563:8563 \
            -e COSLWD_ENABLED=1 \
            exasol/docker-db:2025.2.0

      - name: Wait for Exasol to be ready
        run: ./scripts/wait_for_exasol.sh exasol-test 120

      - name: Run integration tests with coverage
        env:
          REQUIRE_EXASOL: "1"
        run: |
          cargo llvm-cov --no-report --features ffi --test integration_tests -- --test-threads=1
          cargo llvm-cov report --lcov --output-path lcov-integration.info

      - name: Build FFI library for driver manager tests
        run: cargo build --release --features ffi

      - name: Run driver manager tests
        env:
          REQUIRE_EXASOL: "1"
        run: cargo test --features ffi --test driver_manager_tests -- --include-ignored --test-threads=1

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.12'

      - name: Install Python test dependencies
        run: pip install adbc-driver-manager pyarrow pytest polars

      - name: Run Python integration tests
        run: pytest tests/python/test_driver_integration.py -v

      - name: Stop Exasol container
        if: always()
        run: |
          docker stop exasol-test || true
          docker rm exasol-test || true

  release:
    name: Release
    needs: [integration-tests]
    if: github.event_name == 'push' && github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Get version from Cargo.toml
        id: version
        run: |
          VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/')
          echo "version=$VERSION" >> "$GITHUB_OUTPUT"
          echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"

      - name: Check if tag already exists
        id: check
        run: |
          if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
            echo "exists=true" >> "$GITHUB_OUTPUT"
          else
            echo "exists=false" >> "$GITHUB_OUTPUT"
          fi

      - name: Extract changelog for this version
        if: steps.check.outputs.exists == 'false'
        id: changelog
        run: |
          VERSION="${{ steps.version.outputs.version }}"
          BODY=$(awk "/^## ${VERSION}\$/{ found=1; next } /^## /{ if(found) exit } found{ print }" CHANGELOG.md)
          {
            echo "body<<CHANGELOG_EOF"
            echo "$BODY"
            echo "CHANGELOG_EOF"
          } >> "$GITHUB_OUTPUT"

      - name: Create git tag
        if: steps.check.outputs.exists == 'false'
        run: |
          git tag "${{ steps.version.outputs.tag }}"
          git push origin "${{ steps.version.outputs.tag }}"

      - name: Create GitHub release
        if: steps.check.outputs.exists == 'false'
        uses: softprops/action-gh-release@v2
        with:
          tag_name: ${{ steps.version.outputs.tag }}
          name: ${{ steps.version.outputs.tag }}
          body: ${{ steps.changelog.outputs.body }}

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

      - name: Check if version is on crates.io
        id: crate
        run: |
          VERSION="${{ steps.version.outputs.version }}"
          if curl -sf "https://crates.io/api/v1/crates/exarrow-rs/$VERSION" | grep -q '"num"'; then
            echo "published=true" >> "$GITHUB_OUTPUT"
          else
            echo "published=false" >> "$GITHUB_OUTPUT"
          fi

      - name: Publish to crates.io
        if: steps.crate.outputs.published == 'false'
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_TOKEN }}
        run: cargo publish