name: Test
on:
  pull_request:
  push:
permissions:
  contents: read

jobs:
  test:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        node: [12, 14, 16, 18]
        os: [ubuntu-20.04]
    name: Node ${{ matrix.node }}
    steps:
      - uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # v3

      - name: Setup node
        uses: actions/setup-node@5b52f097d36d4b0b2f94ed6de710023fbb8b2236 # v3.1.0
        with:
          node-version: ${{ matrix.node }}

      - run: npm install

      - run: npm test

  lint:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        node: [18]
        os: [ubuntu-20.04]
    name: Lint
    steps:
      - uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # v3

      - name: Setup node
        uses: actions/setup-node@5b52f097d36d4b0b2f94ed6de710023fbb8b2236 # v3.1.0
        with:
          node-version: ${{ matrix.node }}

      - run: npm install

      - run: npm run lint