-
-
Notifications
You must be signed in to change notification settings - Fork 169
564 lines (545 loc) · 21.2 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
name: ci
on:
push:
paths-ignore:
- "doc/**"
- "mddoc/**"
- "res/**"
- "split-repository/**"
- "website/**"
- ".markdownlint.json"
- "README.md"
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true
jobs:
ci-linux:
name: Linux Swoole-${{ matrix.swoole.version }} RoadRunner-${{ matrix.roadrunner }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
swoole:
- version: php8.2-swoole-5.1
- version: php8.1-swoole-5.1
- version: php8.2-swoole-5.0
- version: php8.1-swoole-5.0
roadrunner: [2.7.*]
env:
ENV_SERVICE: swoole
REPOSITORY_OWNER: ${{ github.repository_owner }}
IMAGE_VERSION: ${{ matrix.swoole.version }}
MYSQL_DOCKER_VERSION: "8.0"
REDIS_SERVER_HOST: redis
ROADRUNNER_DOCKER_VERSION: ${{ matrix.roadrunner }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Prepare1
run: |
echo "REPOSITORY_OWNER=${REPOSITORY_OWNER,,}" >>${GITHUB_ENV}
mkdir -p /tmp/base_cache/composer
- name: Cache dependencies
uses: actions/cache@v3
with:
path: /tmp/base_cache/composer
key: ${{ runner.os }}-composer-${{ env.IMAGE_VERSION }}-${{ hashFiles('*/composer.json', 'src/Components/*/composer.json') }}
restore-keys: |
${{ runner.os }}-composer-${{ env.IMAGE_VERSION }}-
${{ runner.os }}-composer-
- name: Prepare2
uses: ./.github/actions/ci-prepare
with:
env: ${{ env.ENV_SERVICE }}
- name: Test Env
if: ${{ env.test_prepared && always() }}
run: |
docker ps
docker logs shared-tmp || true
docker logs redis || true
docker exec ${ENV_SERVICE} bash -c "ls -lha /run/shared"
echo ">>> redis-cluster-node-0"
docker exec ${ENV_SERVICE} bash -c "echo -e 'auth l83aa26\r\ninfo server' | nc redis-cluster-node-0-1 6379 -w 1"
docker exec ${ENV_SERVICE} bash -c "echo -e 'auth l83aa26\r\ncluster info\r\ncluster nodes' | nc redis-cluster-node-0-1 6379 -w 1"
echo ">>> redis"
docker exec ${ENV_SERVICE} bash -c "echo -e 'auth l83aa26\r\ninfo server' | nc redis 6379 -w 1"
- name: Test
if: ${{ env.test_prepared && always() }}
run: docker exec ${ENV_SERVICE} composer test
- name: Test connection-center
if: ${{ env.test_prepared && always() }}
run: docker exec ${ENV_SERVICE} composer test-connection-center
- name: Test database
if: ${{ env.test_prepared && always() }}
run: docker exec ${ENV_SERVICE} composer test-database
- name: Test redis
if: ${{ env.test_prepared && always() }}
run: |
docker exec ${ENV_SERVICE} composer test-redis
- name: Test swoole
if: ${{ env.test_prepared && always() }}
run: docker exec ${ENV_SERVICE} composer test-swoole
- name: Test workerman
if: ${{ env.test_prepared && always() }}
run: docker exec ${ENV_SERVICE} composer test-workerman
- name: Test workerman-gateway
if: ${{ env.test_prepared && always() }}
run: docker exec ${ENV_SERVICE} composer test-workerman-gateway
- name: Test roadrunner
if: ${{ env.test_prepared && always() }}
run: docker exec ${ENV_SERVICE} composer test-roadrunner
- name: Test fpm
if: ${{ env.test_prepared && always() }}
run: docker exec ${ENV_SERVICE} composer test-fpm
- name: Test jwt
if: ${{ env.test_prepared && always() }}
run: docker exec ${ENV_SERVICE} composer test-jwt
- name: Test queue
if: ${{ env.test_prepared && always() }}
run: docker exec ${ENV_SERVICE} composer test-queue
- name: Test amqp
if: ${{ env.test_prepared && always() }}
run: docker exec ${ENV_SERVICE} composer test-amqp
- name: Test kafka
if: ${{ env.test_prepared && always() }}
run: docker exec ${ENV_SERVICE} composer test-kafka
- name: Test grpc
if: ${{ env.test_prepared && always() }}
run: docker exec ${ENV_SERVICE} composer test-grpc
- name: Test snowflake
if: ${{ env.test_prepared && always() }}
run: docker exec ${ENV_SERVICE} composer test-snowflake
- name: Test mqtt
if: ${{ env.test_prepared && always() }}
run: docker exec ${ENV_SERVICE} composer test-mqtt
- name: Test smarty
if: ${{ env.test_prepared && always() }}
run: docker exec ${ENV_SERVICE} composer test-smarty
- name: Test pgsql
if: ${{ env.test_prepared && always() }}
run: docker exec ${ENV_SERVICE} composer test-pgsql
- name: Test phar
if: ${{ env.test_prepared && always() }}
run: docker exec ${ENV_SERVICE} composer test-phar
- name: Test model
if: ${{ env.test_prepared && always() }}
run: docker exec ${ENV_SERVICE} composer test-model
- name: Print logs
if: failure()
run: docker exec ${ENV_SERVICE} php .github/print-logs.php
ci-swoole-cli:
name: Swoole-cli-${{ matrix.swoole-cli }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
swoole-cli: [v5.0.3]
env:
MYSQL_DOCKER_VERSION: "8.0"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Services
shell: bash
run: |
sudo apt update && sudo apt install -y rsync netcat-openbsd tree
docker network create imi-ci-service-network --subnet 172.10.12.0/24
docker compose -f ./.github/service/redis-cluster/docker-compose.yml up -d
docker compose -f ./.github/docker-compose.yml up -d mysql postgres redis rabbitmq kafka1
echo "127.0.0.1 kafka1" | sudo tee -a /etc/hosts
- name: Setup swoole-cli
run: .github/script/install-swoole-cli.sh ${{ matrix.swoole-cli }}
- name: Check Version
run: |
swoole-cli -v
php -v
php -m
composer -V
php --ri swoole
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-swoole-cli-${{ matrix.swoole-cli }}-${{ hashFiles('*/composer.json', 'src/Components/*/composer.json') }}
restore-keys: |
${{ runner.os }}-composer-swoole-cli-${{ matrix.swoole-cli }}-
${{ runner.os }}-composer-swoole-cli-
${{ runner.os }}-composer-
- name: Prepare
run: |
echo "::group::Composer install"
composer config -g process-timeout 600
composer update --prefer-dist --no-progress
echo "::endgroup::"
echo "::group::Kafka prepare"
.github/prepare-kafka.sh
echo "::endgroup::"
echo "::group::Table Init"
docker exec mysql mysql -uroot -p -e "ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';flush privileges;"
tests/db/install-db.sh
docker exec postgres psql -d db_imi_test -U root -f /imi/.github/pgsql.sql
echo "::endgroup::"
echo "test_prepared=1" >> $GITHUB_ENV
- name: Test Env
if: ${{ env.test_prepared && always() }}
run: |
docker ps
docker logs shared-tmp
docker logs redis
find /run/shared -name *.sock
tree -alfugh /run/shared
echo ">>> redis"
echo -e 'auth l83aa26\r\ninfo server' | nc 127.0.0.1 6379 -w 1
echo ">>> ====="
docker compose -f ./.github/service/redis-cluster/docker-compose.yml logs
echo ">>> redis-cluster"
echo -e 'auth l83aa26\r\ninfo server' | nc 172.10.12.2 6379 -w 1
echo -e 'auth l83aa26\r\ncluster info\r\ncluster nodes' | nc 172.10.12.2 6379 -w 1
docker compose -f ./.github/service/redis-cluster/docker-compose.yml exec node-0 cat /bitnami/redis/data/nodes.conf
- name: Test
if: ${{ env.test_prepared && always() }}
env:
REDIS_SERVER_PASSWORD: "l83aa26"
REDIS_SERVER_CLUSTER_PASSWORD: "l83aa26"
REDIS_SERVER_CLUSTER_SEEDS: "172.10.12.2:6379,172.10.12.3:6379,172.10.12.4:6379,172.10.12.5:6379,172.10.12.6:6379,172.10.12.7:6379"
run: composer test
- name: Test connection-center
if: ${{ env.test_prepared && always() }}
run: composer test-connection-center
- name: Test database
if: ${{ env.test_prepared && always() }}
run: composer test-database
- name: Test redis
if: ${{ env.test_prepared && always() }}
env:
REDIS_SERVER_PASSWORD: "l83aa26"
REDIS_SERVER_CLUSTER_PASSWORD: "l83aa26"
REDIS_SERVER_CLUSTER_SEEDS: "172.10.12.2:6379,172.10.12.3:6379,172.10.12.4:6379,172.10.12.5:6379,172.10.12.6:6379,172.10.12.7:6379"
REDIS_SERVER_TLS_CLUSTER_SEEDS: "172.10.12.2:6443,172.10.12.3:6443,172.10.12.4:6443,172.10.12.5:6443,172.10.12.6:6443,172.10.12.7:6443"
REDIS_SERVER_UNIX_SOCK: "/run/shared/redis.sock"
REDIS_SERVER_TLS_HOST: "127.0.0.1"
REDIS_SERVER_TLS_PORT: "6443"
REDIS_SERVER_TLS_PASSWORD: "l83aa26"
REDIS_SERVER_TLS_CA_FILE: ${{ github.workspace }}/.github/service/redis-tls/certs/ca.crt
REDIS_SERVER_TLS_CERT_FILE: ${{ github.workspace }}/.github/service/redis-tls/certs/client.crt
REDIS_SERVER_TLS_KEY_FILE: ${{ github.workspace }}/.github/service/redis-tls/certs/client.key
run: composer test-redis
- name: Test swoole
if: ${{ env.test_prepared && always() }}
env:
REDIS_SERVER_PASSWORD: "l83aa26"
run: composer test-swoole
- name: Test workerman
if: ${{ env.test_prepared && always() }}
run: composer test-workerman
- name: Test workerman-gateway
if: ${{ env.test_prepared && always() }}
run: composer test-workerman-gateway
- name: Test jwt
if: ${{ env.test_prepared && always() }}
run: composer test-jwt
- name: Test queue
if: ${{ env.test_prepared && always() }}
env:
REDIS_SERVER_PASSWORD: "l83aa26"
run: composer test-queue
- name: Test amqp
if: ${{ env.test_prepared && always() }}
env:
REDIS_SERVER_PASSWORD: "l83aa26"
run: composer test-amqp
- name: Test kafka
if: ${{ env.test_prepared && always() }}
env:
REDIS_SERVER_PASSWORD: "l83aa26"
run: composer test-kafka
- name: Test grpc
if: ${{ env.test_prepared && always() }}
env:
REDIS_SERVER_PASSWORD: "l83aa26"
run: composer test-grpc
- name: Test snowflake
if: ${{ env.test_prepared && always() }}
env:
REDIS_SERVER_PASSWORD: "l83aa26"
run: composer test-snowflake
- name: Test mqtt
if: ${{ env.test_prepared && always() }}
env:
REDIS_SERVER_PASSWORD: "l83aa26"
run: composer test-mqtt
- name: Test smarty
if: ${{ env.test_prepared && always() }}
run: composer test-smarty
# - name: Test pgsql
# if: ${{ matrix.swoole-cli == 'v5.0.3' && env.test_prepared && always() }}
# run: composer test-pgsql
- name: Test phar
if: ${{ env.test_prepared && always() }}
run: composer test-phar
- name: Test model
if: ${{ env.test_prepared && always() }}
run: composer test-model
- name: Print logs
if: failure()
run: php .github/print-logs.php
ci-macos:
name: MacOS PHP-${{ matrix.php }} Swoole-${{ matrix.swoole }} RoadRunner-${{ matrix.roadrunner }}
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
php: ["8.2"] # ["8.1", "8.2"]
swoole: [v5.1.0] # [v5.1.0, v5.0.3]
roadrunner: [2.7.*]
env:
MYSQL_SERVER_PASSWORD: "root"
PHP_VERSION: ${{ matrix.php }}
IMI_TEST_AMQP_SERVER_UTIL: 0
IMI_ROADRUNNER_BINARY: ${{ github.workspace }}/rr
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ROADRUNNER_DOCKER_VERSION: ${{ matrix.roadrunner }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup MySQL
uses: shogo82148/actions-setup-mysql@v1
with:
mysql-version: "8.0"
root-password: root
my-cnf: |
socket=/tmp/mysql.sock
- name: Setup Redis
uses: shogo82148/actions-setup-redis@v1
id: setup-redis
with:
redis-version: "7.2"
redis-port: "6379"
redis-tls-port: "6443"
- name: Get Openssl Dir
id: opecssl-dir
run: echo "path=$(brew --prefix [email protected])" >> $GITHUB_OUTPUT
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: pecl
extensions: >
apcu, bcmath, curl, openssl, mbstring, intl, json, redis, mysqli, pdo, pdo_mysql, sockets, zip, :opcache,
swoole-swoole/swoole-src@${{ matrix.swoole }}
env:
SWOOLE_CONFIGURE_OPTS: >
--enable-openssl
--with-openssl-dir=${{ steps.opecssl-dir.outputs.path }}
--enable-http2
--enable-mysqlnd
--enable-swoole-json
--enable-swoole-curl
- name: Check Version
run: |
php -v
php -m
composer -V
php --ri swoole
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ env.php-versions }}-${{ hashFiles('*/composer.json', 'src/Components/*/composer.json') }}
restore-keys: |
${{ runner.os }}-composer-${{ env.php-versions }}-
${{ runner.os }}-composer-
- name: Prepare
run: |
echo "::group::Env prepare"
mysql -uroot -proot -e 'CREATE DATABASE IF NOT EXISTS db_imi_test;'
echo "::endgroup::"
echo "::group::Composer install"
composer update --prefer-dist --no-progress
echo "::endgroup::"
echo "::group::Table Init"
tests/db/install-db.sh
echo "::endgroup::"
- name: Install RoadRunner
run: |
echo no | src/Components/roadrunner/vendor/bin/rr get-binary -f $ROADRUNNER_DOCKER_VERSION
./rr -v
- name: Prepared
run: |
echo "test_prepared=1" >> $GITHUB_ENV
- name: Test
if: ${{ env.test_prepared && always() }}
run: composer test
- name: Test connection-center
if: ${{ env.test_prepared && always() }}
run: composer test-connection-center
- name: Test database
if: ${{ env.test_prepared && always() }}
run: composer test-database
- name: Test redis
if: ${{ env.test_prepared && always() }}
env:
REDIS_SERVER_UNIX_SOCK: ${{ steps.setup-redis.outputs.redis-unix-socket }}
REDIS_SERVER_TLS_HOST: "127.0.0.1"
REDIS_SERVER_TLS_PORT: "6443"
REDIS_SERVER_TLS_CA_FILE: ${{ steps.setup-redis.outputs.redis-tls-dir }}/ca.crt
REDIS_SERVER_TLS_CERT_FILE: ${{ steps.setup-redis.outputs.redis-tls-dir }}/client.crt
REDIS_SERVER_TLS_KEY_FILE: ${{ steps.setup-redis.outputs.redis-tls-dir }}/client.key
run: composer test-redis
- name: Test swoole
if: ${{ env.test_prepared && always() }}
run: composer test-swoole
- name: Test workerman
if: ${{ env.test_prepared && always() }}
run: composer test-workerman
- name: Test workerman-gateway
if: ${{ env.test_prepared && always() }}
run: composer test-workerman-gateway
- name: Test roadrunner
if: ${{ env.test_prepared && always() }}
run: composer test-roadrunner
- name: Test fpm
if: ${{ env.test_prepared && always() }}
run: composer test-fpm
- name: Test jwt
if: ${{ env.test_prepared && always() }}
run: composer test-jwt
- name: Test queue
if: ${{ env.test_prepared && always() }}
run: composer test-queue
- name: Test grpc
if: ${{ env.test_prepared && always() }}
run: composer test-grpc
- name: Test snowflake
if: ${{ env.test_prepared && always() }}
run: composer test-snowflake
- name: Test mqtt
if: ${{ env.test_prepared && always() }}
run: composer test-mqtt
- name: Test smarty
if: ${{ env.test_prepared && always() }}
run: composer test-smarty
- name: Test phar
if: ${{ env.test_prepared && always() }}
run: composer test-phar
- name: Test model
if: ${{ env.test_prepared && always() }}
run: composer test-model
- name: Print logs
if: failure()
run: php .github/print-logs.php
ci-windows:
name: Windows PHP-${{ matrix.php }} RoadRunner-${{ matrix.roadrunner }}
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
php: ["8.1"] # 部分扩展还未在 pecl 发布 PHP 8.2 Windows 版扩展,所以无法测试
roadrunner: [2.7.*]
extensions:
[
"apcu, bcmath, curl, openssl, mbstring, intl, json, redis, mysqli, pdo, pdo_mysql, sockets, :opcache",
]
env:
IMI_ROADRUNNER_BINARY: ${{ github.workspace }}\rr.exe
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ROADRUNNER_DOCKER_VERSION: ${{ matrix.roadrunner }}
steps:
- uses: actions/checkout@v4
- name: Setup MySQL
uses: shogo82148/actions-setup-mysql@v1
with:
mysql-version: "8.0"
root-password: root
- name: Setup Redis-server
run: |
nuget install redis-64 -excludeversion
redis-64\tools\redis-server.exe --service-install
redis-64\tools\redis-server.exe --service-start
'@ECHO Redis Started'
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
ini-values: session.save_path=C:\temp
tools: pecl
extensions: ${{ matrix.extensions }}
env:
fail-fast: true
- name: Get composer cache directory
id: composer-cache
shell: pwsh
run: |
Set-Variable -Name CacheDir -Value (composer config cache-files-dir)
"dir=$CacheDir" >> $env:GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ hashFiles('*/composer.json', 'src/Components/*/composer.json') }}
restore-keys: |
${{ runner.os }}-composer-${{ matrix.php }}-
${{ runner.os }}-composer-
- name: Prepare
run: |
Write-Output "::group::Env prepare"
mysql -uroot -proot -e 'CREATE DATABASE IF NOT EXISTS db_imi_test;'
Write-Output "::endgroup::"
Write-Output "::group::Composer install"
composer update --prefer-dist --no-progress
Write-Output "::endgroup::"
Write-Output "::group::Table Init"
php src\Cli\bin\imi-cli generate/table --app-namespace "Imi\Model\Test"
Write-Output "::endgroup::"
- name: Install RoadRunner
run: |
echo no | src\Components\roadrunner\vendor\bin\rr get-binary -f $env:ROADRUNNER_DOCKER_VERSION
.\rr -v
- name: Prepared
run: |
echo "test_prepared=1" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Test
if: ${{ env.test_prepared && always() }}
run: composer test
- name: Test connection-center
if: ${{ env.test_prepared && always() }}
run: composer test-connection-center-common
- name: Test database
if: ${{ env.test_prepared && always() }}
run: composer test-database
- name: Test redis
if: ${{ env.test_prepared && always() }}
run: composer test-redis
- name: Test fpm
if: ${{ env.test_prepared && always() }}
run: composer test-fpm
- name: Test workerman
if: ${{ env.test_prepared && always() }}
run: composer test-workerman
- name: Test workerman-gateway
if: ${{ env.test_prepared && always() }}
run: composer test-workerman-gateway-w
- name: Test roadrunner
if: ${{ env.test_prepared && always() }}
run: composer test-roadrunner
- name: Test jwt
if: ${{ env.test_prepared && always() }}
run: composer test-jwt
- name: Test snowflake
if: ${{ env.test_prepared && always() }}
run: composer test-snowflake
- name: Test model
if: ${{ env.test_prepared && always() }}
run: composer test-model
- name: Print logs
if: failure()
run: php .github\print-logs.php