name: erp-kit Unit Test

# Unit tests run on a mock runtime — no workspace or credentials needed.
# A separate workflow lets them run in parallel with the integration tests.
on:
  push:
    branches: [main]
    paths:
      - "modules/**"
  pull_request:
    branches: [main]
    paths:
      - "modules/**"

jobs:
  unit-test:
    runs-on: ubuntu-slim
    timeout-minutes: 10
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false

      - uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10

      - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
        with:
          cache: pnpm
          cache-dependency-path: ./pnpm-lock.yaml
          node-version-file: package.json

      - run: pnpm install

      - name: Run module unit tests
        # Run the command directly instead of a root script.
        # This file may be copied into a repo that lacks that script,
        # where a script call would fail with a missing-script error.
        run: pnpm --recursive --if-present run test
