name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: ['22', '24']
    steps:
      - uses: actions/checkout@v5

      - uses: actions/setup-node@v5
        with:
          node-version: ${{ matrix.node-version }}
          cache: 'npm'

      - run: npm ci

      - run: npm run typecheck

      - run: npm test

      - run: npm run build

      - name: Verify .ts/.js siblings are in sync
        run: |
          if ! git diff --exit-code; then
            echo "::error::Built .js files differ from committed siblings. Run 'npm run build' and commit the result."
            exit 1
          fi
