name: Unit Tests

on:
    push:
        branches:
            - master
    pull_request:

jobs:
    test:
        name: Node v${{ matrix.node_version }} - ${{ matrix.os }}
        runs-on: ${{ matrix.os }}
        strategy:
            matrix:
                node_version: [18.12.0]
                os: [ubuntu-latest, windows-latest]

        steps:
            - name: Checkout Project
              uses: actions/checkout@v3
            - name: Use Node.js ${{ matrix.node_version }}
              uses: actions/setup-node@v3
              with:
                  node-version: ${{ matrix.node_version }}
                  cache: yarn
            - name: Restore CI Cache
              uses: actions/cache@v3
              with:
                  path: node_modules
                  key: ${{ runner.os }}-${{ matrix.node_version }}-${{ hashFiles(matrix.os == 'windows-latest' && '**\yarn.lock' || '**/yarn.lock') }}
            - name: Install Dependencies
              run: yarn --frozen-lockfile
            - name: Test
              run: yarn test:unit
            - name: Upload coverage data to Codecov
              uses: codecov/codecov-action@v1