name: Validate PR

on:
  pull_request:

env:
  ACTIONS_ALLOW_UNSECURE_COMMANDS: true

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

jobs:
  build-test:
    name: Build and test
    runs-on: ubuntu-latest
    container:
      image: mcr.microsoft.com/playwright:v1.44.0-jammy
    steps:
      - name: Checkout
        uses: actions/checkout@v4

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

      - uses: bahmutov/npm-install@v1

      - name: Lint (via Turbo)
        run: npm run lint

      - name: Build (via Turbo)
        run: npm run build

      - name: Test (via Turbo)
        run: npm test
        env:
          # For Playwright -- Firefox is unable to launch if the $HOME folder isn't owned by the current user. 
          HOME: /root