pg_exporter 0.5.5

PostgreSQL metric exporter for Prometheus
Documentation
---
name: Test

on:
  workflow_call:
  pull_request:
    branches:
      - '*'

jobs:
  format:
    name: Format
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: llvm-tools-preview, rustfmt

      - name: Format
        run: cargo fmt --all -- --check

  lint:
    name: Clippy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy

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

  check:
    name: Check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@stable

      - name: Check
        run: cargo check

  test:
    name: Test (PostgreSQL ${{ matrix.postgres }})
    runs-on: ubuntu-latest
    needs:
      - format
      - lint
      - check

    strategy:
      fail-fast: false  # Continue other jobs if one fails
      matrix:
        postgres:
          - 16
          - 17
          - 18

    services:
      postgres:
        image: postgres:${{ matrix.postgres }}
        env:
          POSTGRES_USER: postgres
          POSTGRES_PASSWORD: postgres
          POSTGRES_DB: postgres
          POSTGRES_HOST_AUTH_METHOD: trust
        options: >-
          --health-cmd "pg_isready -U postgres"
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
        ports:
          - 5432:5432

    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@stable

      - name: Wait for PostgreSQL
        run: |
          until pg_isready -h localhost -p 5432 -U postgres; do
            echo "Waiting for PostgreSQL..."
            sleep 1
          done
          echo "PostgreSQL ${{ matrix.postgres }} is ready!"

      - name: Show PostgreSQL version
        run: |
          psql -h localhost -U postgres -d postgres -c "SELECT version();"

      - name: Run tests
        env:
          PG_EXPORTER_DSN: postgresql://postgres:postgres@localhost:5432/postgres
        run: cargo test