name: Node CI

on: [push, pull_request_target]

jobs:
  build:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [14.x, 16.x, 18.x, 20.x]

    steps:
    - uses: actions/checkout@v4
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v4
      with:
        node-version: ${{ matrix.node-version }}
        check-latest: true
        cache: 'npm'
    - name: Update npm to version 9
      run: npm i -g npm@9 --registry=https://registry.npmjs.org
    - name: Install dependencies
      run: npm ci
    - name: Build, and test the package
      run: |
        npm run build
        npm test
      env:
        CI: true
