name: Quality

on:
  pull_request:
  push:
    branches: [main]

permissions:
  contents: read

jobs:
  quality:
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4
      - uses: oven-sh/setup-bun@v2
        with:
          bun-version: 1.3.14
      - uses: actions/setup-node@v4
        with:
          node-version: 24
          cache: npm
          cache-dependency-path: editors/vscode/package-lock.json
      - name: Install framework dependencies
        run: bun install --frozen-lockfile
      - name: Install editor dependencies
        run: npm ci --prefix editors/vscode
      - name: Typecheck
        run: bun run typecheck
      - name: Lint
        run: bun run lint
      - name: Formatting
        run: bun run format:check
      - name: Package and application tests
        run: bun run test:all
      - name: Package contracts
        run: bun run check:public-api && bun run check:ui-visual && bun run audit:packages && bun run test:package-kits && bun run validate:staging
      - name: Stage and test publishable packages
        if: matrix.os == 'ubuntu-latest'
        run: bun run stage:packages && bun run test:staged-consumers
      - name: Framework validation
        run: bun run validate:0.8
      - name: Dependency audit
        run: bun audit
      - name: Editor dependency audit
        run: npm audit --prefix editors/vscode --audit-level=high
