name: "Run tests"

on:
  pull_request:
    branches:
      - "*"
permissions:
  contents: write
  pull-requests: write
  id-token: write
jobs:
  test:
    name: Dependency Check
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node_version: [24]
    steps:
      - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
      - name: Use Node.js 24
        uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e
        with:
          node-version: 24
      - name: Install root dependencies
        run: npm ci
      - name: Use Node.js ${{ matrix.node_version }}
        uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e
        with:
          node-version: ${{ matrix.node_version }}
      - name: Install dependencies
        working-directory: test${{ matrix.node_version }}
        run: npm ci
      - name: Run test
        working-directory: test${{ matrix.node_version }}
        run: npm test
  dependabot-auto-merge:
    needs: [test]
    if: ${{ github.actor == 'dependabot[bot]' }}
    runs-on: ubuntu-latest
    timeout-minutes: 5
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - name: approve Dependabot PR
        run: |
          gh pr review --approve ${{ github.event.pull_request.html_url }} --body "Auto approved by CI"
      - name: Enable auto-merge for Dependabot PRs
        run: |
          gh pr merge --auto --squash ${{ github.event.pull_request.html_url }}
