增加单测 #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PHPUnit | |
on: [ push, pull_request ] | |
env: | |
SWOOLE_VERSION: '5.1.1' | |
SWOW_VERSION: 'v1.2.0' | |
jobs: | |
ci: | |
name: Test PHP ${{ matrix.php-version }} on ${{ matrix.engine }} | |
runs-on: "${{ matrix.os }}" | |
strategy: | |
matrix: | |
os: [ ubuntu-latest ] | |
php-version: [ '8.1', '8.2', '8.3' ] | |
engine: [ 'none', 'swoole', 'swow' ] | |
max-parallel: 9 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-version }} | |
tools: phpize | |
ini-values: opcache.enable_cli=0 | |
coverage: none | |
- name: Setup Swoole | |
if: ${{ matrix.engine == 'swoole' }} | |
run: | | |
cd /tmp | |
sudo apt-get update | |
sudo apt-get install libcurl4-openssl-dev libc-ares-dev libpq-dev | |
wget https://github.com/swoole/swoole-src/archive/v${SWOOLE_VERSION}.tar.gz -O swoole.tar.gz | |
mkdir -p swoole | |
tar -xf swoole.tar.gz -C swoole --strip-components=1 | |
rm swoole.tar.gz | |
cd swoole | |
phpize | |
./configure --enable-openssl --enable-swoole-curl --enable-cares --enable-swoole-pgsql | |
make -j$(nproc) | |
sudo make install | |
sudo sh -c "echo extension=swoole > /etc/php/${{ matrix.php-version }}/cli/conf.d/swoole.ini" | |
php --ri swoole | |
- name: Setup Swow | |
if: ${{ matrix.engine == 'swow' }} | |
run: | | |
cd /tmp | |
wget https://github.com/swow/swow/archive/"${SWOW_VERSION}".tar.gz -O swow.tar.gz | |
mkdir -p swow | |
tar -xf swow.tar.gz -C swow --strip-components=1 | |
rm swow.tar.gz | |
cd swow/ext || exit | |
phpize | |
./configure --enable-swow --enable-swow-ssl --enable-swow-curl | |
make -j "$(nproc)" | |
sudo make install | |
sudo sh -c "echo extension=swow > /etc/php/${{ matrix.php-version }}/cli/conf.d/swow.ini" | |
php --ri swow | |
- name: Setup Packages | |
run: composer update -o --no-scripts | |
- name: Setup MySQL Server | |
run: | | |
docker run --name mysql -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=true -d mysql:8.0 --bind-address=0.0.0.0 --default-authentication-plugin=mysql_native_password | |
mysql -h 127.0.0.1 -u root -e "CREATE DATABASE IF NOT EXISTS test charset=utf8mb4 collate=utf8mb4_unicode_ci;" | |
- name: Run Test Cases | |
run: | | |
vendor/bin/php-cs-fixer fix --dry-run | |
composer analyse | |
composer test |