tower-http-cache 0.6.0

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@v7
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ matrix.rust }}
      - uses: Swatinem/rust-cache@v2
      # The feature-selected run below is the primary gate.
      - 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
      # The 0.5.x legacy reader must build and pass with the feature both on
      # and off, for the default set and for redis-backend. It is in `default`,
      # so only the explicit off legs actually exercise the cfg-gated absence.
      - run: cargo test --no-default-features --features in-memory,serde
      - run: cargo test --no-default-features --features in-memory,serde,legacy-bincode1-read
      - run: cargo test --no-default-features --features in-memory,serde,redis-backend
      - run: cargo test --no-default-features --features in-memory,serde,redis-backend,legacy-bincode1-read

  no-bincode:
    name: bincode absent from the graph
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v7
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      # 0.6.0 deleted the RUSTSEC-2025-0141 suppression from deny.toml by
      # removing bincode entirely; the 0.5.x reader is hand-written and pulls no
      # dependency. Without this guard a transitive reintroduction would surface
      # as an unexplained cargo-deny failure instead of here.
      #
      # `cargo tree -i` exits non-zero when the package is NOT found, which is
      # the outcome we want -- hence the deliberate inversion.
      - name: cargo tree -i bincode must find nothing
        run: |
          if cargo tree -i bincode --all-features >/dev/null 2>&1; then
            echo "bincode is back in the dependency graph:"
            cargo tree -i bincode --all-features
            exit 1
          fi

  msrv:
    name: msrv (1.85 core / 1.88 backends)
    runs-on: ubuntu-latest
    timeout-minutes: 25
    steps:
      - uses: actions/checkout@v7
      - 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 requires 1.88: redis 1.6 declares it, and it also
      # reaches url -> idna -> icu_*. Enforced separately rather than papered
      # over.
      - uses: dtolnay/rust-toolchain@1.88.0
      - run: cargo build --features redis-backend

  lint:
    name: fmt + clippy
    runs-on: ubuntu-latest
    timeout-minutes: 25
    steps:
      - uses: actions/checkout@v7
      - 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@v7
      - 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@v7
      - uses: EmbarkStudios/cargo-deny-action@v2
        with:
          command: check