name: Test PRs

on:
  pull_request: # Trigger for pull requests.
    types: [opened, synchronize, reopened]
  workflow_dispatch: # Allows for manual triggering.
    inputs:
      ref:
        description: "The ref to build and test."
        required: False

concurrency:
  group: ${{ github.workflow }}-${{ github.event.number || inputs.ref }}
  cancel-in-progress: true

jobs:
  test:
    name: Test
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          ref: ${{ inputs.ref || github.ref }}
          persist-credentials: false

      - name: Test
        run: |
          npm ci
          npm test