name: Tests

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main
  workflow_dispatch:

concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  cancel-in-progress: true

jobs:
  test:
    runs-on: ${{ matrix.os }}
    timeout-minutes: 10

    strategy:
      fail-fast: true
      matrix:
        os: [ubuntu-latest]
        node-version: [22, 24]
        include:
          # Single macOS runner — verifies platform compatibility
          - os: macos-latest
            node-version: 22
          # Single Windows runner — slowest CI runner, smoke-test only
          - os: windows-latest
            node-version: 22

    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd  # v6.0.2

      - name: Set up Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f  # v6.3.0
        with:
          node-version: ${{ matrix.node-version }}
          cache: 'npm'

      - name: Install dependencies
        run: npm ci

      - name: Run tests with coverage
        shell: bash
        run: npm run test:coverage
