on:
  [pull_request]

name: Run unit tests
permissions:
  contents: read

jobs:
  unit-test:
    strategy:
      fail-fast: false
      matrix:
        os: [windows-latest, ubuntu-latest, macos-latest]
    name: Run unit tests
    runs-on: ${{ matrix.os }}
    timeout-minutes: 5
    steps:
      - name: "Checkout repository"
        uses: actions/checkout@v5
      - name: "Setup node"
        uses: actions/setup-node@v4.4.0
        with:
          node-version: 20
      - name: "Install dependencies"
        run: npm ci
      - name: "Run tests"
        run: npm run test --if-present
  lint:
    name: Ensure code standards
    runs-on: ubuntu-latest
    timeout-minutes: 5
    steps:
      - name: "Checkout repostiory"
        uses: actions/checkout@v5
      - name: "Setup node"
        uses: actions/setup-node@v4
        with:
          node-version: 20
      - name: "Install dependencies"
        uses: bahmutov/npm-install@v1
      - name: "Lint code"
        run: npm run lint --if-present
