name: Node.js CI

on:
  push:
    tags:
      - '*'
  pull_request:
  workflow_dispatch:

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest]
        node-version: [22.x, 24.x, 26.x]
        webpack-version: [5]

    steps:
      - name: Checkout code
        uses: actions/checkout@v5

      - name: Setup Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v5
        with:
          node-version: ${{ matrix.node-version }}
          cache: 'npm'
          cache-dependency-path: '**/package-lock.json'

      - name: Install dependencies
        run: npm ci

      - name: Install webpack ${{ matrix.webpack-version }}
        run: npm i webpack@${{ matrix.webpack-version }} --no-save

      - name: Run tests for webpack ${{ matrix.webpack-version }}
        run: npm test
