From 9958be5f9256f5955b6a5f85989ed640f6c3ea4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=93=AD=E6=98=95?= <715557344@qq.com> Date: Thu, 5 Aug 2021 09:55:34 +0800 Subject: [PATCH 1/2] Added v2.1 support for Hyperf --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 852ed61..c032720 100644 --- a/composer.json +++ b/composer.json @@ -31,13 +31,13 @@ "require": { "php": ">=7.3", "ext-swoole": ">=4.5", - "hyperf/config": "~2.2.0", - "hyperf/di": "~2.2.0", - "hyperf/framework": "~2.2.0" + "hyperf/config": "^2.1", + "hyperf/di": "^2.1", + "hyperf/framework": "^2.1" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.0", - "hyperf/testing": "~2.2.0", + "hyperf/testing": "^2.1", "phpstan/phpstan": "^0.12", "swoole/ide-helper": "dev-master" }, From 466eed2e050e028a77df08041a877c0790ea7c19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=93=AD=E6=98=95?= <715557344@qq.com> Date: Thu, 5 Aug 2021 10:03:15 +0800 Subject: [PATCH 2/2] Added github workflows to run test cases --- .github/workflows/test.yml | 64 ++++++++++++++++++++++++++++++++++++++ .travis/swoole.install.sh | 15 ++++++--- composer.json | 3 +- 3 files changed, 75 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..4cd7f93 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,64 @@ +name: PHPUnit + +on: [push, pull_request] + +env: + SWOOLE_VERSION: '4.7.0' + SWOW_VERSION: 'develop' + +jobs: + ci: + name: Test PHP ${{ matrix.php-version }} on ${{ matrix.engine }} + runs-on: "${{ matrix.os }}" + strategy: + matrix: + os: [ubuntu-latest] + php-version: ['7.3', '7.4', '8.0'] + engine: ['none', 'swoole', 'swow'] + max-parallel: 5 + 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=1 + coverage: none + - name: Setup Swoole + if: ${{ matrix.engine == 'swoole' }} + run: | + sudo apt-get install libcurl4-openssl-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-http2 --enable-swoole-curl --enable-swoole-json + 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: | + 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-debug + 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: Run Test Cases + run: | + composer analyse + composer test diff --git a/.travis/swoole.install.sh b/.travis/swoole.install.sh index 0067690..bdf3cd2 100644 --- a/.travis/swoole.install.sh +++ b/.travis/swoole.install.sh @@ -1,10 +1,15 @@ #!/usr/bin/env bash -wget https://github.com/swoole/swoole-src/archive/v"${SW_VERSION}".tar.gz -O swoole.tar.gz +sudo apt-get update +sudo apt-get install libcurl4-openssl-dev +wget https://github.com/swoole/swoole-src/archive/${SW_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 || exit +cd swoole phpize -./configure --enable-openssl --enable-mysqlnd --enable-http2 -make -j "$(nproc)" -make install +./configure --enable-openssl --enable-http2 --enable-swoole-curl --enable-swoole-json +make -j$(nproc) +sudo make install +sudo sh -c "echo extension=swoole > /etc/php/${PHP_VERSION}/cli/conf.d/swoole.ini" +sudo sh -c "echo swoole.use_shortname='Off' >> /etc/php/${PHP_VERSION}/cli/conf.d/swoole.ini" +php --ri swoole diff --git a/composer.json b/composer.json index c032720..e19b108 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,6 @@ }, "require": { "php": ">=7.3", - "ext-swoole": ">=4.5", "hyperf/config": "^2.1", "hyperf/di": "^2.1", "hyperf/framework": "^2.1" @@ -45,7 +44,7 @@ "sort-packages": true }, "scripts": { - "test": "co-phpunit --prepend tests/bootstrap.php -c phpunit.xml --colors=always", + "test": "phpunit --prepend tests/bootstrap.php -c phpunit.xml --colors=always", "analyse": "phpstan analyse --memory-limit 1024M -l 0 ./src", "cs-fix": "php-cs-fixer fix $1" },