-
Notifications
You must be signed in to change notification settings - Fork 160
executable file
·226 lines (226 loc) · 8.12 KB
/
test.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
name: MineAdmin Unit and Ci Test
on:
push:
pull_request:
schedule:
- cron: '0 2 * * *'
jobs:
cs-fix:
name: PHP CS Fix on PHP${{ matrix.php }} ${{ matrix.swoole }}
runs-on: ubuntu-latest
strategy:
matrix:
os: [ ubuntu-latest ]
php: [ '8.1' ]
swoole: [ 'swoole' ]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
tools: php-cs-fixer
extensions: redis, pdo, pdo_mysql, bcmath, ${{ matrix.swoole }}
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ matrix.php-version }}-composer
restore-keys: |
${{ matrix.php-version }}-composer
- name: Setup Packages
run: ./.github/ci/requirement.install.sh
- name: Run CS Fix
run: |
vendor/bin/php-cs-fixer fix app --dry-run --diff
tests-swoole:
needs: cs-fix
name: Test on PHP${{ matrix.php-version }} Swoole-${{ matrix.sw-version }}
runs-on: "${{ matrix.os }}"
strategy:
matrix:
os: [ ubuntu-latest ]
php-version: [ '8.3', '8.2', '8.1' ]
sw-version: [ 'v5.0.3', 'v5.1.5', 'master' ]
exclude:
- php-version: '8.3'
sw-version: 'v5.0.3'
max-parallel: 20
fail-fast: false
env:
SW_VERSION: ${{ matrix.sw-version }}
MYSQL_VERSION: '8.0'
PGSQL_VERSION: '14'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Upgrade
run: |
sudo apt-get clean
sudo apt-get update
sudo apt-get upgrade -f
- name: Setup PHP TS
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: phpize
extensions: redis, pdo, pdo_mysql,sqlsrv,pdo_sqlsrv,pdo_odbc,bcmath
ini-values: opcache.enable_cli=0
env:
phpts: ts
- name: Install Swoole
run: |
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
- name: Setup Swoole
run: |
sudo apt-get install libcurl4-openssl-dev libc-ares-dev libpq-dev
cd swoole
phpize
./configure --enable-openssl --enable-swoole-curl --enable-cares --enable-swoole-pgsql --enable-brotli --enable-swoole-thread
make -j$(nproc)
sudo make install
sudo sh -c "echo extension=swoole > /etc/php/${{ matrix.php-version }}/cli/conf.d/swoole.ini"
sudo sh -c "echo swoole.use_shortname='Off' >> /etc/php/${{ matrix.php-version }}/cli/conf.d/swoole.ini"
php --ri swoole
- name: Setup Packages
run: ./.github/ci/requirement.install.sh
- name: Run PHPStan
run: ./.github/ci/run.check.sh
- name: Setup Services
run: ./.github/ci/setup.services.sh
- name: Setup Mysql
run: bash ./.github/ci/setup.mysql.sh
- name: Setup PostgreSQL
run: bash ./.github/ci/setup.pgsql.sh
- name: Run Scripts Before Test
run: cp .github/ci/.env.example .env
- name: Print PHP Environments
run: |
sudo rm -rf /etc/php/${{ matrix.php-version }}/cli/conf.d/20-xdebug.ini
php -i
php -m
- name: Run Mysql Test Cases
env:
DB_DRIVER: mysql
DB_HOST: 127.0.0.1
DB_DATABASE: mineadmin
run: ./.github/ci/run.test.sh
- name: Clear Redis Cache
run: |
docker exec redis redis-cli FLUSHALL
sleep 1
- name: Run PgSql Test Cases
env:
DB_DRIVER: pgsql
DB_HOST: 127.0.0.1
DB_PORT: 5432
DB_USERNAME: postgres
DB_PASSWORD: postgres
DB_CHARSET: utf8
DB_DATABASE: mineadmin
run: ./.github/ci/run.test.sh
tests-swow:
needs: cs-fix
name: Test on PHP${{ matrix.php-version }} Swow-${{ matrix.sw-version }}
runs-on: "${{ matrix.os }}"
strategy:
matrix:
os: [ ubuntu-latest ]
php-version: [ '8.3', '8.2', '8.1' ]
sw-version: [ 'develop' ]
exclude:
- php-version: '8.3'
sw-version: 'v5.0.3'
max-parallel: 20
fail-fast: false
env:
SW_VERSION: ${{ matrix.sw-version }}
MYSQL_VERSION: '8.0'
PGSQL_VERSION: '14'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Upgrade
run: |
sudo apt-get clean
sudo apt-get update
sudo apt-get upgrade -f
COMPOSER_JSON_PATH="composer.json"
COMPOSER_JSON_CONTENT=$(cat $COMPOSER_JSON_PATH)
COMPOSER_DATA=$(echo $COMPOSER_JSON_CONTENT | jq 'del(.require["ext-swoole"])')
COMPOSER_DATA=$(echo $COMPOSER_DATA | jq '.require["hyperf/engine-swow"] = "*"')
echo $COMPOSER_DATA | jq '.' > $COMPOSER_JSON_PATH
cp -f .github/ci/hyperf.php bin/hyperf.php
cp -f .github/ci/server.php config/autoload/server.php
cp -f .github/ci/bootstrap.php tests/bootstrap.php
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: phpize
extensions: redis, pdo, pdo_mysql,sqlsrv,pdo_sqlsrv,pdo_odbc,bcmath
ini-values: opcache.enable_cli=0
- name: Install Swow
run: |
wget https://github.com/swow/swow/archive/${SW_VERSION}.tar.gz -O swow.tar.gz
mkdir -p swow
tar -xf swow.tar.gz -C swow --strip-components=1
rm swow.tar.gz
- name: Setup Swow
run: |
sudo apt-get install libcurl4-openssl-dev libc-ares-dev libpq-dev
cd swow/ext
phpize
./configure --enable-openssl --enable-swow-curl --enable-cares --enable-swow-pgsql --enable-brotli
make && 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: |
./.github/ci/requirement.install.sh
- name: Run PHPStan
run: ./.github/ci/run.check.sh
- name: Setup Services
run: ./.github/ci/setup.services.sh
- name: Setup Mysql
run: bash ./.github/ci/setup.mysql.sh
- name: Setup PostgreSQL
run: bash ./.github/ci/setup.pgsql.sh
- name: Run Scripts Before Test
run: cp .github/ci/.env.example .env
- name: Print PHP Environments
run: |
sudo rm -rf /etc/php/${{ matrix.php-version }}/cli/conf.d/20-xdebug.ini
php -i
php -m
- name: Run Mysql Test Cases
env:
DB_DRIVER: mysql
DB_HOST: 127.0.0.1
DB_DATABASE: mineadmin
run: |
vendor/bin/phpunit --group=migrations --bootstrap tests/bootstrap.php --configuration phpunit.xml.dist --colors=always
vendor/bin/phpunit --exclude-group=migrations --bootstrap tests/bootstrap.php --configuration phpunit.xml.dist --colors=always
- name: Clear Redis Cache
run: |
docker exec redis redis-cli FLUSHALL
sleep 1
- name: Run PgSql Test Cases
env:
DB_DRIVER: pgsql
DB_HOST: 127.0.0.1
DB_PORT: 5432
DB_USERNAME: postgres
DB_PASSWORD: postgres
DB_CHARSET: utf8
DB_DATABASE: mineadmin
run: |
vendor/bin/phpunit --group=migrations --bootstrap tests/bootstrap.php --configuration phpunit.xml.dist --colors=always
vendor/bin/phpunit --exclude-group=migrations --bootstrap tests/bootstrap.php --configuration phpunit.xml.dist --colors=always