# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

permissions:
  contents: read

on: [ push, pull_request ]

jobs:
  quality:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v7
    - name: Use Node.js 26.x
      uses: actions/setup-node@v7
      with:
        node-version: 26.x
    - run: npm ci
    - run: npm run format:check
    - run: npm run lint

  build:
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]
        node-version: [20.x, 22.x, 24.x, 26.x]

    runs-on: ${{ matrix.os }}

    steps:
    - uses: actions/checkout@v7
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v7
      with:
        node-version: ${{ matrix.node-version }}
    - run: npm ci
    - run: npm run build:all
    - run: npm test

    - name: Check generated lib is clean
      run: git diff --exit-code -- ./lib
