name: Check Quality

on: pull_request

env:
  NODE_VERSION: 16.14.2

jobs:
  lint:
    name: Lint files
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          ref: ${{ github.event.pull_request.head.ref }}
          fetch-depth: 0
      - uses: actions/setup-node@v3
        with:
          node-version: ${{ env.NODE_VERSION }}
      - name: Install NPM deps
        run: npm ci
      - name: Run linting
        run: npm run lint

  unit-test:
    name: Unit Test
    runs-on: ubuntu-latest
    environment: development
    steps:
      - uses: actions/checkout@v3
        with:
          ref: ${{ github.event.pull_request.head.ref }}
          fetch-depth: 0
      - uses: actions/setup-node@v3
        with:
          node-version: ${{ env.NODE_VERSION }}
      - name: Install NPM deps
        run: npm ci
      - name: Run unit tests
        run: npm run jest