name: Unit/Integration Tests

on:
  pull_request:
    types:
      - opened
      - synchronize
      - reopened
      - ready_for_review
  push:
    branches:
      - main
jobs:
  build-and-test:
    strategy:
      matrix:
        node-version: [20.x, 22.x, 24.x]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: true
      - uses: actions/setup-node@v4
        with:
          node-version: '${{ matrix.node-version }}'
      - name: cache node modules
        uses: actions/cache@v4
        with:
          path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
          key: npm-${{ matrix.node-version }}-${{ hashFiles('package-lock.json') }}
          restore-keys: |
            npm-${{ matrix.node-version }}-${{ hashFiles('package-lock.json') }}
            npm-
      - run: npm ci
      - run: npm test
        env:
          CI: true
      - run: npm run test:esm-build
        env:
          CI: true
