Skip to content

chore: update composer packages #196

chore: update composer packages

chore: update composer packages #196

name: HeyCommunity Commit
on: ['push', 'pull_request']
jobs:
laravel-tests:
name: PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }}
runs-on: ${{ matrix.operating-system }}
## 操作系统和 PHP 版本
strategy:
matrix:
operating-system: ['ubuntu-20.04', 'ubuntu-18.04']
php-versions: ['7.4', '8.0', '8.1']
## 环境变量
env:
APP_ENV: local
APP_DEBUG: true
DB_DATABASE: prod_heycommunity
DB_USERNAME: root
DB_PASSWORD: password
DB_PORT: 33306
REDIS_PORT: 33977
CACHE_DRIVER: redis
QUEUE_CONNECTION: redis
SESSION_DRIVER: redis
BROADCAST_DRIVER: log
## 服务
services:
mysql:
image: mysql:latest
env:
MYSQL_ALLOW_EMPTY_PASSWORD: false
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: prod_heycommunity
ports:
- 33306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
redis:
image: redis
ports:
- 33977:6379
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
## 执行步骤
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, dom, fileinfo
coverage: xdebug
ini-values: post_max_size=256M, max_execution_time=180
tools: php-cs-fixer, phpunit:${{ matrix.phpunit-versions }}
- name: Checkout
uses: actions/checkout@v3
### 安装 Composer libraries
- name: 安装依赖 (Composer Install)
run: composer install --no-ansi --no-interaction --no-progress --prefer-dist
### 更新 Composer libraries
- name: 更新依赖 (Composer Update)
run: composer update --no-ansi --no-interaction --no-progress --prefer-dist
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: Generate laravel key
run: php artisan key:generate
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: 数据库迁移和生成种子数据
run: php artisan migrate:refresh --seed --no-interaction
- name: 执行 Laravel 测试
run: php artisan test
### 模拟生产环境测试
- name: 开始模拟生产环境测试
run: echo '开始模拟生产环境测试' && date
- name: 更新依赖 (Composer Update --no-dev)
run: composer update --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --no-dev
- name: 安装 PHPUnit
run: composer require phpunit/phpunit --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --dev
- name: 数据库迁移
run: php artisan migrate:refresh --no-interaction
- name: 执行 Laravel 测试
run: php artisan test