mirror of
https://github.com/HDInnovations/UNIT3D.git
synced 2026-01-31 01:35:31 +01:00
138 lines
5.4 KiB
YAML
138 lines
5.4 KiB
YAML
name: PHPUnit Test (Pest)
|
|
on: [ push, pull_request ]
|
|
jobs:
|
|
tests:
|
|
strategy:
|
|
fail-fast: true
|
|
matrix:
|
|
operating-system:
|
|
- ubuntu-24.04
|
|
php-version:
|
|
- '8.5'
|
|
name: php ${{ matrix.php-version }} on ${{ matrix.operating-system }}
|
|
runs-on: ${{ matrix.operating-system }}
|
|
services:
|
|
mysql:
|
|
image: mysql:8.0
|
|
env:
|
|
MYSQL_ALLOW_EMPTY_PASSWORD: yes
|
|
MYSQL_DATABASE: unit3d
|
|
ports:
|
|
- 3306:3306
|
|
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
|
redis:
|
|
image: redis:7.2.1
|
|
ports:
|
|
- 6379:6379
|
|
options: >-
|
|
--health-cmd "redis-cli ping"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
steps:
|
|
# 1. Checkout
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
# 2. Setup PHP
|
|
- name: Setup PHP
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: ${{ matrix.php-version }}
|
|
extensions: curl, dom, gd, libxml, mbstring, zip, mysql, xml, intl, bcmath, redis-phpredis/phpredis@6.0.1
|
|
ini-values: error_reporting=E_ALL
|
|
coverage: pcov
|
|
tools: composer:v2
|
|
env:
|
|
REDIS_CONFIGURE_OPTS: --enable-redis
|
|
|
|
# 3. Composer Dependencies
|
|
- name: Get Composer cache directory
|
|
id: composer-cache
|
|
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Restore Composer cache
|
|
uses: actions/cache/restore@v4
|
|
with:
|
|
path: ${{ steps.composer-cache.outputs.dir }}
|
|
key: unit3d-${{ matrix.operating-system }}-php${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.lock') }}
|
|
restore-keys: |
|
|
unit3d-${{ matrix.operating-system }}-php${{ matrix.php-version }}-composer-
|
|
|
|
- name: Install Composer dependencies
|
|
env:
|
|
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
|
|
run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --optimize-autoloader
|
|
|
|
- name: Save Composer cache
|
|
uses: actions/cache/save@v4
|
|
if: always()
|
|
with:
|
|
path: ${{ steps.composer-cache.outputs.dir }}
|
|
key: unit3d-${{ matrix.operating-system }}-php${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.lock') }}
|
|
|
|
# 4. Bun Dependencies
|
|
- name: Setup Bun
|
|
uses: oven-sh/setup-bun@v2
|
|
with:
|
|
bun-version: latest
|
|
|
|
- name: Restore Bun cache
|
|
uses: actions/cache/restore@v4
|
|
with:
|
|
path: ~/.bun/install/cache
|
|
key: unit3d-${{ matrix.operating-system }}-php${{ matrix.php-version }}-bun-${{ hashFiles('**/bun.lockb') }}
|
|
restore-keys: |
|
|
unit3d-${{ matrix.operating-system }}-php${{ matrix.php-version }}-bun-
|
|
|
|
- name: Install Bun dependencies
|
|
run: bun ci
|
|
|
|
- name: Compile assets
|
|
run: bun run build
|
|
|
|
- name: Save Bun cache
|
|
uses: actions/cache/save@v4
|
|
if: always()
|
|
with:
|
|
path: ~/.bun/install/cache
|
|
key: unit3d-${{ matrix.operating-system }}-php${{ matrix.php-version }}-bun-${{ hashFiles('**/bun.lockb') }}
|
|
|
|
# 5. Prepare Application
|
|
- name: Prepare Laravel environment
|
|
run: cp .env.example .env
|
|
|
|
- name: Generate application key
|
|
run: php artisan key:generate
|
|
|
|
- name: Clear application cache
|
|
run: php artisan clear:all_cache
|
|
|
|
# 6. PHPUnit Tests
|
|
- name: Restore PHPUnit cache
|
|
uses: actions/cache/restore@v4
|
|
with:
|
|
path: .phpunit.cache
|
|
key: unit3d-${{ matrix.operating-system }}-php${{ matrix.php-version }}-phpunit-${{ github.run_id }}
|
|
restore-keys: |
|
|
unit3d-${{ matrix.operating-system }}-php${{ matrix.php-version }}-phpunit-
|
|
|
|
- name: Run PHPUnit tests
|
|
run: COLUMNS=200 ./vendor/bin/pest --compact --parallel --processes=4
|
|
env:
|
|
DB_CONNECTION: mysql
|
|
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
|
|
DB_USERNAME: root
|
|
DB_DATABASE: unit3d
|
|
DB_PASSWORD: null
|
|
CACHE_STORE: array
|
|
|
|
- name: Save PHPUnit cache
|
|
uses: actions/cache/save@v4
|
|
if: always()
|
|
with:
|
|
path: .phpunit.cache
|
|
key: unit3d-${{ matrix.operating-system }}-php${{ matrix.php-version }}-phpunit-${{ github.run_id }}
|