name: Quality

on:
  push:
    branches: ["main"]
  pull_request:

jobs:
  quality:
    runs-on: ubuntu-24.04

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

      - name: Install Linux system deps for Tauri
        run: |
          sudo apt-get update
          sudo apt-get install -y \
            pkg-config \
            libwebkit2gtk-4.1-dev \
            libsoup-3.0-dev \
            libjavascriptcoregtk-4.1-dev

      - name: Setup Node (GitHub Actions)
        if: ${{ env.ACT != 'true' }}
        uses: actions/setup-node@v4
        with:
          node-version: 22
          cache: npm

      - name: Setup Node (act)
        if: ${{ env.ACT == 'true' }}
        uses: actions/setup-node@v4
        with:
          node-version: 22

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

      - name: Install Rust clippy component
        run: rustup component add clippy

      - name: Install JS deps
        run: npm ci

      - name: Check system deps script
        run: npm run deps:check

      - name: Frontend typecheck
        run: npx tsc --noEmit

      - name: Rust check
        working-directory: src-tauri
        run: cargo check

      - name: Rust tests
        working-directory: src-tauri
        run: cargo test

      - name: Rust clippy
        working-directory: src-tauri
        run: cargo clippy -- -D warnings
