name: Pull Request

on:
  pull_request:
    branches: [main, canary]

jobs:
  lint-and-typecheck:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: pnpm/action-setup@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 18.18.0
          cache: "pnpm"
      - run: pnpm install --frozen-lockfile
      - run: pnpm run server:build
      - run: pnpm typecheck

  build-and-test:
    needs: lint-and-typecheck
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: pnpm/action-setup@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 18.18.0
          cache: "pnpm"
      - run: pnpm install --frozen-lockfile
      - run: pnpm run server:build
      - run: pnpm build

  parallel-tests:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: pnpm/action-setup@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 18.18.0
          cache: "pnpm"
      - run: pnpm install --frozen-lockfile
      - run: pnpm run server:build
      - run: pnpm test
