name: Svelte Check

on:
  push:
    branches: [main, breaking/**]
    paths:
      - "frontend/src/**"
      - ".github/svelte-check-matcher.json"
      - "frontend/package.json"
      - "frontend/package-lock.json"
      - "frontend/tsconfig.json"
      - "frontend/svelte.config.js"
  pull_request:
    branches: [main]
    paths:
      - "frontend/src/**"
      - ".github/svelte-check-matcher.json"
      - "frontend/package.json"
      - "frontend/package-lock.json"
      - "frontend/tsconfig.json"
      - "frontend/svelte.config.js"
  workflow_dispatch:

jobs:
  type-check:
    name: Run Svelte Check
    # Don't run on dependabot branches
    if: github.actor != 'dependabot[bot]'
    runs-on: ubuntu-latest
    permissions:
      contents: read
      checks: write
      pull-requests: write

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

      - name: Setup pnpm
        uses: pnpm/action-setup@v4

      - name: Setup Node.js
        uses: actions/setup-node@v5
        with:
          node-version: 22

      - name: Install dependencies
        run: pnpm --filter pocket-id-frontend install --frozen-lockfile

      - name: Build Pocket ID Frontend
        working-directory: frontend
        run: pnpm --filter pocket-id-frontend build

      - name: Add svelte-check problem matcher
        run: echo "::add-matcher::.github/svelte-check-matcher.json"

      - name: Run svelte-check
        working-directory: frontend
        run: pnpm --filter pocket-id-frontend check
