Skip to content

Commit 78d8483

Browse files
authored
Optimize CI scripts (#4798)
* optimzie ci scripts * fix * fix 2 * fix 3 * fix 4 * fix 5 * fix 6 * fix 7 * fix 8 * fix 9 * update tests doc, fix 10 * fix 11
1 parent e085097 commit 78d8483

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+152
-114
lines changed

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/.github/ export-ignore
22
/benchmark/ export-ignore
33
/core-tests/ export-ignore
4-
/.travis.yml export-ignore
54
*.h linguist-language=cpp

.github/workflows/framework.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
docker run -d --name grpc-server -p 50051:50051 grpc-server:latest
6363
docker build -t tcp-server:latest .travis/tcp_server
6464
docker run -d --name tcp-server -p 10001:10001 tcp-server:latest
65-
export TRAVIS_BUILD_DIR=$(pwd) && bash ./.travis/setup.mysql.sh
65+
export SWOOLE_BUILD_DIR=$(pwd) && bash ./.travis/setup.mysql.sh
6666
cp .travis/.env.example .env
6767
composer analyse src
6868
composer test -- --exclude-group NonCoroutine

.github/workflows/test-linux.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ jobs:
2929
echo "`git log -10 --stat --pretty --oneline`"
3030
- name: Run pecl-install.sh
3131
run: |
32-
sudo ${{runner.workspace}}/swoole-src/travis/pecl-install.sh
32+
sudo ${{runner.workspace}}/swoole-src/scripts/pecl-install.sh
3333
- name: Run Swoole test
3434
run: |
35-
export TRAVIS_BRANCH=${GITHUB_REF##*/}
36-
${{runner.workspace}}/swoole-src/travis/route.sh
35+
export SWOOLE_BRANCH=${GITHUB_REF##*/}
36+
${{runner.workspace}}/swoole-src/scripts/route.sh

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,4 @@ core-tests/samples/CMakeFiles/
110110
/tests/include/lib/composer.lock
111111
/core-tests/fuzz/fuzz_results/
112112
/core-tests/fuzz/bin/
113+
/scripts/data

docs/TESTS.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
## Swoole Tests
2+
3+
## Core Tests
4+
Used to test the core code in the `src/` directory, only as a C++ library, not related to php.
5+
The core tests depends on the googletest framework, and googletest needs to be installed.
6+
The core test cases must be written with `C++`.
7+
8+
### Build libswoole.so
9+
10+
```shell
11+
cd swoole-src
12+
cmake .
13+
make -j$(nproc)
14+
```
15+
16+
### Export source directory
17+
```shell
18+
SWOOLE_DIR=/your/path/to/swoole-src
19+
```
20+
21+
### Build core-tests
22+
```shell
23+
cd core-tests
24+
cmake .
25+
make -j$(nproc)
26+
```
27+
28+
### Run core-tests
29+
```shell
30+
# run all tests
31+
./bin/core-tests
32+
# run some test cases
33+
./bin/core-tests --gtest_filter=server.*
34+
# list all tests
35+
./bin/core_tests --gtest_list_tests
36+
```
37+
38+
## PHP Tests
39+
Used to test the php extension code in the `ext-src/` directory. The swoole php test depends on php environment.
40+
The `php-dev` related components must be installed.
41+
42+
The php test cases must be written with `PHP`.
43+
44+
### Build ext-swoole
45+
```shell
46+
cd swoole-src
47+
phpize
48+
./configure ${options}
49+
make -j$(nproc)
50+
make install
51+
```
52+
Need to configure `php.ini`, add `extension=swoole.so` to enable `ext-swoole`.
53+
54+
### Run tests
55+
```shell
56+
./scripts/route.sh
57+
```
58+
59+
The automated test scripts in this directory can not only run on Github Action CI. Powered by docker container technology, it can run on any systems. You only need to run the `route.sh` script to create containers of multiple PHP environments then it will run Swoole's build tests and unit tests on multiple systems automatically.
60+
61+
### With special branch
62+
63+
```shell
64+
SWOOLE_BRANCH=alpine ./scripts/route.sh
65+
```
66+
67+
### Enter the container
68+
69+
> You can cancel the unit test by `CTRL+C`
70+
71+
```shell
72+
docker exec -it -e LINES=$(tput lines) -e COLUMNS=$(tput cols) swoole /bin/bash
73+
```

ext-src/php_swoole_library.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* -----------------------------------------------------------------------
3-
* Generated by tools/build-library.php, Please DO NOT modify!
3+
* Generated by build-library.php, Please DO NOT modify!
44
+----------------------------------------------------------------------+
55
| Swoole |
66
+----------------------------------------------------------------------+
@@ -11,7 +11,7 @@
1111
| If you did not receive a copy of the Apache2.0 license and are unable|
1212
| to obtain it through the world-wide-web, please send a note to |
1313
| [email protected] so we can mail you a copy immediately. |
14-
+----------------------------------------------------------------------+
14+
+----------------------------------------------------------------------+
1515
*/
1616

1717
/* $Id: cc2a5d35674acd1609d060529ea4298b4fcde292 */

package.xml

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
<email>[email protected]</email>
5252
<active>yes</active>
5353
</developer>
54-
<date>2022-08-03</date>
55-
<time>15:00:00</time>
54+
<date>2022-08-05</date>
55+
<time>18:00:00</time>
5656
<version>
5757
<release>5.0.0</release>
5858
<api>5.0</api>
@@ -93,18 +93,11 @@
9393
</notes>
9494
<contents>
9595
<dir name="/">
96-
<file role="doc" name="CHANGELOG.md" />
9796
<file role="src" name="CMakeLists.txt" />
98-
<file role="doc" name="CODE-STYLE.md" />
9997
<file role="src" name="CPPLINT.cfg" />
10098
<file role="doc" name="LICENSE" />
10199
<file role="src" name="Makefile.frag" />
102-
<file role="doc" name="README-CN.md" />
103100
<file role="doc" name="README.md" />
104-
<file role="doc" name="SUPPORTED.md" />
105-
<file role="src" name="clear.sh" />
106-
<file role="src" name="code_format.sh" />
107-
<file role="src" name="code_stats.sh" />
108101
<file role="src" name="codecov.yml" />
109102
<file role="src" name="config.m4" />
110103
<file role="src" name="core-tests/CMakeLists.txt" />
@@ -176,6 +169,10 @@
176169
<file role="src" name="core-tests/src/server/http.cpp" />
177170
<file role="src" name="core-tests/src/server/message_bus.cpp" />
178171
<file role="src" name="core-tests/src/server/server.cpp" />
172+
<file role="doc" name="docs/CHANGELOG.md" />
173+
<file role="doc" name="docs/CODE-STYLE.md" />
174+
<file role="doc" name="docs/SUPPORTED.md" />
175+
<file role="src" name="docs/google-style.xml" />
179176
<file role="doc" name="examples/atomic/long.php" />
180177
<file role="doc" name="examples/atomic/test.php" />
181178
<file role="doc" name="examples/atomic/wait.php" />
@@ -548,7 +545,6 @@
548545
<file role="src" name="ext-src/swoole_timer.cc" />
549546
<file role="src" name="ext-src/swoole_websocket_server.cc" />
550547
<file role="doc" name="gdbinit" />
551-
<file role="src" name="google-style.xml" />
552548
<file role="src" name="include/helper/kqueue.h" />
553549
<file role="src" name="include/swoole.h" />
554550
<file role="src" name="include/swoole_api.h" />
@@ -601,9 +597,11 @@
601597
<file role="src" name="include/swoole_version.h" />
602598
<file role="src" name="include/swoole_websocket.h" />
603599
<file role="src" name="include/swoole_wheel_timer.h" />
604-
<file role="src" name="make.sh" />
605-
<file role="src" name="mascot.png" />
606600
<file role="src" name="php_swoole.h" />
601+
<file role="src" name="scripts/clear.sh" />
602+
<file role="src" name="scripts/code-format.sh" />
603+
<file role="src" name="scripts/code-stats.sh" />
604+
<file role="src" name="scripts/make.sh" />
607605
<file role="src" name="src/core/base.cc" />
608606
<file role="src" name="src/core/channel.cc" />
609607
<file role="src" name="src/core/crc32.cc" />
@@ -1225,19 +1223,20 @@
12251223
<file role="test" name="tests/swoole_event/defer.phpt" />
12261224
<file role="test" name="tests/swoole_event/defer_with_sleep.phpt" />
12271225
<file role="test" name="tests/swoole_event/defer_without_io.phpt" />
1226+
<file role="test" name="tests/swoole_event/del.phpt" />
12281227
<file role="test" name="tests/swoole_event/del_after_close.phpt" />
12291228
<file role="test" name="tests/swoole_event/deprecated_event_wait.phpt" />
12301229
<file role="test" name="tests/swoole_event/dispatch.phpt" />
12311230
<file role="test" name="tests/swoole_event/function_alias.phpt" />
1231+
<file role="test" name="tests/swoole_event/isset.phpt" />
12321232
<file role="test" name="tests/swoole_event/rshutdown.phpt" />
1233-
<file role="test" name="tests/swoole_event/swoole_event.phpt" />
1234-
<file role="test" name="tests/swoole_event/swoole_event_del.phpt" />
1235-
<file role="test" name="tests/swoole_event/swoole_event_isset.phpt" />
1236-
<file role="test" name="tests/swoole_event/swoole_event_set.phpt" />
1237-
<file role="test" name="tests/swoole_event/swoole_event_wait.phpt" />
1238-
<file role="test" name="tests/swoole_event/swoole_event_write.phpt" />
1233+
<file role="test" name="tests/swoole_event/set.phpt" />
1234+
<file role="test" name="tests/swoole_event/simple.phpt" />
1235+
<file role="test" name="tests/swoole_event/sockets.phpt" />
12391236
<file role="test" name="tests/swoole_event/sync_client_1.phpt" />
12401237
<file role="test" name="tests/swoole_event/sync_client_2.phpt" />
1238+
<file role="test" name="tests/swoole_event/wait.phpt" />
1239+
<file role="test" name="tests/swoole_event/write.phpt" />
12411240
<file role="test" name="tests/swoole_feature/cross_close/client.phpt" />
12421241
<file role="test" name="tests/swoole_feature/cross_close/client_by_server.phpt" />
12431242
<file role="test" name="tests/swoole_feature/cross_close/full_duplex.phpt" />
@@ -2331,18 +2330,6 @@
23312330
<file role="src" name="tools/show-big-files.php" />
23322331
<file role="src" name="tools/templates/class.c" />
23332332
<file role="src" name="tools/templates/version.tpl.h" />
2334-
<file role="src" name="travis/.gitignore" />
2335-
<file role="doc" name="travis/README.md" />
2336-
<file role="src" name="travis/debug/swoole_info.php" />
2337-
<file role="src" name="travis/debug/swoole_table_implements.php" />
2338-
<file role="src" name="travis/docker-compile.sh" />
2339-
<file role="src" name="travis/docker-compose.yml" />
2340-
<file role="src" name="travis/docker-route.sh" />
2341-
<file role="src" name="travis/pecl-install.sh" />
2342-
<file role="src" name="travis/route.sh" />
2343-
<file role="src" name="travis/run-tests.sh" />
2344-
<file role="src" name="travis/simple-compile-on-github.sh" />
2345-
<file role="src" name="travis/simple-compile.sh" />
23462333
</dir>
23472334
</contents>
23482335
<dependencies>
File renamed without changes.
File renamed without changes.

travis/docker-compile.sh renamed to scripts/docker-compile.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ __CURRENT__=$(pwd)
33
__DIR__=$(cd "$(dirname "$0")";pwd)
44

55
if [ ! -f "/.dockerenv" ]; then
6-
echo "" && echo "❌ This script is just for Docker env!"
6+
echo "" && echo "❌ This script is just for Docker!"
77
exit
88
fi
99

1010
cd "${__DIR__}" && cd ..
11-
./clear.sh
11+
./scripts/clear.sh
1212
phpize
1313
./configure \
1414
--enable-openssl \

travis/docker-compose.yml renamed to scripts/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ services:
44
container_name: "swoole"
55
image: "phpswoole/php:${PHP_VERSION}"
66
volumes:
7-
- "${TRAVIS_BUILD_DIR}:/swoole-src:rw"
7+
- "${SWOOLE_BUILD_DIR}:/swoole-src:rw"
88
working_dir: /swoole-src
99
ulimits:
1010
core: -1
@@ -17,7 +17,7 @@ services:
1717
- 8.8.8.8
1818
- 1.1.1.1
1919
environment:
20-
SWOOLE_BRANCH: "${TRAVIS_BRANCH}"
20+
SWOOLE_BRANCH: "${SWOOLE_BRANCH}"
2121
command: tail -f /etc/group
2222
mysql:
2323
container_name: "mysql"
File renamed without changes.

travis/pecl-install.sh renamed to scripts/pecl-install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ __DIR__=$(cd "$(dirname "$0")";pwd)
44

55
cd ${__DIR__} && cd ../ && \
66
pecl config-show && \
7-
php ./tools/pecl-package.php && package_file="`ls | grep swoole-*tgz`" && \
7+
php tools/pecl-package.php && package_file="`ls | grep swoole-*tgz`" && \
88
echo "\n" | pecl install -f ${package_file} | tee pecl.log && \
99
cat pecl.log | grep "successfully" && \
1010
pecl uninstall swoole && \

travis/route.sh renamed to scripts/route.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ __CURRENT__=`pwd`
33
__DIR__=$(cd "$(dirname "$0")";pwd)
44

55
export DOCKER_COMPOSE_VERSION="1.21.0"
6-
[ -z "${TRAVIS_BRANCH}" ] && export TRAVIS_BRANCH="master"
7-
[ -z "${TRAVIS_BUILD_DIR}" ] && export TRAVIS_BUILD_DIR=$(cd "$(dirname "$0")";cd ../;pwd)
6+
[ -z "${SWOOLE_BRANCH}" ] && export SWOOLE_BRANCH="master"
7+
[ -z "${SWOOLE_BUILD_DIR}" ] && export SWOOLE_BUILD_DIR=$(cd "$(dirname "$0")";cd ../;pwd)
88
[ -z "${PHP_VERSION_ID}" ] && export PHP_VERSION_ID=`php -r "echo PHP_VERSION_ID;"`
9-
if [ ${PHP_VERSION_ID} -lt 80200 ]; then
9+
if [ ${PHP_VERSION_ID} -lt 80300 ]; then
1010
export PHP_VERSION="`php -r "echo PHP_MAJOR_VERSION;"`.`php -r "echo PHP_MINOR_VERSION;"`"
1111
else
1212
export PHP_VERSION="rc"
1313
fi
14-
if [ "${TRAVIS_BRANCH}" = "alpine" ]; then
14+
if [ "${SWOOLE_BRANCH}" = "alpine" ]; then
1515
export PHP_VERSION="${PHP_VERSION}-alpine"
1616
fi
1717

18-
echo "\n🗻 With PHP version ${PHP_VERSION} on ${TRAVIS_BRANCH} branch"
18+
echo "\n🗻 With PHP version ${PHP_VERSION} on ${SWOOLE_BRANCH} branch"
1919

2020
check_docker_dependency(){
2121
if [ "`docker -v 2>&1 | grep "version"`"x = ""x ]; then
@@ -60,7 +60,7 @@ prepare_data_files(){
6060

6161
remove_data_files(){
6262
cd ${__DIR__} && \
63-
rm -rf ../travis/data
63+
rm -rf scripts/data
6464
}
6565

6666
start_docker_containers(){
@@ -81,8 +81,8 @@ remove_docker_containers(){
8181
}
8282

8383
run_tests_in_docker(){
84-
docker exec swoole touch /.travisenv && \
85-
docker exec swoole /swoole-src/travis/docker-route.sh
84+
docker exec swoole touch /.cienv && \
85+
docker exec swoole /swoole-src/scripts/docker-route.sh
8686
if [ $? -ne 0 ]; then
8787
echo "\n❌ Run tests failed!"
8888
exit 1
File renamed without changes.

travis/simple-compile.sh renamed to scripts/simple-compile.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
__CURRENT__=`pwd`
33
__DIR__=$(cd "$(dirname "$0")";pwd)
44

5-
if [ "${TRAVIS}"x = ""x ]; then
6-
echo "\n❌ This script is just for Travis!"
7-
exit 255
8-
fi
9-
105
cd ${__DIR__} && cd ../ && \
116
./clear.sh > /dev/null && \
127
phpize --clean > /dev/null && \

tests/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ try to run `./init` to initialize the databases.
88
| | mysql | redis |
99
| ------------- | ------------------------------------- | ----------------------------------- |
1010
| path (env) | $MYSQL_SERVER_PATH | $REDIS_SERVER_PATH |
11-
| path (travis) | ${travis}/data/run/mysqld/mysqld.sock | ${travis}/data/run/redis/redis.sock |
11+
| path (actions) | ${actions}/data/run/mysqld/mysqld.sock | ${actions}/data/run/redis/redis.sock |
1212
| host (raw) | 127.0.0.1 | 127.0.0.1 |
1313
| host (docker) | mysql | redis |
1414
| port | 3306 | 6379 |

0 commit comments

Comments
 (0)