name: Clippy Review

on:
  workflow_dispatch:

jobs:
  clippy-review:
    permissions:
      contents: read
      checks: write
      issues: write
      pull-requests: write
    runs-on: ubuntu-latest
    name: Clippy review
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Get Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy
      - name: Get dependencies
        run: sudo apt update && sudo apt install libwayland-dev libxkbcommon-dev libudev-dev libinput-dev libgbm-dev libseat-dev libsystemd-dev protobuf-compiler
      - name: Setup Lua
        uses: leafo/gh-actions-lua@v10
        with:
          luaVersion: "5.4"
      - name: Setup LuaRocks
        uses: leafo/gh-actions-luarocks@v4
      - name: Run Clippy fix
        run: cargo clippy --fix --allow-dirty
      - name: Clippy review
        uses: reviewdog/action-suggester@v1
        with:
          tool_name: clippy