tower-http-cache 0.5.1

Tower-compatible caching layer with pluggable backends (in-memory, Redis, and more)
Documentation
name: CI

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

env:
  CARGO_TERM_COLOR: always

jobs:
  test:
    name: test (${{ matrix.rust }})
    runs-on: ubuntu-latest
    timeout-minutes: 25
    strategy:
      fail-fast: false
      matrix:
        rust: [stable, beta]
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ matrix.rust }}
      - uses: Swatinem/rust-cache@v2
      # `memcached-backend` reaches native-tls via async-memcached -> toxiproxy_rust.
      - name: install openssl headers
        run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config
      # The feature-selected run below is the primary gate; async-memcached pulls toxiproxy_rust
      # -> reqwest 0.11 -> native-tls -> openssl-sys, which needs libssl-dev.
      - run: cargo test --features in-memory,serde,redis-backend,metrics,tracing,compression,admin-api --all-targets
      - run: cargo test --features in-memory,serde --doc
      - run: cargo test --no-default-features --features in-memory
      # Reduced feature sets skip doctests: the crate-level examples use
      # InMemoryBackend, which is a default feature. Doctests are covered
      # by the default and --all-features runs above.
      - run: cargo test --no-default-features --lib --tests
      - run: cargo test --no-default-features --features serde --lib --tests
      # The feature matrix regressed twice before CI existed: `serde` and
      # `in-memory` were both load-bearing without being declared as such.
      - run: cargo test --all-features --all-targets

  msrv:
    name: msrv (1.85 core / 1.88 backends)
    runs-on: ubuntu-latest
    timeout-minutes: 25
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@1.85.0
      - uses: Swatinem/rust-cache@v2
      # Build only: dev-dependencies are allowed to outrun the MSRV.
      # 1.85 covers everything except the shared backends.
      - run: cargo build
      - run: cargo build --features in-memory,serde,metrics,tracing,compression,admin-api
      # redis-backend / memcached-backend reach url -> idna -> icu_*, which
      # require 1.88. Enforced separately rather than papered over.
      - uses: dtolnay/rust-toolchain@1.88.0
      - run: cargo build --features redis-backend
      - run: cargo build --features memcached-backend

  lint:
    name: fmt + clippy
    runs-on: ubuntu-latest
    timeout-minutes: 25
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt, clippy
      - uses: Swatinem/rust-cache@v2
      - run: cargo fmt --all -- --check
      - run: cargo clippy --features in-memory,serde,redis-backend,metrics,tracing,compression,admin-api --all-targets -- -D warnings
      # The minimal build has its own lints (cfg-gated code paths).
      - run: cargo clippy --no-default-features --features in-memory -- -D warnings

  docs:
    name: docs
    runs-on: ubuntu-latest
    timeout-minutes: 25
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@nightly
      - uses: Swatinem/rust-cache@v2
      - run: cargo doc --no-deps --features in-memory,serde,redis-backend,metrics,tracing,compression,admin-api
        env:
          RUSTDOCFLAGS: -D warnings

  deny:
    name: cargo-deny
    runs-on: ubuntu-latest
    timeout-minutes: 25
    steps:
      - uses: actions/checkout@v5
      - uses: EmbarkStudios/cargo-deny-action@v2
        with:
          command: check