name: 'Continuous Integration'

on:
  push:
    branches:
    - master
  pull_request:

jobs:
  test:
    name: Test
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]

    steps:
    - uses: actions/checkout@v3

    - name: Setup Node.js 16.x
      uses: actions/setup-node@v3
      with:
        node-version: '16.x'

    - name: Install
      run: npm clean-install

    - name: Verify
      if: runner.os == 'Linux'
      run: |
        npm run build
        # Fail if "npm run build" generated new changes in dist
        git update-index --refresh dist/* && git diff-index --quiet HEAD dist

    - name: Test
      run: npm test
