hyperf/.github/workflows/test.yml

92 lines
3.9 KiB
YAML
Raw Normal View History

2020-10-27 23:36:09 +08:00
name: PHPUnit for Hyperf
2021-04-19 22:03:42 +08:00
on:
push:
pull_request:
schedule:
2021-08-09 09:37:46 +08:00
- cron: '0 2 * * *'
2020-10-27 23:36:09 +08:00
jobs:
ci:
2021-06-01 11:01:56 +08:00
name: Test on PHP${{ matrix.php-version }} Swoole-${{ matrix.sw-version }}
2020-10-27 23:36:09 +08:00
runs-on: "${{ matrix.os }}"
strategy:
matrix:
2021-01-10 16:46:37 +08:00
os: [ ubuntu-latest ]
2021-12-30 19:17:47 +08:00
php-version: [ '8.0', '8.1' ]
2022-09-27 14:23:23 +08:00
sw-version: [ 'v4.5.11', 'v4.6.7', 'v4.7.1', 'v4.8.12', 'v5.0.0', 'master' ]
exclude:
- php-version: '8.1'
sw-version: 'v4.5.11'
- php-version: '8.1'
sw-version: 'v4.6.7'
- php-version: '8.1'
sw-version: 'v4.7.1'
2021-04-19 22:03:42 +08:00
max-parallel: 12
fail-fast: false
env:
SW_VERSION: ${{ matrix.sw-version }}
2021-06-01 11:01:56 +08:00
MYSQL_VERSION: '5.7'
PGSQL_VERSION: '14'
2020-10-27 23:36:09 +08:00
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: phpize
extensions: redis, pdo, pdo_mysql, bcmath
2021-12-10 17:14:34 +08:00
ini-values: opcache.enable_cli=0
2020-10-27 23:36:09 +08:00
coverage: none
- name: Setup Swoole
run: |
2021-04-02 12:55:30 +08:00
sudo apt-get update
sudo apt-get install libcurl4-openssl-dev libc-ares-dev libpq-dev
2021-04-19 22:03:42 +08:00
wget https://github.com/swoole/swoole-src/archive/${SW_VERSION}.tar.gz -O swoole.tar.gz
2021-04-02 12:55:30 +08:00
mkdir -p swoole
tar -xf swoole.tar.gz -C swoole --strip-components=1
rm swoole.tar.gz
cd swoole
phpize
if [ _${{ matrix.sw-version }} = '_v5.0.0' ] || [ _${{ matrix.sw-version }} = '_master' ]
then
./configure --enable-openssl --enable-swoole-curl --enable-cares --enable-swoole-pgsql
else
./configure --enable-openssl --enable-http2 --enable-swoole-curl --enable-swoole-json
fi
2021-04-02 12:55:30 +08:00
make -j$(nproc)
sudo make install
sudo sh -c "echo extension=swoole > /etc/php/${{ matrix.php-version }}/cli/conf.d/swoole.ini"
2021-04-02 12:55:30 +08:00
sudo sh -c "echo swoole.use_shortname='Off' >> /etc/php/${{ matrix.php-version }}/cli/conf.d/swoole.ini"
php --ri swoole
2020-10-27 23:36:09 +08:00
- name: Setup Packages
run: ./.travis/requirement.install.sh
2020-10-27 23:36:09 +08:00
- name: Setup Services
run: |
2021-06-01 11:01:56 +08:00
docker run --name mysql -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=true -d mysql:${MYSQL_VERSION} --bind-address=0.0.0.0 --default-authentication-plugin=mysql_native_password
docker run --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=postgres -d postgres:${PGSQL_VERSION}
2020-10-27 23:36:09 +08:00
docker run --name redis -p 6379:6379 -d redis
docker run -d --name dev-consul -e CONSUL_BIND_INTERFACE=eth0 -p 8500:8500 consul
docker run --name nsq -p 4150:4150 -p 4151:4151 -p 4160:4160 -p 4161:4161 -p 4170:4170 -p 4171:4171 --entrypoint /bin/nsqd -d nsqio/nsq:latest
docker run -d --restart=always --name rabbitmq -p 4369:4369 -p 5672:5672 -p 15672:15672 -p 25672:25672 rabbitmq:management-alpine
2020-10-27 23:36:09 +08:00
docker build --tag grpc-server:latest src/grpc-client/tests/Mock
docker run -d --name grpc-server -p 50051:50051 grpc-server:latest
docker build src/grpc-client/tests/Golang -t go-grpc-server:latest
docker run -d --name go-grpc-server -p 50052:50052 go-grpc-server:latest
docker build -t tcp-server:latest .travis/tcp_server
docker run -d --name tcp-server -p 10001:10001 tcp-server:latest
2020-10-27 23:36:09 +08:00
- name: Setup Mysql
run: export TRAVIS_BUILD_DIR=$(pwd) && bash ./.travis/setup.mysql.sh
- name: Setup PostgreSQL
run: export TRAVIS_BUILD_DIR=$(pwd) && bash ./.travis/setup.pgsql.sh
2020-10-27 23:36:09 +08:00
- name: Run Scripts Before Test
run: cp .travis/.env.example .env
- name: Run Test Cases
run: |
composer analyse src
composer test -- --exclude-group NonCoroutine
vendor/bin/phpunit --group NonCoroutine
vendor/bin/phpunit src/filesystem --group NonCoroutine
vendor/bin/php-cs-fixer fix src --dry-run