name: Tests and Code Coverage

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]
    types: [opened, synchronize, reopened, ready_for_review]


jobs:
  security-scan:
    name : Security Scan
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Run npm audit
        run: npm audit --production

  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        nodeVersion: [ 22, 24, 26 ]
    name: Run Tests - Node ${{ matrix.nodeVersion }}
    steps:
      - uses: actions/checkout@v4
      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: ${{ matrix.nodeVersion }}
          check-latest: true
          cache: 'npm'
      - name: Run tests and collect coverage
        run: ./scripts/cibuild.sh
      - name: Upload coverage reports to Codecov
        # https://github.com/marketplace/actions/codecov
        uses: codecov/codecov-action@v3
