name: CI

on:
  push:
    branches: [main]

# Cancel an in-progress run when newer commits are pushed to the same ref.
concurrency:
  group: ci-${{ github.ref }}
  cancel-in-progress: true

jobs:
  test:
    name: Unit tests (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: npm

      # The capture unit tests require app/capture.js, which require()s the
      # electron module at load — so the Electron binary must actually be
      # installed (don't set ELECTRON_SKIP_BINARY_DOWNLOAD here).
      - name: Install dependencies
        run: npm ci

      - name: Run unit tests
        run: npm test
