name: Tests

on:
  pull_request:
    branches: ['*']

jobs:
  test:
    name: Test on node ${{ matrix.node-version }}
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [12.x, 14.x, 15.x]

    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v2
        with:
          node-version: ${{ matrix.node-version }}
      - name: Install dependencies
        run: npm ci
      - name: Build
        run: npm run build --if-present
      - name: Run linters
        run: npm run lint
      - name: Run tests
        run: npm test
