name: Test Next Server

on:
  pull_request:
    paths:
      - "www/**"
  push:
    branches:
      - main
    paths:
      - "www/**"

jobs:
  test-next-server:
    runs-on: ubuntu-latest

    defaults:
      run:
        working-directory: ./www

    steps:
    - uses: actions/checkout@v4

    - name: Setup Node.js
      uses: actions/setup-node@v4
      with:
        node-version: '20'

    - name: Install pnpm
      uses: pnpm/action-setup@v4
      with:
        version: 8

    - name: Setup Node.js cache
      uses: actions/setup-node@v4
      with:
        node-version: '20'
        cache: 'pnpm'
        cache-dependency-path: './www/pnpm-lock.yaml'

    - name: Install dependencies
      run: pnpm install

    - name: Run tests
      run: pnpm test