name: Pull Request Checks

on:
  pull_request:
  push:
    branches:
      - main
      - master
  workflow_dispatch:

concurrency:
  group: pr-checks-${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

permissions:
  contents: read

jobs:
  quality-checks:
    name: Code Quality & Security
    runs-on: ubuntu-latest

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

      - name: Setup Node & pnpm
        uses: ./.github/actions/setup-node-pnpm

      - name: Install dependencies
        run: pnpm install --frozen-lockfile

      - name: Check formatting
        run: pnpm format:check

      - name: Run linter
        run: pnpm lint

      - name: Run type check
        run: pnpm type-check

      - name: Run tests
        run: pnpm test

      - name: Build
        run: pnpm build

      - name: Verify domain dist is up-to-date
        run: pnpm domain:check-dist
