criterion2 3.0.5

Statistics-driven micro-benchmarking library
name: CI

on:
  pull_request:
    branches:
      - main
  push:
    branches:
      - main
      - "renovate/**"

jobs:
  ci:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        rust:
          - stable
          - 1.85.0 # MSRV
          - nightly

    steps:
      - uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2

      # rust-toolchain.toml overrides the installed toolchain for every cargo
      # invocation, so versioned lanes must opt out of it to test what they claim.
      - name: Override pinned toolchain for versioned lanes
        if: ${{ matrix.rust != 'stable' && matrix.rust != 'nightly' }}
        run: echo "RUSTUP_TOOLCHAIN=${{ matrix.rust }}" >> "$GITHUB_ENV"

      - uses: dtolnay/rust-toolchain@2c7215f132e9ebf062739d9130488b56d53c060c # master
        name: Setup rust toolchain
        with:
          toolchain: ${{ matrix.rust }}
          components: rustfmt, clippy

      - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
        with:
          save-if: ${{ github.ref_name == 'main' }}

      - name: Build with stable features
        run: cargo build --features stable

      - name: Build with unstable features
        if: ${{ matrix.rust == 'nightly' }}
        run: cargo build --all-features

      - name: Build with minimal features
        run: cargo build --no-default-features

      - name: Test with stable features
        run: cargo test --features stable

      - name: Test with minimal features
        run: cargo test --no-default-features

      - name: Check codspeed
        run: cargo check --features codspeed

      - name: Check for non-standard formatting
        if: ${{ matrix.rust == 'stable' }}
        run: cargo fmt --all -- --check

      - name: Check for clippy hints
        if: ${{ matrix.rust == 'stable' }}
        run: cargo clippy --workspace --all-targets -- -D warnings

  nextest-compat:
    name: Check compatibility with nextest
    runs-on: ubuntu-latest
    strategy:
      matrix:
        rust:
          - stable

    steps:
      - uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2

      - uses: dtolnay/rust-toolchain@2c7215f132e9ebf062739d9130488b56d53c060c # master
        with:
          toolchain: ${{ matrix.rust }}
          components: rustfmt, clippy

      - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
        with:
          shared-key: test
          save-if: ${{ github.ref_name == 'main' }}

      - uses: taiki-e/install-action@69db1bbfd1881e5f6f05afd6a7354ab039991fb7 # nextest

      - run: ci/nextest-compat.sh

  unused-deps:
    name: Check Unused Dependencies
    runs-on: ubuntu-latest
    steps:
      - uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2
      - uses: oxc-project/setup-rust@3d6fb132fbe7cdcb66bf8ec193911c2945369d12 # v1.0.17
        with:
          restore-cache: false
          tools: cargo-shear@1
      - run: cargo shear