Add Vitest (test:unit) with exact-value tests for the crop math (containScale, defaultSelection, clampSelection, all resizeSelection corners, and mime/filename resolution), and wire it plus the Pest browser test into CI. The browser test now samples output pixels against a four-quadrant fixture, so it detects a blank, flipped, or wrong crop rather than only asserting a 512x512 canvas. Add composer test:all to run PHP + Vitest + browser tests locally.
111 lines
2.9 KiB
YAML
111 lines
2.9 KiB
YAML
name: Tests
|
|
|
|
on:
|
|
push:
|
|
branches: [main, develop]
|
|
pull_request:
|
|
branches: [main, develop]
|
|
|
|
jobs:
|
|
tests:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
DB_CONNECTION: pgsql
|
|
DB_DATABASE: trypost_test
|
|
DB_USERNAME: postgres
|
|
DB_PASSWORD: password
|
|
BROADCAST_CONNECTION: "null"
|
|
CACHE_STORE: array
|
|
QUEUE_CONNECTION: sync
|
|
SESSION_DRIVER: array
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:16
|
|
env:
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: password
|
|
POSTGRES_DB: trypost_test
|
|
ports:
|
|
- 5432/tcp
|
|
options: >-
|
|
--health-cmd="pg_isready"
|
|
--health-interval=10s
|
|
--health-timeout=5s
|
|
--health-retries=3
|
|
|
|
redis:
|
|
image: redis:7
|
|
ports:
|
|
- 6379/tcp
|
|
options: >-
|
|
--health-cmd="redis-cli ping"
|
|
--health-interval=10s
|
|
--health-timeout=5s
|
|
--health-retries=3
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup PHP
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: '8.4'
|
|
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_pgsql, bcmath, intl, gd, redis
|
|
coverage: none
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22'
|
|
cache: 'npm'
|
|
|
|
- name: Cache Composer dependencies
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: vendor
|
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
|
restore-keys: ${{ runner.os }}-composer-
|
|
|
|
- name: Prepare environment
|
|
run: cp .env.ci .env
|
|
|
|
- name: Install Composer dependencies
|
|
run: composer install --no-interaction --prefer-dist --optimize-autoloader
|
|
|
|
- name: Install npm dependencies
|
|
run: npm ci
|
|
|
|
- name: Generate application key
|
|
run: php artisan key:generate
|
|
|
|
- name: Build assets
|
|
run: npm run build
|
|
|
|
- name: Run frontend unit tests
|
|
run: npm run test:unit
|
|
|
|
- name: Run migrations
|
|
run: php artisan migrate --force
|
|
env:
|
|
DB_PORT: ${{ job.services.postgres.ports['5432'] }}
|
|
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
|
|
|
|
- name: Generate Passport keys
|
|
run: php artisan passport:keys --force
|
|
|
|
- name: Run tests
|
|
run: php artisan test --compact --parallel
|
|
env:
|
|
DB_PORT: ${{ job.services.postgres.ports['5432'] }}
|
|
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
|
|
|
|
- name: Install Playwright browsers
|
|
run: npx playwright install --with-deps chromium
|
|
|
|
- name: Run browser tests
|
|
run: php artisan test tests/Browser --compact
|
|
env:
|
|
DB_PORT: ${{ job.services.postgres.ports['5432'] }}
|
|
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
|