Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

提升测试覆盖率,多项修复和改进 #518

Merged
merged 67 commits into from
May 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
5ef2c63
统一静态类声明方式
Yurunsoft May 12, 2023
d7639d8
优化代码,完善测试用例
Yurunsoft May 12, 2023
13434ec
优化代码,完善测试用例
Yurunsoft May 12, 2023
1414c1f
修复并标记废弃 Imi\Util\DateTime::getLastWeek(),增加 Imi\Util\DateTime::getPre…
Yurunsoft May 15, 2023
df2adb1
修复 DelayServerBeanCallable、DelayBeanCallable 引用返回值,优化代码
Yurunsoft May 15, 2023
556ddfb
增加测试
Yurunsoft May 15, 2023
3295495
修复 Imi\Util\File::enumFile()、Imi\Util\File::enumFileSync() 错误的返回值注释
Yurunsoft May 15, 2023
b7533d3
修复 FilterableList
Yurunsoft May 15, 2023
9e8c2f5
修复 Request::getRequestTarget() 错误的值、ServerRequest::post() 不支持非数组、Memo…
Yurunsoft May 16, 2023
9c9deef
尝试测试组件覆盖率
Yurunsoft May 16, 2023
684298f
修复测试
Yurunsoft May 17, 2023
282940f
修复测试
Yurunsoft May 17, 2023
c8680ea
修复测试
Yurunsoft May 17, 2023
a18ffb4
test
Yurunsoft May 17, 2023
d5d7afd
修复 Swoole 测试覆盖率
Yurunsoft May 17, 2023
9cb6f18
修复 Imi\Util\Text::endwith()
Yurunsoft May 17, 2023
9358950
修复测试
Yurunsoft May 17, 2023
36adc17
test
Yurunsoft May 17, 2023
b956236
test
Yurunsoft May 17, 2023
563d443
test
Yurunsoft May 18, 2023
51a4466
test
Yurunsoft May 18, 2023
1b548b5
test
Yurunsoft May 18, 2023
959949f
修复 PHP 8.2 兼容性(Creation of dynamic property)
Yurunsoft May 18, 2023
cdb4cf3
test
Yurunsoft May 18, 2023
c812f0c
test
Yurunsoft May 18, 2023
2cbcf7b
增加 Http 验证器测试
Yurunsoft May 18, 2023
d272900
修复事务嵌套,部分回滚事务
Yurunsoft May 18, 2023
fd6deaf
优化代码,补充测试,删除无用的类
Yurunsoft May 18, 2023
ef95815
关闭测试热更新
Yurunsoft May 18, 2023
72847fe
增加热更新监视器类测试
Yurunsoft May 18, 2023
60c0c84
优化:非 Swoole、Workerman 环境使用 Timer 抛出异常
Yurunsoft May 18, 2023
c250ef1
删除无用类
Yurunsoft May 18, 2023
255ccfb
修复测试
Yurunsoft May 18, 2023
63900c9
将同步Gitee和组件发版任务设置为并发等待
Yurunsoft May 19, 2023
7b03471
并行测试覆盖率
Yurunsoft May 19, 2023
73e0dfc
test
Yurunsoft May 19, 2023
2556f82
test
Yurunsoft May 19, 2023
5c6e125
test
Yurunsoft May 19, 2023
57d6191
test
Yurunsoft May 19, 2023
3b2a2f6
test
Yurunsoft May 19, 2023
3662146
test
Yurunsoft May 19, 2023
b82d0d4
test
Yurunsoft May 19, 2023
59ed4a4
test
Yurunsoft May 19, 2023
d19ad92
test
Yurunsoft May 19, 2023
f731a66
优化模型 DDL 注解的 decode 参数,允许设为 null
Yurunsoft May 19, 2023
fa7aa1e
test
Yurunsoft May 19, 2023
ae7c59c
test
Yurunsoft May 19, 2023
a28bf3f
修正变量名,增加测试
Yurunsoft May 19, 2023
fdb9ccb
计划废弃 Imi\Model\ModelManager 类
Yurunsoft May 19, 2023
2bf0f21
test
Yurunsoft May 19, 2023
d83ccf7
test
Yurunsoft May 19, 2023
e8205a5
test
Yurunsoft May 19, 2023
64f7f71
删除无用文件,增加测试
Yurunsoft May 19, 2023
0d01f6c
修复测试
Yurunsoft May 19, 2023
0569f3b
覆盖率测试日志保存到artifact
Yurunsoft May 19, 2023
ff0f2a1
保存最终的覆盖率 xml 文件到 artifact
Yurunsoft May 19, 2023
b6290fd
修复测试
Yurunsoft May 19, 2023
a0c15da
update 补充DB别名测试
NHZEX May 16, 2023
5054015
update README.md [no ci]
NHZEX May 16, 2023
a5cc50a
使用缓存
Yurunsoft May 19, 2023
a4cd498
修复测试
Yurunsoft May 19, 2023
2f581f2
修复测试
Yurunsoft May 19, 2023
a30ca4a
test
Yurunsoft May 19, 2023
2706d55
恢复被注释的测试
Yurunsoft May 20, 2023
95178ca
修复 roadrunner 并发测试过多时测试失败
Yurunsoft May 20, 2023
b318de9
修复测试
Yurunsoft May 20, 2023
22b8643
修复 roadrunner 并发测试过多时测试失败
Yurunsoft May 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/print-logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}

