# This workflow will do a clean installation of node dependencies, cache/restore them, 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

on: ['push', 'pull_request']

jobs:
  build:
    runs-on: ubuntu-22.04

    strategy:
      matrix:
        node-version: ['22.23.4', '24.22.1']
        # See supported Node.js release schedule at https://nodejs.org/en/about/releases/

    steps:
      - name: Report GitHub-managed Actions Node.js runtime
        run: |
          runner_root="$(dirname "$(dirname "$(readlink -f /proc/$PPID/exe)")")"
          "$runner_root/externals/node24/bin/node" -e '
            console.log("GitHub Actions runtime:", process.version, process.execPath);
            const [major, minor, patch] = process.versions.node.split(".").map(Number);
            if (major !== 24 || minor < 22 || (minor === 22 && patch < 1)) {
              console.warn("::warning::GitHub-managed Action runtime is below Node.js 24.22.1; setup-node only secures the build runtime.");
            }
          '
      - uses: actions/checkout@v7.0.1
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v7.1.0
        with:
          node-version: ${{ matrix.node-version }}
          cache: 'npm'
      - name: Verify build runtime
        run: |
          node --version
          test "$(node --version)" = "v${{ matrix.node-version }}"
          npm --version
      - run: npm ci
      - run: npm run lint
      - run: npm run build
      - run: MODE=prod npm run build
      - run: npx playwright install
      - run: npm run test
