# Run `cargo-unused-features` for finding out unused features
# NOTE: this is broken for now, see https://github.com/TimonPost/cargo-unused-features/pull/10

name: Cargo Unused Features

on:
  workflow_dispatch:

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true

jobs:
  bloat:
    name: Cargo Unused Features
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install Rust Toolchain
        uses: ./.github/actions/rustup

      - name: Install cargo-unused-features
        uses: taiki-e/install-action@v2
        with:
          tool: cargo-unused-features

      - name: Run
        run: unused-features analyze

  check-dependencies:
    name: Check Unused Dependencies
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: dorny/paths-filter@v2
        id: filter
        with:
          filters: |
            src:
              - 'Cargo.lock'

      - name: Install cargo-udeps
        if: steps.filter.outputs.src == 'true'
        uses: taiki-e/install-action@cargo-udeps

      - if: steps.filter.outputs.src == 'true'
        run: cargo udeps
