name: Unit Tests

on:
  pull_request:
    types: [opened, synchronize, reopened]
    branches: [master]

env:
  GITHUB_TOKEN: ${{ secrets.TOPTAL_DEVBOT_TOKEN }}
  NPM_TOKEN: ${{ secrets.NPM_TOKEN_READ_ONLY }}

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  unit-tests:
    name: Check:UnitTests
    runs-on: [ 'org/toptal', 'os/linux', 'arch/x64', 'size/large' ]
    strategy:
      fail-fast: false
      matrix:
        index: [0, 1, 2] # create 3 parallel instances
    env:
      GROUP_INDEX: ${{ matrix.index }}
      GROUP_TOTAL: ${{ strategy.job-total }}
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Setup Node.js
        uses: actions/setup-node@v6
        with:
          node-version: 20

      - uses: toptal/davinci-github-actions/pnpm-install@v20.0.0

      - uses: toptal/davinci-github-actions/unit-tests@v20.0.0
