name: Web Apps CI

on:
  push:
    paths:
      - 'apps/web-client/**'
      - 'apps/web-docs/**'
      - 'packages/**'
      - 'pnpm-lock.yaml'
      - 'package.json'
  pull_request:
    paths:
      - 'apps/web-client/**'
      - 'apps/web-docs/**'
      - 'packages/**'
      - 'pnpm-lock.yaml'
      - 'package.json'

jobs:
  web-quality-gates:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      
      - name: Setup PNPM
        uses: pnpm/action-setup@v2
        with:
          version: 8
      
      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '25'
          cache: 'pnpm'
      
      - name: Install dependencies
        run: pnpm install --frozen-lockfile
      
      - name: Build shared packages
        run: pnpm --filter './packages/*' build
      
      - name: Lint Web Client
        run: pnpm --filter @goodgo/web-client lint
      
      - name: Type check Web Client
        run: pnpm --filter @goodgo/web-client typecheck

      - name: Test Web Client
        run: pnpm --filter @goodgo/web-client test

      - name: Install Playwright Chromium
        run: pnpm --filter @goodgo/web-client exec playwright install --with-deps chromium

      - name: Run Web Client E2E (Auth + Settings)
        run: pnpm --filter @goodgo/web-client exec playwright test e2e/auth.spec.ts e2e/settings.spec.ts --project=chromium
      
      - name: Build Web Client
        run: pnpm --filter @goodgo/web-client build

      - name: Build Web Docs
        run: pnpm --filter @goodgo/vitepress-docs build
