name: Node CI

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [24.x]

    steps:
    - uses: actions/checkout@v6
      with:
        fetch-depth: 0

    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v6
      with:
        node-version: ${{ matrix.node-version }}
        cache: 'npm'

    - run: npm install

    - name: Cache Playwright browsers
      uses: actions/cache@v5
      with:
          path: ~/.cache/ms-playwright
          key: ${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-playwright-

    - name: Install Playwright browsers
      run: npx playwright install --with-deps chromium

    - name: npm test - Vitest
      run: npm test

    - name: Upload coverage reports to Codecov
      uses: codecov/codecov-action@v7
      with:
        token: ${{ secrets.CODECOV_TOKEN }}
        files: ./coverage/lcov.info