echo '[Swoole Component]', \PHP_EOL;
$fileName = \dirname(__DIR__) . '/tests/unit/Component/logs/log-' . date('Y-m-d') . '.log';
$fileName = \dirname(__DIR__) . 'src/Components/swoole/tests/unit/Component/logs/log-' . date('Y-m-d') . '.log';
if (is_file($fileName))
{
echo file_get_contents($fileName), \PHP_EOL;
Expand Down
17 changes: 11 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,14 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [7.4, "8.0", "8.1"]
swoole: [v5.0.3, v4.8.11]
php: ["7.4", "8.0", "8.1", "8.2"]
swoole: [v5.0.3, v4.8.13]
roadrunner: [2.7.*]
exclude:
- php: 7.4
swoole: v5.0.3
- php: 8.2
swoole: v4.8.13
env:
MYSQL_SERVER_PASSWORD: "root"
PHP_VERSION: ${{ matrix.php }}
Expand Down Expand Up @@ -405,9 +407,12 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [7.4, "8.0", 8.1]
php: ["7.4", "8.0", "8.1"] # 部分扩展还未在 pecl 发布 PHP 8.2 Windows 版扩展,所以无法测试
roadrunner: [2.7.*]

extensions:
[
"apcu, bcmath, curl, openssl, mbstring, intl, json, redis, mysqli, pdo, pdo_mysql, sockets",
]
env:
IMI_ROADRUNNER_BINARY: ${{ github.workspace }}\rr.exe
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -435,7 +440,7 @@ jobs:
php-version: ${{ matrix.php }}
ini-values: session.save_path=C:\temp
tools: pecl
extensions: apcu, bcmath, curl, openssl, mbstring, intl, json, redis, mysqli, pdo, pdo_mysql, sockets
extensions: ${{ matrix.extensions }}
env:
fail-fast: true

Expand Down Expand Up @@ -489,7 +494,7 @@ jobs:
# swoole:
# # - version: v5.0.3
# # postgresql_version: ""
# # - version: v4.8.11
# # - version: v4.8.13
# # postgresql_version: ""
# - version: fix-curl-hook-php8.2
# postgresql_version: ""
Expand Down
233 changes: 77 additions & 156 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ on:
pull_request:

jobs:
tests:
test:
runs-on: ubuntu-latest
strategy:
matrix:
testType: [core, swoole, components]
services:
zookeeper:
image: zookeeper:3.4
Expand Down Expand Up @@ -97,6 +100,7 @@ jobs:
--health-timeout=5s
--health-retries=3
env:
TEST_TYPE: ${{ matrix.testType }}
SWOOLE_VERSION: v5.0.3
ROADRUNNER_VERSION: 2.7.*
IMI_ROADRUNNER_BINARY: ${{ github.workspace }}/rr
Expand All @@ -110,6 +114,7 @@ jobs:
--enable-swoole-json
--enable-swoole-curl
--enable-swoole-pgsql
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -118,18 +123,27 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.2
tools: pecl
coverage: xdebug
extensions: >
apcu, bcmath, curl, openssl, mbstring, intl, json, redis, mysqli, pdo, pdo_mysql, pdo_pgsql,
sockets, zip, inotify, event, apcu,
sockets, zip, inotify, event
swoole-swoole/swoole-src@${{ env.SWOOLE_VERSION }}
- name: Check Version
run: |
php -v
php -m
php --ri swoole
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache vendor
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Prepare
run: |
printf "127.0.0.1\tkafka1\n" | sudo tee -a /etc/hosts
Expand All @@ -139,160 +153,67 @@ jobs:
PGPASSWORD=root psql -h 127.0.0.1 -d db_imi_test -U root -f ./.github/pgsql.sql
src/Components/roadrunner/vendor/bin/rr get-binary -f $ROADRUNNER_VERSION
./rr -v
echo "test_ready=1" >> $GITHUB_ENV
- name: Run core test suite
timeout-minutes: 5
run: php vendor/bin/phpunit -c ./tests/phpunit.xml --coverage-clover=./core-coverage.xml -v
- name: Run swoole test suite
if: ${{ env.test_ready && always() }}
timeout-minutes: 5
run: >
php src/Components/swoole/bin/swoole-phpunit
-c ./src/Components/swoole/tests/phpunit.xml
--coverage-clover=./swoole-coverage.xml -v
- name: Run workerman test suite
if: ${{ env.test_ready && always() }}
timeout-minutes: 3
run: >
php src/Components/workerman/vendor/bin/phpunit
-c ./src/Components/workerman/tests/phpunit.xml
--coverage-clover=./workerman-coverage.xml -v
- name: Run workerman-gateway test suite
if: ${{ env.test_ready && always() }}
timeout-minutes: 3
run: >
php src/Components/workerman-gateway/vendor/bin/phpunit
-c ./src/Components/workerman-gateway/tests/phpunit.xml
--testsuite workerman
--coverage-clover=./workerman-gateway-coverage.xml -v
- name: Run workerman-gateway(swoole) test suite
if: ${{ env.test_ready && always() }}
timeout-minutes: 3
run: >
php src/Components/workerman-gateway/vendor/bin/phpunit
-c ./src/Components/workerman-gateway/tests/phpunit.xml
--testsuite swoole
--coverage-clover=./workerman-gateway-swoole-coverage.xml -v
- name: Run roadrunner test suite
if: ${{ env.test_ready && always() }}
timeout-minutes: 3
run: >
php src/Components/roadrunner/vendor/bin/phpunit
-c ./src/Components/roadrunner/tests/phpunit.xml
--coverage-clover=./roadrunner-coverage.xml -v
- name: Run fpm test suite
if: ${{ env.test_ready && always() }}
timeout-minutes: 3
run: >
php src/Components/fpm/vendor/bin/phpunit
-c ./src/Components/fpm/tests/phpunit.xml
--coverage-clover=./fpm-coverage.xml -v
- name: Run jwt test suite
if: ${{ env.test_ready && always() }}
timeout-minutes: 3
run: >
php src/Components/jwt/vendor/bin/phpunit
-c ./src/Components/jwt/tests/phpunit.xml
--coverage-clover=./jwt-coverage.xml -v
- name: Run queue test suite
if: ${{ env.test_ready && always() }}
timeout-minutes: 3
run: >
php src/Components/swoole/bin/swoole-phpunit
-c ./src/Components/queue/tests/phpunit.xml
--coverage-clover=./queue-coverage.xml -v
- name: Run amqp-swoole test suite
if: ${{ env.test_ready && always() }}
timeout-minutes: 3
run: >
AMQP_TEST_MODE=swoole php src/Components/swoole/bin/swoole-phpunit
-c ./src/Components/amqp/tests/phpunit.xml
--coverage-clover=./amqp-swoole-coverage.xml -v
- name: Run amqp-workerman test suite
if: ${{ env.test_ready && always() }}
timeout-minutes: 3
run: >
AMQP_TEST_MODE=workerman php src/Components/swoole/bin/swoole-phpunit
-c ./src/Components/amqp/tests/phpunit.xml
--coverage-clover=./amqp-workerman-coverage.xml -v
- name: Run kafka-swoole test suite
if: ${{ env.test_ready && always() }}
timeout-minutes: 3
run: >
KAFKA_TEST_MODE=swoole php src/Components/swoole/bin/swoole-phpunit
-c ./src/Components/kafka/tests/phpunit.xml
--coverage-clover=./kafka-swoole-coverage.xml -v
- name: Run kafka-workerman test suite
if: ${{ env.test_ready && always() }}
timeout-minutes: 3
run: >
KAFKA_TEST_MODE=workerman php src/Components/swoole/bin/swoole-phpunit
-c ./src/Components/kafka/tests/phpunit.xml
--coverage-clover=./kafka-workerman-coverage.xml -v
- name: Run grpc test suite
if: ${{ env.test_ready && always() }}
timeout-minutes: 3
run: >
php src/Components/swoole/bin/swoole-phpunit
-c ./src/Components/grpc/tests/phpunit.xml
--coverage-clover=./grpc-coverage.xml -v
- name: Run snowflake test suite
if: ${{ env.test_ready && always() }}
timeout-minutes: 3
run: >
php src/Components/snowflake/vendor/bin/phpunit
-c ./src/Components/snowflake/tests/phpunit.xml
--coverage-clover=./snowflake-coverage.xml -v
- name: Run mqtt test suite
if: ${{ env.test_ready && always() }}
timeout-minutes: 3
run: >
php src/Components/swoole/bin/swoole-phpunit
-c ./src/Components/mqtt/tests/phpunit.xml
--coverage-clover=./mqtt-coverage.xml -v
- name: Run smarty test suite
if: ${{ env.test_ready && always() }}
timeout-minutes: 3
run: >
php src/Components/swoole/bin/swoole-phpunit
-c ./src/Components/smarty/tests/phpunit.xml
--coverage-clover=./smarty-coverage.xml -v
- name: Run pgsql test suite
if: ${{ env.test_ready && always() }}
timeout-minutes: 3
run: >
php src/Components/swoole/bin/swoole-phpunit
-c ./src/Components/pgsql/tests/phpunit.xml
--coverage-clover=./pgsql-coverage.xml -v
- name: Print logs
if: failure()
run: php .github/print-logs.php
- name: Run test suite
id: run-test-suite
run: ./dev/test-coverage-actions.sh php $TEST_TYPE
- name: Upload coverage file
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.testType }}-coverage
path: tests/coverage.php
- name: Upload log files
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.testType }}-logs
path: |
tests/unit/Component/logs/*.log
src/Components/*/tests/*/*/logs/*.log
src/Components/*/example/.runtime/logs/*.log
upload-coverage:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
tools: pecl
extensions: >
bcmath, curl, openssl, mbstring, intl, json, sockets, zip, event
- name: Check Version
run: |
php -v
php -m
- name: Prepare
run: |
composer update --prefer-dist --no-progress
mkdir -p ./dev/cover
- name: Download core coverage
uses: actions/download-artifact@v3
with:
name: core-coverage
path: ./dev/cover/core-coverage.php
- name: Download swoole coverage
uses: actions/download-artifact@v3
with:
name: swoole-coverage
path: ./dev/cover/swoole-coverage.php
- name: Download components coverage
uses: actions/download-artifact@v3
with:
name: components-coverage
path: ./dev/cover/components-coverage.php
- name: Parse coverage data
run: php ./dev/merge-coverage.php clover
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: "./core-coverage.xml,\
./swoole-coverage.xml,\
./workerman-coverage.xml,\
./workerman-gateway-coverage.xml,\
./workerman-gateway-swoole-coverage.xml,\
./roadrunner-coverage.xml,\
./fpm-coverage.xml,\
./jwt-coverage.xml,\
./queue-coverage.xml,\
./amqp-swoole-coverage.xml,\
./amqp-workerman-coverage.xml,\
./kafka-swoole-coverage.xml,\
./kafka-workerman-coverage.xml,\
./grpc-coverage.xml,\
./amqp-swoole-coverage.xml,\
./amqp-workerman-coverage.xml,\
./kafka-swoole-coverage.xml,\
./kafka-workerman-coverage.xml,\
./grpc-coverage.xml,\
./snowflake-coverage.xml,\
./mqtt-coverage.xml,\
./smarty-coverage.xml,\
./pgsql-coverage.xml"
flags: unittests
name: umbrella
file: "./tests/coverage.xml"
- name: Upload coverage reports to artifact
uses: actions/upload-artifact@v3
with:
name: coverage
path: tests/coverage.xml
1 change: 1 addition & 0 deletions .github/workflows/mirror.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
jobs:
gitee:
if: github.repository == 'imiphp/imi' && (github.ref == 'refs/heads/2.1')
concurrency: ci-${{ github.ref }}
runs-on: ubuntu-20.04
steps:
- name: Configure Private Key
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/split-repository.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ name: split repository
on:
push:
branches:
- '2.1'
- "2.1"
release:
types: [published]

jobs:
split-repository:
if: github.repository == 'imiphp/imi'
concurrency: ci-${{ github.ref }}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ composer.lock
*.macro.php
/.phpbench
/node_modules
/tests/clover.xml
/tests/html-coverage
/dev/cover
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[![imi Doc](https://img.shields.io/badge/docs-passing-green.svg)](https://doc.imiphp.com/v2.1/)
[![imi License](https://img.shields.io/badge/license-MulanPSL%202.0-brightgreen.svg)](https://github.com/imiphp/imi/blob/master/LICENSE)
[![star](https://gitee.com/yurunsoft/IMI/badge/star.svg?theme=gvp)](https://gitee.com/yurunsoft/IMI/stargazers)
[![codecov](https://codecov.io/github/imiphp/imi/branch/dev/graph/badge.svg?token=YrNRQgbRe2)](https://codecov.io/github/imiphp/imi)
[![codecov](https://codecov.io/github/imiphp/imi/branch/2.1/graph/badge.svg?token=YrNRQgbRe2)](https://codecov.io/github/imiphp/imi)

## 介绍

Expand Down
Loading