name: Backend Unit Tests
on:
  push:
  pull_request:
  workflow_dispatch:

jobs:
  unit-test:
    name: Backend Unit Tests
    runs-on: ov-actions-runner
    steps:
      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '22.13'
      - name: Setup OpenVidu Meet
        uses: OpenVidu/actions/start-openvidu-meet@main
        with:
          skip_backend_start: 'true'
      - name: Run tests
        run: |
          cd backend
          npm run test:unit
        env:
          JEST_JUNIT_OUTPUT_DIR: './reports/'
      - name: Publish Test Report
        uses: mikepenz/action-junit-report@v4
        if: always()
        with:
          report_paths: '**/reports/junit.xml'
          fail_on_failure: true
          require_tests: true
      - name: Clean up
        if: always()
        uses: OpenVidu/actions/cleanup@main
