Skip to content

Commit 8acac30

Browse files
committed
Add windows IIs tests
1 parent a7195be commit 8acac30

2 files changed

Lines changed: 147 additions & 0 deletions

File tree

.github/workflows/tests.yml

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ on:
4545
required: false
4646
type: string
4747
default: '1'
48+
RUN_WINDOWS_JOBS:
49+
required: false
50+
type: string
51+
default: '1'
4852
RUN_NPM_INSTALL:
4953
required: false
5054
type: string
@@ -526,3 +530,142 @@ jobs:
526530
run: phpBB/vendor/bin/phpunit --configuration phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml --bootstrap ./tests/bootstrap.php
527531
working-directory: ./phpBB3
528532
# END Other Tests Job
533+
534+
# Test with IIS & PostgreSQL on Windows
535+
windows-tests:
536+
if: ${{ inputs.RUN_WINDOWS_JOBS == '1' }}
537+
runs-on: windows-latest
538+
strategy:
539+
matrix:
540+
php:
541+
- ${{ startsWith(inputs.PRIMARY_PHP_VERSION, '7') && '7.4' || inputs.PRIMARY_PHP_VERSION }}
542+
db:
543+
- postgres
544+
type:
545+
- unit
546+
- functional
547+
548+
name: PHP ${{ matrix.php }} - Windows - ${{ matrix.type }}
549+
550+
steps:
551+
- name: Prepare git for Windows
552+
run: |
553+
git config --system core.autocrlf false
554+
git config --system core.eol lf
555+
556+
- name: Checkout phpBB
557+
uses: actions/checkout@v4
558+
with:
559+
repository: phpbb/phpbb
560+
ref: ${{ env.PHPBB_BRANCH }}
561+
path: phpBB3
562+
563+
- name: Checkout extension
564+
uses: actions/checkout@v4
565+
with:
566+
path: phpBB3/phpBB/ext/${{ env.EXTNAME }}
567+
568+
- name: Setup PHP
569+
uses: shivammathur/setup-php@v2
570+
with:
571+
php-version: ${{ matrix.php }}
572+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, intl, gd, exif, iconv, pgsql, pdo_pgsql
573+
ini-values: upload_tmp_dir=${{ runner.temp }}, sys_temp_dir=${{ runner.temp }}
574+
coverage: none
575+
576+
- name: Setup environment for phpBB
577+
env:
578+
GITHUB_WORKSPACE: ${{ github.workspace }}
579+
TEMP_DIR: ${{ runner.temp }}
580+
run: |
581+
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
582+
Set-Service wuauserv -StartupType Manual
583+
(Get-Content ${env:GITHUB_WORKSPACE}\phpBB3\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}\phpBB3\phpBB\web.config
584+
(Get-Content ${env:GITHUB_WORKSPACE}\phpBB3\phpBB\web.config).replace("`t</system.webServer>", "`t`t<httpErrors errorMode=`"Detailed`" />`n`t</system.webServer>") | Set-Content ${env:GITHUB_WORKSPACE}\phpBB3\phpBB\web.config
585+
choco install urlrewrite -y
586+
Import-Module WebAdministration
587+
New-WebSite -Name 'phpBBTest' -PhysicalPath "${env:GITHUB_WORKSPACE}\phpBB3\phpBB" -Force
588+
$session = Get-PSSession -Name WinPSCompatSession
589+
$sb = {Set-ItemProperty 'IIS:\Sites\phpBBTest' -name Bindings -value @{protocol='http';bindingInformation='*:80:phpbb.test'}}
590+
Invoke-Command -Scriptblock $sb -Session $session
591+
$sb = {Set-WebConfigurationProperty -filter /system.WebServer/security/authentication/AnonymousAuthentication -name enabled -value true -location "IIS:\Sites\phpBBTest"}
592+
Invoke-Command -Scriptblock $sb -Session $session
593+
Add-Content -Path $env:windir\System32\drivers\etc\hosts -Value "`r`n127.0.0.1`tphpbb.test" -Force
594+
[System.Environment]::SetEnvironmentVariable('PATH',$Env:PATH+";%windir%\system32\inetsrv")
595+
echo Setup FAST-CGI configuration
596+
Add-WebConfiguration -Filter /system.webServer/fastCgi -PSPath IIS:\ -Value @{fullpath="C:\tools\php\php-cgi.exe"}
597+
echo Setup FACT-CGI handler
598+
New-WebHandler -Name "PHP-FastCGI" -Path "*.php" -Modules FastCgiModule -ScriptProcessor "C:\tools\php\php-cgi.exe" -Verb '*' -ResourceType Either
599+
iisreset
600+
NET START W3SVC
601+
mkdir "${env:GITHUB_WORKSPACE}\phpBB3\phpBB\cache\test"
602+
mkdir "${env:GITHUB_WORKSPACE}\phpBB3\phpBB\cache\installer"
603+
icacls "${env:GITHUB_WORKSPACE}\phpBB3\phpBB\cache" /grant Users:F /T
604+
icacls "${env:GITHUB_WORKSPACE}\phpBB3\phpBB\files" /grant Users:F /T
605+
icacls "${env:GITHUB_WORKSPACE}\phpBB3\phpBB\store" /grant Users:F /T
606+
icacls "${env:GITHUB_WORKSPACE}\phpBB3\phpBB\images\avatars\upload" /grant Users:F /T
607+
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule("IIS_IUSRS", "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow")
608+
$acl = Get-ACL "${env:TEMP_DIR}"
609+
$acl.AddAccessRule($accessRule)
610+
Set-ACL -Path "${env:TEMP_DIR}" -ACLObject $acl
611+
cd ${env:GITHUB_WORKSPACE}\phpBB3\phpBB
612+
php ..\composer.phar install
613+
php ..\composer.phar remove phpunit/dbunit --dev --update-with-dependencies
614+
php ..\composer.phar require symfony/yaml:~4.4 misantron/dbunit:~5.0 phpunit/phpunit:^9.3 doctrine/instantiator:^1.4 --dev --update-with-all-dependencies --ignore-platform-reqs
615+
cd ..
616+
617+
- name: Setup database
618+
run: |
619+
$postgreSqlSvc = Get-Service "postgresql*"
620+
Set-Service $postgreSqlSvc.Name -StartupType manual
621+
$runningStatus = [System.ServiceProcess.ServiceControllerStatus]::Running
622+
$maxStartTimeout = New-TimeSpan -Seconds 30
623+
try {
624+
$postgreSqlSvc.Start()
625+
$postgreSqlSvc.WaitForStatus($runningStatus, $maxStartTimeout)
626+
} catch {
627+
$_ | select *
628+
}
629+
[System.Environment]::SetEnvironmentVariable('PATH',$Env:PATH+";${env:PGBIN}")
630+
$env:PGPASSWORD = 'root'
631+
psql -c 'ALTER SYSTEM SET hot_standby = on;' -U postgres
632+
psql -c 'ALTER SYSTEM SET wal_level = minimal;' -U postgres
633+
psql -c 'DROP DATABASE IF EXISTS phpbb_tests;' -U postgres
634+
psql -c 'create database phpbb_tests;' -U postgres
635+
Set-MpPreference -ExclusionPath "${env:PGDATA}" # Exclude PGDATA directory from Windows Defender
636+
Set-MpPreference -DisableRealtimeMonitoring $true
637+
638+
- name: Install NPM dependencies
639+
if: ${{ inputs.RUN_NPM_INSTALL == '1' }}
640+
uses: actions/setup-node@v4
641+
with:
642+
node-version: 20
643+
644+
- name: Run npm ci
645+
if: ${{ inputs.RUN_NPM_INSTALL == '1' }}
646+
run: npm ci
647+
working-directory: .\phpBB3\phpBB\ext\${{ env.EXTNAME }}
648+
649+
- name: Install composer dependencies
650+
if: ${{ inputs.RUN_COMPOSER_INSTALL == '1' }}
651+
run: composer install
652+
working-directory: .\phpBB3\phpBB\ext\${{ env.EXTNAME }}
653+
654+
- name: Setup PHPUnit files
655+
run: |
656+
if (-not (Test-Path "phpBB\ext\$env:EXTNAME\.github")) {
657+
mkdir "phpBB\ext\$env:EXTNAME\.github"
658+
}
659+
Copy-Item ".github\phpunit*" -Destination "phpBB\ext\$env:EXTNAME\.github" -Force
660+
working-directory: .\phpBB3
661+
662+
- name: Run unit tests
663+
if: ${{ matrix.type == 'unit' }}
664+
run: phpBB/vendor/bin/phpunit --configuration phpBB/ext/$env:EXTNAME/.github/phpunit-psql-windows-github.xml --bootstrap ./tests/bootstrap.php --verbose --stop-on-error --exclude-group functional
665+
working-directory: .\phpBB3
666+
667+
- name: Run functional tests
668+
if: ${{ matrix.type == 'functional' }}
669+
run: phpBB/vendor/bin/phpunit --configuration phpBB/ext/$env:EXTNAME/.github/phpunit-psql-windows-github.xml --bootstrap ./tests/bootstrap.php --verbose --stop-on-error --group functional
670+
working-directory: .\phpBB3
671+
# END IIS & PostgreSQL on Windows Tests Job

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ call-tests:
121121
# Default: 1
122122
RUN_MSSQL_JOBS: 1
123123
124+
# Set this to 0 to skip all Windows IIS & PostgreSQL tests.
125+
# Default: 1
126+
RUN_WINDOWS_JOBS: 1
127+
124128
# Set this to 1 if your extension relies on NPM dependencies.
125129
# Default: 0
126130
RUN_NPM_INSTALL: 0

0 commit comments

Comments
 (0)