confers 0.4.0

Production-ready Rust configuration library with zero boilerplate
Documentation
name: CI

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

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1

jobs:
  check:
    name: Check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
      - uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 # stable
      - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
      - name: Install protoc
        run: sudo apt-get update && sudo apt-get install -y --no-install-recommends protobuf-compiler
      - name: Check default features
        run: cargo check
      - name: Check full features
        run: cargo check --features full

  test:
    name: Test
    runs-on: ubuntu-latest
    strategy:
      matrix:
        features: ["default", "recommended", "full"]
    steps:
      - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
      - name: Start NATS with JetStream
        run: |
          docker run -d --name nats -p 4222:4222 nats:2.10 -js
          for i in $(seq 1 60); do
            nc -z 127.0.0.1 4222 && break
            sleep 0.5
          done
      - uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 # stable
      - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
      - name: Install protoc
        run: sudo apt-get update && sudo apt-get install -y --no-install-recommends protobuf-compiler
      - name: Run tests
        run: cargo test --features ${{ matrix.features }}

  clippy:
    name: Clippy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
      - uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 # stable
        with:
          components: clippy
      - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
      - name: Install protoc
        run: sudo apt-get update && sudo apt-get install -y --no-install-recommends protobuf-compiler
      - name: Run clippy
        run: cargo clippy --features full -- -D warnings

  fmt:
    name: Format
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
      - uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 # stable
        with:
          components: rustfmt
      - name: Check formatting
        run: cargo fmt --all -- --check

  docs:
    name: Documentation
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
      - uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 # stable
      - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
      - name: Install protoc
        run: sudo apt-get update && sudo apt-get install -y --no-install-recommends protobuf-compiler
      - name: Build documentation
        run: cargo doc --features full --no-deps
        env:
          RUSTDOCFLAGS: -D warnings

  security:
    name: Security Audit
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
      - uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 # stable
      - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
      - name: Install cargo-audit
        uses: taiki-e/install-action@5626e41434f03ab3022d9685405c0645c879f441 # cargo-audit
      - name: Run security audit
        run: cargo audit

  msrv:
    name: MSRV
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
      # MSRV 1.88: full feature pulls async-nats 0.49, darling 0.23, time 0.3.47 — all require rustc 1.88.
      - uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 # stable
        with:
          toolchain: 1.88
      - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
      - name: Install protoc
        run: sudo apt-get update && sudo apt-get install -y --no-install-recommends protobuf-compiler
      - name: Check MSRV
        run: cargo check --features full

  benchmarks:
    name: Performance Benchmarks
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
      - uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 # stable
        with:
          components: llvm-tools-preview
      - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
      - name: Run benchmarks
        run: |
          # --benches restricts to criterion targets (harness=false); else libtest rejects --save-baseline
          cargo bench --features dev --benches -- --save-baseline current
      - name: Compare with main branch baseline
        run: |
          # Try to fetch baseline from main branch
          git fetch origin main --quiet 2>/dev/null || true
          if git rev-parse --verify origin/main &>/dev/null; then
            # Stash current results, checkout main baseline, compare, restore
            cargo bench --features dev --benches -- --baseline main 2>&1 | tee bench_compare.txt || true
            # Check for significant regressions (>10%)
            if grep -q "Regression" bench_compare.txt; then
              echo "WARNING: Performance regression detected!"
              # Show regression details
              grep -A 2 "Regression" bench_compare.txt || true
            fi
          else
            echo "No main branch baseline found, skipping comparison"
          fi
      - name: Upload benchmark results
        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
        if: always()
        with:
          name: benchmark-results
          path: target/criterion/

  coverage:
    name: Coverage
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
      - name: Start NATS with JetStream
        run: |
          docker run -d --name nats -p 4222:4222 nats:2.10 -js
          for i in $(seq 1 60); do
            nc -z 127.0.0.1 4222 && break
            sleep 0.5
          done
      - uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 # stable
        with:
          components: llvm-tools-preview
      - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
      - name: Install protoc
        run: sudo apt-get update && sudo apt-get install -y --no-install-recommends protobuf-compiler
      - name: Install cargo-llvm-cov
        uses: taiki-e/install-action@c6d51ded7cde3c421f6cd6046cd601f2248f3710 # cargo-llvm-cov
      - name: Generate coverage
        run: cargo llvm-cov --features full --lcov --output-path lcov.info
      - name: Check minimum coverage (80%)
        run: cargo llvm-cov --features full --text -- | tee coverage.txt && (grep -E "^TOTAL.*[0-9]+%" coverage.txt | tail -1 | awk '{print $2}' | sed 's/%//' | awk '{if ($1 >= 80) exit 0; else {print "Coverage " $1 "% is below 80% minimum"; exit 1}}' || exit 1)
      - name: Upload coverage
        uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
        with:
          files: lcov.info
          fail_ci_if_error: true