name: Validate

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:

    runs-on: ubuntu-latest

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

    steps:
    - uses: actions/checkout@v2
      with:
        fetch-depth: 0
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v3
    - run: npm ci
    - run: npm run lint
    - run: npm run test:coverage
    - name: Check Coverage
      if: github.ref != 'refs/heads/main'
      run: npm run check:coverage
