Skip to content

Improve PHPT hang diagnostics and fix flaky socket tests #319

Improve PHPT hang diagnostics and fix flaky socket tests

Improve PHPT hang diagnostics and fix flaky socket tests #319

Workflow file for this run

name: Windows tests
on: [push, pull_request]
jobs:
windows-tests:
name: Unit Test on Windows
runs-on: windows-2022
timeout-minutes: 20
if: "!contains(github.event.head_commit.message, '--filter=') || contains(github.event.head_commit.message, '[win-unit]')"
strategy:
fail-fast: false
matrix:
os: [ 'windows-2022' ]
ts: [ 'ts' ]
steps:
- name: Checkout
uses: actions/checkout@v7
with:
persist-credentials: false
- name: Configure git for phpt tests
shell: cmd
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
coverage: none
extensions: curl,openssl,pdo,sockets
env:
phpts: ts
- name: Cache PHP deps and devpack
id: cache-php
uses: actions/cache@v6
with:
path: |
C:\tools\phpdev\deps
C:\tools\phpdev\php-*-devel-*-*
key: php84-${{ runner.os }}-${{ matrix.ts }}-v3
restore-keys: |
php84-${{ runner.os }}-${{ matrix.ts }}-
php84-${{ runner.os }}-
- name: Build Swoole extension
uses: ./.github/workflows/winext
with:
ext-path: .
tools-path: C:\tools\phpdev
conf-args: --enable-swoole-curl --enable-swoole-thread --enable-php-sockets
staging-deps: '1'
deps: openssl,libcurl,libssh2,zlib,nghttp2,libzstd,brotli
- name: Show Swoole extension info
shell: powershell
run: |
php -d extension=php_swoole --ri swoole
- name: Install test dependencies
shell: cmd
run: |
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php --quiet
php composer.phar install --working-dir=tests\include\lib --no-interaction
- name: Run IOCP cURL cancellation test
id: iocp-curl-cancel
continue-on-error: true
timeout-minutes: 1
shell: cmd
run: |
set PHPT=1
set TEST_PHP_EXECUTABLE=php
set SKIP_ONLINE_TESTS=1
set NO_INTERACTION=1
php tests\run-tests -P -q -d extension=php_swoole -d swoole.use_shortname=On --show-diff -g PASS,FAIL,BORK,LEAK,XLEAK --show-slow 1000 --set-timeout 10 tests\swoole_windows\iocp_curl_cancel.phpt
- name: Run core Windows IOCP tests
id: windows-core
continue-on-error: true
timeout-minutes: 2
shell: powershell
run: |
$tests = @(
'tests\swoole_windows\atomic_compat.phpt',
'tests\swoole_windows\bootstrap.phpt',
'tests\swoole_windows\iocp_cancel.phpt',
'tests\swoole_windows\iocp_curl.phpt',
'tests\swoole_windows\iocp_curl_multi.phpt',
'tests\swoole_windows\iocp_file.phpt',
'tests\swoole_windows\iocp_shutdown.phpt',
'tests\swoole_windows\iocp_socket.phpt',
'tests\swoole_windows\local_ip.phpt',
'tests\swoole_windows\local_mac.phpt'
)
& .github\workflows\windows-phpt.ps1 -Path $tests -TimeoutSeconds 12
- name: Run Windows function and atomic tests
id: function-atomic
continue-on-error: true
timeout-minutes: 1
shell: cmd
run: |
set PHPT=1
set TEST_PHP_EXECUTABLE=php
set SKIP_ONLINE_TESTS=1
set NO_INTERACTION=1
php tests\run-tests -P -q -d extension=php_swoole -d swoole.use_shortname=On --show-diff -g PASS,FAIL,BORK,LEAK,XLEAK --show-slow 1000 --set-timeout 10 tests\swoole_function tests\swoole_atomic\atomic.phpt tests\swoole_atomic\wait_and_wakeup.phpt
- name: Run Windows channel and lock tests
id: channel-lock
continue-on-error: true
timeout-minutes: 2
shell: cmd
run: |
set PHPT=1
set TEST_PHP_EXECUTABLE=php
set SKIP_ONLINE_TESTS=1
set NO_INTERACTION=1
php tests\run-tests -P -q -d extension=php_swoole -d swoole.use_shortname=On --show-diff -g PASS,FAIL,BORK,LEAK,XLEAK --show-slow 1000 --set-timeout 10 tests\swoole_channel_coro tests\swoole_coroutine_lock tests\swoole_coroutine_wait_group
- name: Run Windows scheduler tests
id: scheduler
continue-on-error: true
timeout-minutes: 3
shell: powershell
run: |
& .github\workflows\windows-phpt.ps1 -Path tests\swoole_coroutine_scheduler -TimeoutSeconds 12
- name: Run Windows coroutine utility tests
id: coroutine-util
continue-on-error: true
timeout-minutes: 2
shell: powershell
run: |
& .github\workflows\windows-phpt.ps1 -Path tests\swoole_coroutine_util -TimeoutSeconds 12
- name: Run Windows coroutine system tests
id: coroutine-system
continue-on-error: true
timeout-minutes: 2
shell: powershell
run: |
& .github\workflows\windows-phpt.ps1 -Path tests\swoole_coroutine_system -TimeoutSeconds 12
- name: Run Windows timer and event tests
id: timer-event
continue-on-error: true
timeout-minutes: 2
shell: cmd
run: |
set PHPT=1
set TEST_PHP_EXECUTABLE=php
set SKIP_ONLINE_TESTS=1
set NO_INTERACTION=1
php tests\run-tests -P -q -d extension=php_swoole -d swoole.use_shortname=On --show-diff -g PASS,FAIL,BORK,LEAK,XLEAK --show-slow 1000 --set-timeout 10 tests\swoole_timer tests\swoole_event
- name: Run Windows IOCP socket tests (1/4)
id: iocp-socket-1
continue-on-error: true
timeout-minutes: 2
shell: powershell
run: |
& .github\workflows\windows-phpt.ps1 -Path tests\swoole_socket_coro -Count 16 -TimeoutSeconds 12
- name: Run Windows IOCP socket tests (2/4)
id: iocp-socket-2
continue-on-error: true
timeout-minutes: 2
shell: powershell
run: |
& .github\workflows\windows-phpt.ps1 -Path tests\swoole_socket_coro -Offset 16 -Count 16 -TimeoutSeconds 12
- name: Run Windows IOCP socket tests (3/4)
id: iocp-socket-3
continue-on-error: true
timeout-minutes: 2
shell: powershell
run: |
& .github\workflows\windows-phpt.ps1 -Path tests\swoole_socket_coro -Offset 32 -Count 16 -TimeoutSeconds 12
- name: Run Windows IOCP socket tests (4/4)
id: iocp-socket-4
continue-on-error: true
timeout-minutes: 2
shell: powershell
run: |
& .github\workflows\windows-phpt.ps1 -Path tests\swoole_socket_coro -Offset 48 -Count 16 -TimeoutSeconds 12
- name: Run Windows thread tests
id: thread
continue-on-error: true
timeout-minutes: 4
shell: powershell
run: |
& .github\workflows\windows-phpt.ps1 -Path tests\swoole_thread\*.phpt -TimeoutSeconds 20
- name: Check Windows test results
if: always()
shell: powershell
run: |
$outcomes = @(
'${{ steps.iocp-curl-cancel.outcome }}',
'${{ steps.windows-core.outcome }}',
'${{ steps.function-atomic.outcome }}',
'${{ steps.channel-lock.outcome }}',
'${{ steps.scheduler.outcome }}',
'${{ steps.coroutine-util.outcome }}',
'${{ steps.coroutine-system.outcome }}',
'${{ steps.timer-event.outcome }}',
'${{ steps.iocp-socket-1.outcome }}',
'${{ steps.iocp-socket-2.outcome }}',
'${{ steps.iocp-socket-3.outcome }}',
'${{ steps.iocp-socket-4.outcome }}',
'${{ steps.thread.outcome }}'
)
if ($outcomes -contains 'failure' -or $outcomes -contains 'cancelled') {
Write-Error "One or more Windows PHPT suites failed: $($outcomes -join ', ')"
exit 1
}