name: Validate style and tests

on:
  pull_request:
    paths:
      - "**/*.js"
      - "**/*.ts"
      - package.json
      - test/**
    branches:
      - main

jobs:
  check:
    runs-on:
      - ubuntu-latest
    steps:
      - name: Checkout
        id: checkout
        uses: actions/checkout@v3

      - uses: actions/setup-node@v2
        with:
          node-version: 19
          cache: npm

      - name: Install dependencies
        run: npm i

      - name: Check Format
        run: npm run fmt-check

      - name: Run unit tests
        run: npm test
