91 lines
2.4 KiB
YAML
91 lines
2.4 KiB
YAML
name: Tests
|
|
|
|
on:
|
|
push:
|
|
branches: [main, develop]
|
|
pull_request:
|
|
branches: [main, develop]
|
|
|
|
jobs:
|
|
tests:
|
|
runs-on: ubuntu-latest
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:16
|
|
env:
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: password
|
|
POSTGRES_DB: trypost_test
|
|
ports:
|
|
- 5432:5432
|
|
options: >-
|
|
--health-cmd="pg_isready"
|
|
--health-interval=10s
|
|
--health-timeout=5s
|
|
--health-retries=3
|
|
|
|
redis:
|
|
image: redis:7
|
|
ports:
|
|
- 6379:6379
|
|
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: Install Composer dependencies
|
|
run: composer install --no-interaction --prefer-dist --optimize-autoloader
|
|
|
|
- name: Install npm dependencies
|
|
run: npm ci
|
|
|
|
- name: Build assets
|
|
run: npm run build
|
|
|
|
- name: Prepare environment
|
|
run: |
|
|
cp .env.example .env
|
|
php artisan key:generate
|
|
|
|
- name: Configure test environment
|
|
run: |
|
|
sed -i 's/DB_CONNECTION=mysql/DB_CONNECTION=pgsql/' .env
|
|
sed -i 's/DB_PORT=3306/DB_PORT=5432/' .env
|
|
sed -i 's/DB_DATABASE=trypost/DB_DATABASE=trypost_test/' .env
|
|
sed -i 's/DB_USERNAME=root/DB_USERNAME=postgres/' .env
|
|
sed -i 's/DB_PASSWORD=/DB_PASSWORD=password/' .env
|
|
sed -i 's/CACHE_STORE=redis/CACHE_STORE=array/' .env
|
|
sed -i 's/QUEUE_CONNECTION=redis/QUEUE_CONNECTION=sync/' .env
|
|
sed -i 's/SESSION_DRIVER=database/SESSION_DRIVER=array/' .env
|
|
|
|
- name: Run migrations
|
|
run: php artisan migrate --force
|
|
|
|
- name: Run tests
|
|
run: php artisan test --compact
|