name: Check Format

on:
  pull_request:

jobs:
  format-check:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: lts/*

      - name: Setup pnpm
        uses: pnpm/action-setup@v4
        with:
          run_install: false

      - name: Install dependencies
        run: pnpm install

      - name: Check Prettier formatting
        run: |
          pnpm exec prettier --check .

      - name: Setup Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt

      - name: Check Tauri Rust formatting
        working-directory: src-tauri
        run: cargo fmt --all -- --check

      - name: Check Plugin Rust formatting
        working-directory: src-plugin
        run: cargo fmt --all -- --check

      - name: Check Plugin Examples Rust formatting
        working-directory: src-plugin/examples
        run: cargo fmt --all -- --check
