squeal 0.1.1

A SQL query builder library for Rust
Documentation
name: Rust CI

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

env:
  CARGO_TERM_COLOR: always

jobs:
  msrv:
    name: Cargo Check with MSRV
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install Rust 1.90
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: "1.90"
      - uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/
          key: ${{ runner.os }}-cargo-msrv-${{ hashFiles('**/Cargo.lock') }}
      - name: Check with MSRV
        run: cargo check --all-targets --all-features

  fmt:
    name: Format Check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt
          toolchain: "1.90"
      - name: Check formatting
        run: cargo fmt --all -- --check

  clippy:
    name: Clippy Lint
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/
          key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy
          toolchain: "1.90"
      - name: Run clippy
        run: cargo clippy --all-targets --all-features -- -D warnings

  test:
    name: Test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
      - name: Run tests
        run: cargo test --all --verbose

  coverage:
    name: Code Coverage
    runs-on: ubuntu-latest
    needs: test
    steps:
      - uses: actions/checkout@v4
      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
      - uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/
          key: ${{ runner.os }}-cargo-tarpaulin-${{ hashFiles('**/Cargo.lock') }}
      - name: Install tarpaulin
        run: |
          if ! command -v cargo-tarpaulin &> /dev/null; then
            cargo install cargo-tarpaulin
          fi
      - name: Run tarpaulin
        run: cargo tarpaulin --verbose --all-features --workspace --timeout 120 --out xml --output-dir coverage
      - name: Check coverage threshold
        run: |
          COVERAGE=$(cargo tarpaulin --verbose --all-features --workspace --timeout 120 | grep -oP '\d+\.\d+(?=% coverage)')
          echo "Coverage: $COVERAGE%"
          if (( $(echo "$COVERAGE < 90.0" | bc -l) )); then
            echo "ERROR: Coverage $COVERAGE% is below 90% threshold"
            exit 1
          fi
          echo "SUCCESS: Coverage $COVERAGE% meets 90% threshold"

  integration-test:
    name: Integration Test with Docker
    runs-on: ubuntu-latest
    if: github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'integration')
    steps:
      - uses: actions/checkout@v4
      - uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
      - name: Run PostgreSQL Docker integration tests
        run: cargo test --features postgres-docker --verbose 2>&1 | tee test-output.log
      - name: Upload test results
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: integration-test-results
          path: test-output.log


  release-build:
    name: Release Build
    runs-on: ubuntu-latest
    if: github.ref == 'refs/heads/main'
    needs: [msrv, fmt, clippy, test, coverage]
    steps:
      - uses: actions/checkout@v4
      - uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
      - name: Build for release
        run: cargo build --release --verbose