---
name: test

on:
  push:
    branches:
    - master
  pull_request:
    branches:
    - master

jobs:
  build:
    runs-on: ubuntu-latest
    env:
      CI: true
    strategy:
      matrix:
        node-version: [14.x, 16.x, 18.x]
    name: Use Node.js ${{ matrix.node-version }}
    steps:
      - uses: actions/checkout@v3
      - name: Setup node
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
      - name: npm install
        run: npm i
      - name: Unittesting
        run: npm run test
      - name: Linting
        # Only test on one version to avoid duplicate linter annotations.
        if: ${{ matrix.node-version == '16.x' }}
        run: npm run lint
