sqlx-pool-registry 0.2.1

Lightweight SQLx PostgreSQL connection pool routing for primary/replica separation
Documentation
name: CI

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

env:
  CARGO_TERM_COLOR: always

jobs:
  offline-test:
    name: Offline test (${{ matrix.sqlx_feature }})
    runs-on: ubuntu-latest
    strategy:
      matrix:
        sqlx_feature: [with-sqlx-0_8, with-sqlx-0_9]

    steps:
      - uses: actions/checkout@v4

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

      - name: Cache dependencies
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-offline-${{ matrix.sqlx_feature }}-${{ hashFiles('**/Cargo.lock') }}

      - name: Build
        run: cargo build --verbose --no-default-features --features "${{ matrix.sqlx_feature }},with-named-pools"

      - name: Check examples
        run: cargo check --verbose --examples --no-default-features --features "${{ matrix.sqlx_feature }},with-named-pools"

      - name: Run offline tests without DATABASE_URL
        run: |
          unset DATABASE_URL
          cargo test --verbose --no-default-features --features "${{ matrix.sqlx_feature }},with-named-pools"

  database-test:
    name: Database test (${{ matrix.sqlx_feature }})
    runs-on: ubuntu-latest
    strategy:
      matrix:
        sqlx_feature: [with-sqlx-0_8, with-sqlx-0_9]

    services:
      postgres:
        image: postgres:16
        env:
          POSTGRES_PASSWORD: password
          POSTGRES_DB: test
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
        ports:
          - 5432:5432

    steps:
      - uses: actions/checkout@v4

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

      - name: Cache dependencies
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-database-${{ matrix.sqlx_feature }}-${{ hashFiles('**/Cargo.lock') }}

      - name: Run database tests
        env:
          DATABASE_URL: postgresql://postgres:password@localhost:5432/test
        run: cargo test --verbose --no-default-features --features "${{ matrix.sqlx_feature }},with-named-pools" -- --ignored

  lint:
    name: Lint (${{ matrix.sqlx_feature }})
    runs-on: ubuntu-latest
    strategy:
      matrix:
        sqlx_feature: [with-sqlx-0_8, with-sqlx-0_9]

    steps:
      - uses: actions/checkout@v4

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

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

      - name: Run clippy
        run: cargo clippy --all-targets --no-default-features --features "${{ matrix.sqlx_feature }},with-named-pools" -- -D warnings

  msrv:
    name: MSRV (Rust ${{ matrix.rust }}, ${{ matrix.sqlx_feature }})
    runs-on: ubuntu-latest
    strategy:
      matrix:
        include:
          - rust: "1.78"
            sqlx_feature: with-sqlx-0_8
          - rust: "1.94"
            sqlx_feature: with-sqlx-0_9

    steps:
      - uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ matrix.rust }}

      - name: Check library
        run: cargo check --lib --no-default-features --features "${{ matrix.sqlx_feature }}"