name: CI
on:
  workflow_dispatch:

jobs:
  build-test:
    runs-on: ubuntu-latest
    env:
      APP_ENV: dev
      DEV_COOKIE_INSECURE: "true"
      E2E_BASE_URL: http://127.0.0.1:8080

    steps:
      - uses: actions/checkout@v4

      - uses: shivammathur/setup-php@v2
        with:
          php-version: '8.2'
          coverage: none

      - name: Composer install
        run: composer install --no-interaction --prefer-dist

      - uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'

      - name: NPM ci
        run: npm ci --ignore-scripts

      - name: Greps anti-legacy
        run: bash tools/ci/guards.sh

      - name: Démarrer serveur PHP
        run: |
          nohup php -S 127.0.0.1:8080 -t public >/dev/null 2>&1 &
          sleep 1

      - name: PHPUnit
        run: composer test:php

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

      - name: E2E Playwright
        run: npx playwright test


