-
-
Notifications
You must be signed in to change notification settings - Fork 946
594 lines (525 loc) · 23.4 KB
/
tests.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
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
name: Tests
on:
push:
branches:
- 3.3.x
- master
- 'prep-release-*'
tags:
- 'release-*'
pull_request:
branches:
- 3.3.x
- master
- 'prep-release-*'
jobs:
# Basic checks, e.g. parse errors, commit messages, etc.
basic-checks:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- db: 'none'
php: '8.1'
NOTESTS: 1
name: PHP ${{ matrix.php }} - ${{ matrix.db }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 100
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, intl, gd, exif, iconv
coverage: none
- name: Get Composer Cache Directory
id: composer-cache
run: |
cd phpBB
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
cd ..
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ matrix.php }}-${{ hashFiles('phpBB/composer.lock') }}
- name: Setup environment for phpBB
env:
DB: ${{ matrix.db }}
PHP_VERSION: ${{ matrix.php }}
NOTESTS: '1'
run: |
.github/setup-phpbb.sh $DB $PHP_VERSION $NOTESTS
- name: Phing sniff
run: |
.github/phing-sniff.sh
- name: Check doctum parse errors
run: |
.github/check-doctum-parse-errors.sh
- name: Check code with psalm
run: |
phpBB/vendor/bin/psalm --output-format=github
- name: Check image ICC profiles
run: |
.github/check-image-icc-profiles.sh
- name: Check executable files
run: |
.github/check-executable-files.sh ./
- name: Check stylesheets
run: |
.github/check-stylesheet.sh
- name: Lint JavaScript files
run: |
.github/check-js.sh
- name: Check commit message
if: github.event_name == 'pull_request'
run: |
git fetch origin $GITHUB_BASE_REF &> /dev/null
git-tools/commit-msg-hook-range.sh $(git rev-parse origin/$GITHUB_BASE_REF)..$GITHUB_SHA
# Tests for MySQL and MariaDB
mysql-tests:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- php: '8.1'
db: "mariadb:10.2"
- php: '8.1'
db: "mariadb:10.3"
- php: '8.1'
db: "mariadb:10.4"
- php: '8.1'
db: "mariadb:10.6"
- php: '8.1'
db: "mariadb:10.9"
- php: '8.1'
db: "mariadb:10.10"
- php: '8.1'
db: "mariadb:10.11"
- php: '8.1'
db: "mysql:5.7"
db_alias: "MySQL Slow Tests"
SLOWTESTS: 1
- php: '8.1'
db: "mysql:5.7"
db_alias: "MyISAM Tests"
MYISAM: 1
- php: '8.1'
db: "mysql:5.7"
- php: '8.1'
db: "mysql:8.0"
- php: '8.1'
db: "mysql:8.1"
- php: '8.2'
db: "mysql:8.0"
- php: '8.2'
db: "mariadb:10.2"
- php: '8.3'
db: "mysql:5.7"
- php: '8.3'
db: "mariadb:10.2"
name: PHP ${{ matrix.php }} - ${{ matrix.db_alias != '' && matrix.db_alias || matrix.db }}
services:
mysql:
image: ${{ matrix.db }}
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: phpbb_tests
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- name: Checkout repository
uses: actions/checkout@v4
- id: database-type
env:
MATRIX_DB: ${{ matrix.db }}
run: |
db=$(echo "${MATRIX_DB%%:*}")
echo "db=$db" >> $GITHUB_OUTPUT
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, intl, gd, exif, iconv, mysqli, pdo, pdo_mysql, ldap
coverage: none
- name: Get Composer Cache Directory
id: composer-cache
env:
PHP_VERSION: ${{ matrix.php }}
run: |
cd phpBB
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
cd ..
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ matrix.php }}-${{ hashFiles('phpBB/composer.lock') }}
- name: Setup environment for phpBB
env:
DB: ${{steps.database-type.outputs.db}}
PHP_VERSION: ${{ matrix.php }}
NOTESTS: '0'
run: |
.github/setup-phpbb.sh $DB $PHP_VERSION ${NOTESTS:-0}
- name: Setup database
env:
DB: ${{steps.database-type.outputs.db}}
MYISAM: ${{ matrix.MYISAM != 1 && '0' || '1' }}
run: |
.github/setup-database.sh $DB $MYISAM
- name: Setup LDAP
if: ${{ matrix.SLOWTESTS == 1 }}
run: |
.github/setup-ldap.sh
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup node dependencies
run: npm ci
- name: Setup SPHINX
run: |
.github/setup-sphinx.sh
- name: Lint tests
if: ${{ matrix.SLOWTESTS != 1 && steps.database-type.outputs.db == 'mysql' }}
run: phpBB/vendor/bin/phpunit tests/lint_test.php
- name: Run unit tests
env:
DB: ${{steps.database-type.outputs.db}}
if: ${{ matrix.SLOWTESTS != 1 && matrix.NOTESTS != 1 }}
run: |
phpBB/vendor/bin/phpunit --configuration .github/phpunit-$DB-github.xml --verbose --stop-on-error
- name: Slow tests
env:
DB: ${{steps.database-type.outputs.db}}
if: ${{ matrix.SLOWTESTS == 1 }}
run: |
phpBB/vendor/bin/phpunit --configuration .github/phpunit-$DB-github.xml --group slow
# Tests for PostgreSQL
postgres-tests:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- php: '8.1'
db: "postgres:9.5"
- php: '8.1'
db: "postgres:9.6"
- php: '8.1'
db: "postgres:10"
- php: '8.1'
db: "postgres:11"
- php: '8.1'
db: "postgres:12"
- php: '8.1'
db: "postgres:13"
- php: '8.1'
db: "postgres:14"
- php: '8.1'
db: "postgres:15"
- php: '8.2'
db: "postgres:9.5"
- php: '8.3'
db: "postgres:9.5"
name: PHP ${{ matrix.php }} - ${{ matrix.db }}
services:
postgres:
image: ${{ matrix.db != 'postgres:9.5' && matrix.db != 'postgres:9.6' && matrix.db != 'postgres:10' && matrix.db != 'postgres:11' && matrix.db != 'postgres:12' && matrix.db != 'postgres:13' && matrix.db != 'postgres:14' && matrix.db != 'postgres:15' && 'postgres:10' || matrix.db }}
env:
POSTGRES_HOST: localhost
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
-v /var/run/postgresql:/var/run/postgresql
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- name: Checkout repository
uses: actions/checkout@v4
- id: database-type
env:
MATRIX_DB: ${{ matrix.db }}
run: |
db=$(echo "${MATRIX_DB%%:*}")
echo "db=$db" >> $GITHUB_OUTPUT
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, intl, gd, exif, iconv, pgsql, pdo, pdo_pgsql
coverage: none
- name: Get Composer Cache Directory
id: composer-cache
env:
PHP_VERSION: ${{ matrix.php }}
run: |
cd phpBB
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
cd ..
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ matrix.php }}-${{ hashFiles('phpBB/composer.lock') }}
- name: Setup environment for phpBB
env:
DB: ${{steps.database-type.outputs.db}}
PHP_VERSION: ${{ matrix.php }}
NOTESTS: '0'
run: |
.github/setup-phpbb.sh $DB $PHP_VERSION ${NOTESTS:-0}
- name: Setup database
env:
DB: ${{steps.database-type.outputs.db}}
MYISAM: '0'
run: |
.github/setup-database.sh $DB $MYISAM
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup node dependencies
run: npm ci
- name: Run unit tests
env:
DB: ${{steps.database-type.outputs.db}}
run: |
phpBB/vendor/bin/phpunit --configuration .github/phpunit-$DB-github.xml --verbose --stop-on-error
# Other database types, namely sqlite3 and mssql
other-tests:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- php: '8.1'
db: "sqlite3"
- php: '8.1'
db: "mcr.microsoft.com/mssql/server:2017-latest"
db_alias: 'MSSQL 2017'
- php: '8.1'
db: "mcr.microsoft.com/mssql/server:2019-latest"
db_alias: 'MSSQL 2019'
- php: '8.1'
db: "mcr.microsoft.com/mssql/server:2022-latest"
db_alias: 'MSSQL 2022'
name: PHP ${{ matrix.php }} - ${{ matrix.db_alias != '' && matrix.db_alias || matrix.db }}
services:
mssql:
image: ${{ matrix.db != 'mcr.microsoft.com/mssql/server:2017-latest' && matrix.db != 'mcr.microsoft.com/mssql/server:2019-latest' && matrix.db != 'mcr.microsoft.com/mssql/server:2022-latest' && 'mcr.microsoft.com/mssql/server:2017-latest' || matrix.db }}
env:
SA_PASSWORD: "Pssw0rd_12"
ACCEPT_EULA: "y"
ports:
- 1433:1433
options: >-
--health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'Pssw0rd_12' -Q \"Use [master]; CREATE DATABASE [phpbb_tests] COLLATE Latin1_General_CI_AS\" || exit 1"
--health-interval 10s
--health-timeout 5s
--health-retries 5
--health-start-period 10s
redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- name: Checkout repository
uses: actions/checkout@v4
- id: database-type
env:
MATRIX_DB: ${{ matrix.db }}
run: |
if [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2017-latest' ] || [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2019-latest' ] || [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2022-latest' ]
then
db='mssql'
else
db=$(echo "${MATRIX_DB%%:*}")
fi
echo "db=$db" >> $GITHUB_OUTPUT
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, intl, gd, exif, iconv, sqlsrv, pdo, pdo_sqlsrv
coverage: none
- name: Get Composer Cache Directory
id: composer-cache
env:
PHP_VERSION: ${{ matrix.php }}
run: |
cd phpBB
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
cd ..
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ matrix.php }}-${{ hashFiles('phpBB/composer.lock') }}
- name: Setup environment for phpBB
env:
DB: ${{steps.database-type.outputs.db}}
PHP_VERSION: ${{ matrix.php }}
NOTESTS: '0'
run: |
.github/setup-phpbb.sh $DB $PHP_VERSION ${NOTESTS:-0}
- name: Setup database
env:
DB: ${{steps.database-type.outputs.db}}
MYISAM: '0'
run: |
.github/setup-database.sh $DB $MYISAM
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup node dependencies
run: npm ci
- name: Run unit tests
env:
DB: ${{steps.database-type.outputs.db}}
run: |
phpBB/vendor/bin/phpunit --configuration .github/phpunit-$DB-github.xml --verbose --stop-on-error
# Test with IIS & PostgreSQL on Windows
windows-tests:
runs-on: windows-latest
strategy:
matrix:
type: ['unit', 'functional']
php: ['8.1', '8.2']
db: ['postgres']
name: Windows - ${{ matrix.type }} - PHP ${{ matrix.php }} - ${{ matrix.db }}
steps:
- name: Prepare git for Windows
run: |
git config --system core.autocrlf false
git config --system core.eol lf
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, intl, gd, exif, iconv, pgsql, pdo_pgsql
ini-values: upload_tmp_dir=${{ runner.temp }}, sys_temp_dir=${{ runner.temp }}
coverage: none
- name: Get Composer Cache Directory
id: composer-cache
run: |
cd phpBB
echo "dir=$(composer config cache-files-dir)" >> $env:GITHUB_OUTPUT
cd ..
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ matrix.php }}-${{ hashFiles('phpBB/composer.lock') }}
- name: Setup environment for phpBB
env:
GITHUB_WORKSPACE: ${{ github.workspace }}
TEMP_DIR: ${{ runner.temp }}
run: |
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerRole, IIS-WebServer, IIS-CommonHttpFeatures, IIS-ManagementConsole, IIS-HttpErrors, IIS-HttpRedirect, IIS-WindowsAuthentication, IIS-StaticContent, IIS-DefaultDocument, IIS-HttpCompressionStatic, IIS-DirectoryBrowsing, IIS-WebServerManagementTools, IIS-CGI -All
Set-Service wuauserv -StartupType Manual
(Get-Content ${env:GITHUB_WORKSPACE}\phpBB\web.config).replace("<configuration>", "<configuration>`n`t<system.web>`n`t`t<customErrors mode=`"Off`"/>`n`t</system.web>") | Set-Content ${env:GITHUB_WORKSPACE}\phpBB\web.config
(Get-Content ${env:GITHUB_WORKSPACE}\phpBB\web.config).replace("`t</system.webServer>", "`t`t<httpErrors errorMode=`"Detailed`" />`n`t</system.webServer>") | Set-Content ${env:GITHUB_WORKSPACE}\phpBB\web.config
choco install urlrewrite -y
Import-Module WebAdministration
New-WebSite -Name 'phpBBTest' -PhysicalPath "${env:GITHUB_WORKSPACE}\phpBB" -Force
$session = Get-PSSession -Name WinPSCompatSession
$sb = {Set-ItemProperty 'IIS:\Sites\phpBBTest' -name Bindings -value @{protocol='http';bindingInformation='*:80:phpbb.test'}}
Invoke-Command -Scriptblock $sb -Session $session
$sb = {Set-WebConfigurationProperty -filter /system.WebServer/security/authentication/AnonymousAuthentication -name enabled -value true -location "IIS:\Sites\phpBBTest"}
Invoke-Command -Scriptblock $sb -Session $session
Add-Content -Path $env:windir\System32\drivers\etc\hosts -Value "`r`n127.0.0.1`tphpbb.test" -Force
[System.Environment]::SetEnvironmentVariable('PATH',$Env:PATH+";%windir%\system32\inetsrv")
echo Setup FAST-CGI configuration
Add-WebConfiguration -Filter /system.webServer/fastCgi -PSPath IIS:\ -Value @{fullpath="C:\tools\php\php-cgi.exe"}
echo Setup FACT-CGI handler
New-WebHandler -Name "PHP-FastCGI" -Path "*.php" -Modules FastCgiModule -ScriptProcessor "C:\tools\php\php-cgi.exe" -Verb '*' -ResourceType Either
iisreset
NET START W3SVC
mkdir "${env:GITHUB_WORKSPACE}\phpBB\cache\test"
mkdir "${env:GITHUB_WORKSPACE}\phpBB\cache\installer"
icacls "${env:GITHUB_WORKSPACE}\phpBB\cache" /grant Users:F /T
icacls "${env:GITHUB_WORKSPACE}\phpBB\files" /grant Users:F /T
icacls "${env:GITHUB_WORKSPACE}\phpBB\store" /grant Users:F /T
icacls "${env:GITHUB_WORKSPACE}\phpBB\ext" /grant Users:F /T
icacls "${env:GITHUB_WORKSPACE}\phpBB\vendor-ext" /grant Users:F /T
icacls "${env:GITHUB_WORKSPACE}\phpBB\composer-ext.json" /grant Users:F /T
icacls "${env:GITHUB_WORKSPACE}\phpBB\composer-ext.lock" /grant Users:F /T
icacls "${env:GITHUB_WORKSPACE}\phpBB\images\avatars\upload" /grant Users:F /T
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule("IIS_IUSRS", "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow")
$acl = Get-ACL "${env:TEMP_DIR}"
$acl.AddAccessRule($accessRule)
Set-ACL -Path "${env:TEMP_DIR}" -ACLObject $acl
cd ${env:GITHUB_WORKSPACE}\phpBB
php ..\composer.phar install
cd ..
- name: Setup database
run: |
$postgreSqlSvc = Get-Service "postgresql*"
Set-Service $postgreSqlSvc.Name -StartupType manual
$runningStatus = [System.ServiceProcess.ServiceControllerStatus]::Running
$maxStartTimeout = New-TimeSpan -Seconds 30
try {
$postgreSqlSvc.Start()
$postgreSqlSvc.WaitForStatus($runningStatus, $maxStartTimeout)
} catch {
$_ | select *
}
[System.Environment]::SetEnvironmentVariable('PATH',$Env:PATH+";${env:PGBIN}")
$env:PGPASSWORD = 'root'
psql -c 'ALTER SYSTEM SET hot_standby = on;' -U postgres
psql -c 'ALTER SYSTEM SET wal_level = minimal;' -U postgres
psql -c 'DROP DATABASE IF EXISTS phpbb_tests;' -U postgres
psql -c 'create database phpbb_tests;' -U postgres
Set-MpPreference -ExclusionPath "${env:PGDATA}" # Exclude PGDATA directory from Windows Defender
Set-MpPreference -DisableRealtimeMonitoring $true
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup node dependencies
run: npm ci
- name: Run unit tests
if: ${{ matrix.type == 'unit' }}
run: |
phpBB/vendor/bin/phpunit --configuration .github/phpunit-psql-windows-github.xml --verbose --stop-on-error --exclude-group functional,slow
- name: Run functional tests
if: ${{ matrix.type == 'functional' }}
run: |
phpBB/vendor/bin/phpunit --configuration .github/phpunit-psql-windows-github.xml --verbose --stop-on-error --group functional