-
Notifications
You must be signed in to change notification settings - Fork 48
579 lines (566 loc) · 21.2 KB
/
tests.yml
File metadata and controls
579 lines (566 loc) · 21.2 KB
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
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
name: Tests
on:
push:
pull_request:
jobs:
phpstan:
name: PHPStan Static Analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: pdo, pdo_mysql, pdo_pgsql, pdo_sqlite, pdo_oci
coverage: none
- run: composer install --no-interaction --prefer-dist
- run: composer pdodb:phpstan
mysql:
name: MySQL Tests
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
MYSQL_DATABASE: testdb
MYSQL_USER: testuser
MYSQL_PASSWORD: testpass
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping -h 127.0.0.1 -uroot -proot"
--health-interval=10s
--health-timeout=5s
--health-retries=3
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
memcached:
image: memcached:1.6-alpine
ports:
- 11211:11211
options: >-
--health-cmd "echo 'stats' | nc localhost 11211"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: pdo_mysql, simplexml, xmlreader, redis, memcached, apcu
coverage: xdebug
- run: composer install --no-interaction --prefer-dist
- name: Enable MySQL local_infile
run: |
mysql -h 127.0.0.1 -uroot -proot -e "SET GLOBAL local_infile=1;"
- run: |
PDODB_DSN="mysql:host=127.0.0.1;port=3306;dbname=testdb;charset=utf8mb4" \
PDODB_USERNAME="testuser" \
PDODB_PASSWORD="testpass" \
vendor/bin/phpunit --testsuite="MySQL Tests" --coverage-clover coverage-mysql.xml
- name: Test MySQL Examples
run: ./scripts/test-examples.sh --verbose
- name: Upload MySQL coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage-mysql.xml
flags: mysql
name: mysql-coverage
mariadb:
name: MariaDB Tests
runs-on: ubuntu-latest
services:
mariadb:
image: mariadb:11.2
env:
MYSQL_DATABASE: testdb
MYSQL_USER: testuser
MYSQL_PASSWORD: testpass
MYSQL_ROOT_PASSWORD: root
ports:
- 3305:3306
options: >-
--health-cmd="healthcheck.sh --connect --innodb_initialized"
--health-interval=5s
--health-timeout=10s
--health-retries=20
--health-start-period=40s
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
memcached:
image: memcached:1.6-alpine
ports:
- 11211:11211
options: >-
--health-cmd "echo 'stats' | nc localhost 11211"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: pdo_mysql, simplexml, xmlreader, redis, memcached, apcu
coverage: xdebug
- run: composer install --no-interaction --prefer-dist
- run: |
PDODB_DSN="mariadb:host=127.0.0.1;port=3305;dbname=testdb;charset=utf8mb4" \
PDODB_USERNAME="testuser" \
PDODB_PASSWORD="testpass" \
vendor/bin/phpunit --testsuite="MariaDB Tests" --coverage-clover coverage-mariadb.xml
- name: Test MariaDB Examples
run: |
export PDODB_DRIVER=mariadb
export PDODB_USERNAME="testuser"
export PDODB_PASSWORD="testpass"
export PDODB_HOST="127.0.0.1"
export PDODB_PORT="3305"
export PDODB_DATABASE="testdb"
./scripts/test-examples.sh --verbose
- name: Upload MariaDB coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage-mariadb.xml
flags: mariadb
name: mariadb-coverage
postgres:
name: PostgreSQL Tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_DB: testdb
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5433:5432
options: >-
--health-cmd="pg_isready -U postgres -d testdb"
--health-interval=10s
--health-timeout=5s
--health-retries=5
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
memcached:
image: memcached:1.6-alpine
ports:
- 11211:11211
options: >-
--health-cmd "echo 'stats' | nc localhost 11211"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: pdo_pgsql, simplexml, xmlreader, redis, memcached, apcu
coverage: xdebug
- run: composer install --no-interaction --prefer-dist
- name: Setup PostgreSQL test user
run: |
PGPASSWORD=postgres psql -h localhost -p 5433 -U postgres -d testdb -c "CREATE USER testuser WITH PASSWORD 'testpass';"
PGPASSWORD=postgres psql -h localhost -p 5433 -U postgres -d testdb -c "GRANT ALL PRIVILEGES ON DATABASE testdb TO testuser;"
PGPASSWORD=postgres psql -h localhost -p 5433 -U postgres -d testdb -c "GRANT ALL ON SCHEMA public TO testuser;"
- run: |
PDODB_DSN="pgsql:host=localhost;port=5433;dbname=testdb" \
PDODB_USERNAME="testuser" \
PDODB_PASSWORD="testpass" \
vendor/bin/phpunit --testsuite="PostgreSQL Tests" --coverage-clover coverage-postgres.xml
- name: Test PostgreSQL Examples
run: ./scripts/test-examples.sh --verbose
- name: Upload PostgreSQL coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage-postgres.xml
flags: postgres
name: postgres-coverage
sqlite:
name: SQLite Tests
runs-on: ubuntu-latest
services:
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
memcached:
image: memcached:1.6-alpine
ports:
- 11211:11211
options: >-
--health-cmd "echo 'stats' | nc localhost 11211"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: pdo_sqlite, redis, memcached, apcu
coverage: xdebug
- run: composer install --no-interaction --prefer-dist
- run: |
PDODB_DSN="sqlite::memory:" \
vendor/bin/phpunit --testsuite="SQLite Tests" --coverage-clover coverage-sqlite.xml
- name: Test SQLite Examples
run: ./scripts/test-examples.sh --verbose
- name: Upload SQLite coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage-sqlite.xml
flags: sqlite
name: sqlite-coverage
mssql:
name: MSSQL Tests
runs-on: ubuntu-latest
services:
mssql:
image: mcr.microsoft.com/mssql/server:2022-latest
env:
ACCEPT_EULA: Y
MSSQL_SA_PASSWORD: Test123!@#
MSSQL_PID: Developer
ports:
- 1433:1433
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
memcached:
image: memcached:1.6-alpine
ports:
- 11211:11211
options: >-
--health-cmd "echo 'stats' | nc localhost 11211"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: pdo, pdo_odbc, odbc, redis, memcached, apcu
coverage: xdebug
- name: Install Microsoft ODBC Driver and SQL Server Tools
run: |
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 unixodbc-dev mssql-tools18
echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc
export PATH="$PATH:/opt/mssql-tools18/bin"
- name: Install pdo_sqlsrv extension
run: |
if ! php -m | grep -q pdo_sqlsrv; then
sudo pecl install pdo_sqlsrv-5.11.1 || sudo pecl install -f pdo_sqlsrv-5.11.1
echo "extension=pdo_sqlsrv.so" | sudo tee $(php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||")/conf.d/pdo_sqlsrv.ini
fi
php -m | grep pdo_sqlsrv || echo "Warning: pdo_sqlsrv extension not loaded"
- name: Wait for MSSQL to be ready
run: |
export PATH="$PATH:/opt/mssql-tools18/bin"
echo "Waiting for MSSQL to be ready..."
for i in {1..120}; do
if sqlcmd -S localhost -U sa -P 'Test123!@#' -C -Q 'SELECT 1' -b > /dev/null 2>&1; then
echo "MSSQL is ready!"
sqlcmd -S localhost -U sa -P 'Test123!@#' -C -Q 'SELECT @@VERSION' -b
break
fi
if [ $i -eq 120 ]; then
echo "MSSQL failed to start after 240 seconds"
exit 1
fi
echo "Waiting for MSSQL... ($i/120)"
sleep 2
done
- name: Create database
run: |
export PATH="$PATH:/opt/mssql-tools18/bin"
# Create database (ignore error if exists)
sqlcmd -S localhost -U sa -P 'Test123!@#' -C -Q "IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = 'testdb') CREATE DATABASE testdb;" || true
echo "Database 'testdb' ready"
- run: composer install --no-interaction --prefer-dist
- run: |
PDODB_DSN="sqlsrv:Server=localhost,1433;Database=testdb;TrustServerCertificate=yes" \
PDODB_USERNAME="sa" \
PDODB_PASSWORD="Test123!@#" \
vendor/bin/phpunit --testsuite="MSSQL Tests" --coverage-clover coverage-mssql.xml
- name: Test MSSQL Examples
run: |
export PDODB_DRIVER=sqlsrv
export PDODB_USERNAME="sa"
export PDODB_PASSWORD="Test123!@#"
export PDODB_HOST="localhost"
export PDODB_PORT="1433"
export PDODB_DATABASE="testdb"
./scripts/test-examples.sh --verbose
- name: Upload MSSQL coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage-mssql.xml
flags: mssql
name: mssql-coverage
oracle:
name: Oracle Tests
runs-on: ubuntu-latest
services:
oracle:
image: gvenzl/oracle-xe:21-slim
env:
ORACLE_PASSWORD: System123456
ports:
- 1521:1521
- 5500:5500
options: >-
--health-cmd="healthcheck.sh"
--health-interval=30s
--health-timeout=10s
--health-retries=10
--health-start-period=5m
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
memcached:
image: memcached:1.6-alpine
ports:
- 11211:11211
options: >-
--health-cmd "echo 'stats' | nc localhost 11211"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: pdo, redis, memcached, apcu, bz2
coverage: xdebug
- name: Install Oracle dependencies
run: |
# Check if packages are already installed (common in GitHub Actions runners)
if ! command -v wget >/dev/null 2>&1; then
sudo apt-get update && sudo apt-get install -y wget
fi
if ! command -v unzip >/dev/null 2>&1; then
sudo apt-get update && sudo apt-get install -y unzip
fi
# Install libaio only if not installed
if ! dpkg-query -W -f='${Status}' libaio1t64 2>/dev/null | grep -q "install ok installed"; then
if ! dpkg-query -W -f='${Status}' libaio1 2>/dev/null | grep -q "install ok installed"; then
sudo apt-get update && (sudo apt-get install -y libaio1t64 || sudo apt-get install -y libaio1)
fi
fi
# Create symlink for compatibility with Oracle Instant Client (Ubuntu 24.04+)
if [ -f /usr/lib/x86_64-linux-gnu/libaio.so.1t64 ] && [ ! -L /usr/lib/x86_64-linux-gnu/libaio.so.1 ]; then
sudo ln -sf /usr/lib/x86_64-linux-gnu/libaio.so.1t64 /usr/lib/x86_64-linux-gnu/libaio.so.1
fi
- name: Install Oracle Instant Client
run: |
cd /tmp
# Download Oracle Instant Client Basic (libraries)
ORACLE_BASIC_URL="https://download.oracle.com/otn_software/linux/instantclient/211000/instantclient-basic-linux.x64-21.1.0.0.0.zip"
echo "Downloading Oracle Instant Client Basic from: $ORACLE_BASIC_URL"
wget --timeout=30 --tries=3 --progress=bar:force "$ORACLE_BASIC_URL"
unzip -q instantclient-basic-linux.x64-21.1.0.0.0.zip
# Download Oracle Instant Client SDK (headers needed for pdo_oci compilation)
ORACLE_SDK_URL="https://download.oracle.com/otn_software/linux/instantclient/211000/instantclient-sdk-linux.x64-21.1.0.0.0.zip"
echo "Downloading Oracle Instant Client SDK from: $ORACLE_SDK_URL"
wget --timeout=30 --tries=3 --progress=bar:force "$ORACLE_SDK_URL"
unzip -q instantclient-sdk-linux.x64-21.1.0.0.0.zip
# Install to /usr/lib/oracle/21/client64
sudo mkdir -p /usr/lib/oracle/21/client64
sudo mv instantclient_21_1/* /usr/lib/oracle/21/client64/
echo '/usr/lib/oracle/21/client64/lib' | sudo tee /etc/ld.so.conf.d/oracle-instantclient.conf
sudo ldconfig
# Verify installation
if [ ! -f /usr/lib/oracle/21/client64/lib/libclntsh.so ]; then
echo "Error: Oracle Instant Client installation failed - libclntsh.so not found"
exit 1
fi
if [ ! -f /usr/lib/oracle/21/client64/sdk/include/oci.h ]; then
echo "Error: Oracle Instant Client SDK installation failed - oci.h not found"
ls -la /usr/lib/oracle/21/client64/ | head -20
exit 1
fi
- name: Install pdo_oci extension
run: |
export ORACLE_HOME=/usr/lib/oracle/21/client64
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
# Set include path for oci.h header file
export C_INCLUDE_PATH=$ORACLE_HOME/sdk/include:$C_INCLUDE_PATH
export CPPFLAGS="-I$ORACLE_HOME/sdk/include"
export LDFLAGS="-L$ORACLE_HOME/lib"
if ! php -m | grep -q pdo_oci; then
echo "Installing pdo_oci extension..."
# Pass Oracle Instant Client path to pecl install
# Format: instantclient,/path/to/instant/client/lib
echo "instantclient,$ORACLE_HOME/lib" | sudo pecl install pdo_oci || echo "instantclient,$ORACLE_HOME/lib" | sudo pecl install -f pdo_oci
echo "extension=pdo_oci.so" | sudo tee $(php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||")/conf.d/pdo_oci.ini
sudo ldconfig
fi
php -m | grep pdo_oci || echo "Warning: pdo_oci extension not loaded"
- name: Wait for Oracle to be ready
run: |
export ORACLE_HOME=/usr/lib/oracle/21/client64
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME/bin:$PATH
echo "Waiting for Oracle to be ready..."
# Install sqlplus for health check
cd /tmp
wget -q https://download.oracle.com/otn_software/linux/instantclient/instantclient-sqlplus-linux.x64-21.1.0.0.0.zip
unzip -q instantclient-sqlplus-linux.x64-21.1.0.0.0.zip
sudo mv instantclient_21_1/sqlplus /usr/local/bin/
sudo mv instantclient_21_1/* /usr/lib/oracle/21/client64/lib/
sudo ldconfig
for i in {1..120}; do
if echo "SELECT 1 FROM DUAL;" | sqlplus -S system/System123456@localhost:1521/XEPDB1 2>&1 | grep -q "1"; then
echo "Oracle is ready!"
echo "SELECT * FROM v\$version;" | sqlplus -S system/System123456@localhost:1521/XEPDB1 2>&1 | head -5
break
fi
if [ $i -eq 120 ]; then
echo "Oracle failed to start after 240 seconds"
exit 1
fi
echo "Waiting for Oracle... ($i/120)"
sleep 2
done
- name: Setup Oracle test user
run: |
export ORACLE_HOME=/usr/lib/oracle/21/client64
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME/bin:$PATH
# Connect to XEPDB1 PDB and create testuser
sqlplus -S system/System123456@localhost:1521/XEPDB1 <<EOF
ALTER SESSION SET CONTAINER=XEPDB1;
-- Drop user if exists (ignore errors)
BEGIN
EXECUTE IMMEDIATE 'DROP USER testuser CASCADE';
EXCEPTION
WHEN OTHERS THEN NULL;
END;
/
-- Create user
CREATE USER testuser IDENTIFIED BY testpass;
GRANT CONNECT, RESOURCE TO testuser;
ALTER USER testuser QUOTA UNLIMITED ON USERS;
EXIT;
EOF
echo "Oracle user 'testuser' created successfully"
- run: composer install --no-interaction --prefer-dist
- run: |
export ORACLE_HOME=/usr/lib/oracle/21/client64
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PDODB_DRIVER=oci
export PDODB_HOST=localhost
export PDODB_PORT=1521
export PDODB_USERNAME=testuser
export PDODB_PASSWORD=testpass
export PDODB_SERVICE_NAME=XEPDB1
vendor/bin/phpunit --testsuite="Oracle Tests" --coverage-clover coverage-oracle.xml
- name: Test Oracle Examples
run: |
export ORACLE_HOME=/usr/lib/oracle/21/client64
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PDODB_DRIVER=oci
export PDODB_USERNAME="testuser"
export PDODB_PASSWORD="testpass"
export PDODB_HOST="localhost"
export PDODB_PORT="1521"
export PDODB_SERVICE_NAME="XEPDB1"
./scripts/test-examples.sh --verbose
- name: Upload Oracle coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage-oracle.xml
flags: oracle
name: oracle-coverage
shared-coverage:
name: Shared Coverage Tests
runs-on: ubuntu-latest
services:
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
memcached:
image: memcached:1.6-alpine
ports:
- 11211:11211
options: >-
--health-cmd "echo 'stats' | nc localhost 11211"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: pdo_sqlite, redis, memcached, apcu
coverage: xdebug
- run: composer install --no-interaction --prefer-dist
- run: vendor/bin/phpunit --testsuite="Shared Tests" --coverage-clover coverage-shared.xml
- name: Upload Shared coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage-shared.xml
flags: shared
name: shared-coverage