name: CI - Lint, Typecheck & Test

on:
  pull_request:

concurrency:
  group: deploy-pipeline
  cancel-in-progress: true

jobs:
  quality-assurance:
    runs-on: docker
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Setup pnpm
        uses: pnpm/action-setup@v3
        with:
          version: 10
          run_install: false

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 20

      - name: 🔐 Configure Private Registry
        run: |
          REGISTRY="${{ vars.REGISTRY_HOST || 'npm.infra.mintel.me' }}"
          echo "@mintel:registry=https://$REGISTRY" > .npmrc
          echo "//$REGISTRY/:_authToken=${{ secrets.REGISTRY_PASS }}" >> .npmrc

      - name: Install dependencies
        run: pnpm install
        env:
          NPM_TOKEN: ${{ secrets.REGISTRY_PASS }}

      - name: 🧪 QA Checks
        env:
          TURBO_TELEMETRY_DISABLED: "1"
        run: npx turbo run check:mdx lint typecheck test --cache-dir=".turbo"

      - name: 🏗️ Build
        run: pnpm build

      - name: ♿ Accessibility Check
        run: pnpm start-server-and-test start http://localhost:3000 "pnpm check:a11y http://localhost:3000"

      - name: ♿ WCAG Sitemap Audit
        run: pnpm start-server-and-test start http://localhost:3000 "pnpm run check:wcag http://localhost:3000"
# monitor trigger
