name: Run Node Unit Tests

on:
  pull_request:
    branches:
      - master
  workflow_call:

permissions: {}

jobs:
  tests:
    strategy:
      fail-fast: false
      matrix:
        os:
          - macos-12
          - ubuntu-22.04
          - windows-2022
        node-version:
          - '16'
          - '18'
          - '20'
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4.0.0
      - uses: actions/setup-node@v3.8.1
        with:
          cache: 'npm'
          check-latest: true
          node-version: ${{ matrix.node-version }}
      - name: Install dependencies
        run: npm ci
      - name: Lint with npm
        run: npm run stylelint
      - name: Test with npm
        run: npm run test
