name: PR testing

on:
  pull_request:
    types: [opened, reopened, synchronize, ready_for_review]

jobs:
  test:
    if: github.event.pull_request.draft == false #to not run the check if the PR is a draft
    name: Testing on ${{ matrix.os }} using Node ${{ matrix.node }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        node: [ '10', '14', '15' ] #for now versions must be hardcoded as aliases like lts or latest are not yet supported by setup-node action https://github.com/actions/setup-node/issues/26
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
      - name: Setup Node.js ${{ matrix.node }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node }}
      - name: Audit package-lock.json
        run: npx package-lock-audit ./package-lock.json
      - name: Install dependencies
        run: npm install
      - name: Run test
        run: npm test
      - name: Run linter
        run: npm run lint
