# inspired by https://github.com/GitTools/GitVersion/blob/main/.github/workflows/_unit_tests.yml
on:
  workflow_call:
env:
  DOTNET_ROLL_FORWARD: 'Major'

jobs:
  unit_test:
    name: Unit Tests (${{ matrix.os }})
    strategy:
      fail-fast: false
      matrix:
        os: [windows-latest, ubuntu-latest, macos-latest]

    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v7
        with:
          fetch-depth: 0

      - run: corepack enable # enable corepack before setup-node
      - name: Setup Node
        uses: actions/setup-node@v7
        with:
          node-version-file: .nvmrc
      - run: corepack enable # enable corepack AFTER setup-node
      - name: Setup Node Cache
        uses: actions/setup-node@v7
        with:
          node-version-file: .nvmrc
          cache: yarn
      - run: corepack enable # Assure it's enabled

      - run: yarn install --immutable

      - uses: actions/setup-dotnet@v6.0.0
        with:
          dotnet-version: '8.x'

      - run: dotnet test
