Test with Swow staging version #1588
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test with Swow staging version | |
on: | |
push: | |
pull_request: | |
workflow_dispatch: | |
swow_ref: | |
description: 'Using Swow git ref' | |
required: false | |
default: 'develop' | |
schedule: | |
- cron: '0 3 * * *' | |
env: | |
SW_VERSION: 'develop' | |
jobs: | |
linux-tests: | |
name: Test for PHP ${{ matrix.php-version }} Swow ${{ (github.event.inputs && github.event.inputs.swow_ref) || 'develop' }} on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ 'ubuntu-latest' ] | |
php-version: [ '8.0', '8.1', '8.2', '8.3' ] | |
max-parallel: 6 | |
fail-fast: false | |
steps: | |
- name: Checkout self | |
uses: actions/checkout@v2 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-version }} | |
tools: phpize | |
coverage: none | |
extensions: curl,openssl,sockets,pdo | |
- name: Checkout Swow | |
uses: actions/checkout@v2 | |
with: | |
repository: swow/swow | |
ref: ${{ (github.event.inputs && github.event.inputs.swow_ref) || 'develop' }} | |
path: swow | |
- name: Setup extension dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -yqq libcurl4-openssl-dev lcov | |
- name: Build Swow | |
run: | | |
cd swow/ext | |
printf "::group::\033[1mRun phpize\033[0m\n" | |
phpize | |
printf "::group::\033[1mStart configure\033[0m\n" | |
./configure \ | |
--enable-swow-debug \ | |
--enable-swow-ssl \ | |
--enable-swow-curl | |
printf "::group::\033[1mStart build Swow\033[0m\n" | |
make -j`nproc` | |
printf "::group::\033[1mInstall Swow\033[0m\n" | |
sudo make install-modules | |
printf "::group::\033[1mEnable Swow\033[0m\n" | |
inipath=`php --ini | sed -n 's/^Scan for additional .ini files in: //p'` | |
sudo sh -c "echo extension=swow > ${inipath}/swow.ini" | |
php --ri swow | |
- name: Setup Packages | |
run: | | |
composer update -oW | |
- name: Run Server | |
run: | | |
php examples/http_server.php & disown | |
php examples/tcp_server.php & disown | |
php examples/websocket_server.php & disown | |
php examples/udp_server.php & disown | |
php examples/http_server_v2.php & disown | |
- name: Run Test Cases | |
run: | | |
echo "::group::Start testing" | |
composer test | |
macos-tests: | |
name: Test for PHP ${{ matrix.php-version }} with Swow ${{ (github.event.inputs && github.event.inputs.swow_ref) || 'develop' }} on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ 'macos-latest' ] | |
php-version: [ '8.0', '8.1', '8.2', '8.3' ] | |
max-parallel: 32 | |
fail-fast: false | |
steps: | |
- name: Checkout self | |
uses: actions/checkout@v2 | |
- name: Setup extension dependencies | |
run: | | |
brew install pkg-config | |
brew install openssl | |
brew install curl | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-version }} | |
tools: phpize | |
coverage: none | |
extensions: curl,openssl,sockets,pdo | |
- name: Checkout Swow | |
uses: actions/checkout@v2 | |
with: | |
repository: swow/swow | |
ref: ${{ (github.event.inputs && github.event.inputs.swow_ref) || 'develop' }} | |
path: swow | |
- name: Detect dependencies path from php-config | |
run: | | |
echo "OPENSSL_ROOT_DIR=$(php .github/workflows/detect-deps.php openssl)" >> $GITHUB_ENV | |
echo "CURL_ROOT_DIR=$(php .github/workflows/detect-deps.php curl)" >> $GITHUB_ENV | |
- name: Build Swow | |
run: | | |
cd swow/ext | |
printf "::group::\033[1mRun phpize\033[0m\n" | |
phpize | |
printf "::group::\033[1mStart configure\033[0m\n" | |
./configure \ | |
--enable-swow-debug \ | |
--enable-swow-ssl=${{ env.OPENSSL_ROOT_DIR }} \ | |
--enable-swow-curl=${{ env.CURL_ROOT_DIR }} | |
printf "::group::\033[1mStart build Swow\033[0m\n" | |
make -j`sysctl -n hw.logicalcpu` | |
printf "::group::\033[1mInstall Swow\033[0m\n" | |
make install-modules | |
printf "::group::\033[1mEnable Swow\033[0m\n" | |
inipath=`php --ini | sed -n 's/^Scan for additional .ini files in: //p'` | |
sudo sh -c "echo extension=swow > ${inipath}/swow.ini" | |
php --ri swow | |
- name: Setup Packages | |
run: | | |
composer update -oW | |
- name: Run Server | |
run: | | |
php examples/http_server.php & disown | |
php examples/tcp_server.php & disown | |
php examples/websocket_server.php & disown | |
php examples/udp_server.php & disown | |
php examples/http_server_v2.php & disown | |
- name: Run Test Cases | |
run: | | |
echo "::group::Start testing" | |
composer test | |
windows-tests: | |
name: Test for PHP ${{ matrix.php-version }} ${{ matrix.ts }} Swow ${{ (github.event.inputs && github.event.inputs.swow_ref) || 'develop' }} on ${{ matrix.os }} | |
runs-on: "${{ matrix.os }}" | |
strategy: | |
matrix: | |
os: [ 'windows-2019' ] | |
php-version: [ '8.0', '8.1', '8.2', '8.3' ] | |
ts: [ 'nts', 'ts' ] | |
max-parallel: 6 | |
fail-fast: false | |
env: | |
tools_path: C:\tools\phpdev | |
steps: | |
- name: Checkout self | |
uses: actions/checkout@v2 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-version }} | |
coverage: none | |
extensions: curl,openssl | |
env: | |
phpts: ${{ matrix.ts }} | |
- name: Checkout Swow | |
uses: actions/checkout@v2 | |
with: | |
repository: swow/swow | |
ref: ${{ (github.event.inputs && github.event.inputs.swow_ref) || 'develop' }} | |
path: swow | |
- name: Prepare caches | |
id: cacheprepare | |
working-directory: swow | |
env: | |
UNIX_COLOR: 1 | |
run: | | |
. "./.github/workflows/winext/utils.ps1" -ToolName "cacheprepare" -MaxTry 3 | |
$os = "${{ matrix.os }}" | |
if($os.Equals("windows-latest") -Or $os.Equals("windows-2019")){ | |
$PhpVCVer = "VS16" | |
}elseif($os.Equals("windows-2016")){ | |
$PhpVCVer = "VC15" | |
} | |
function phpsdkver{ | |
$headers = @{ | |
"accept"="application/vnd.github.v3+json"; | |
"content-type"="application/json"; | |
"authorization"="Bearer ${{ secrets.GITHUB_TOKEN }}"; | |
} | |
$info = fetchjson -Uri "https://api.github.com/repos/microsoft/php-sdk-binary-tools/git/ref/heads/master" -Headers $headers | |
if(!$info){ | |
warn "Cannot fetch php-sdk-binary-tools info from api.github.com" | |
}else{ | |
$ver = $info."object"."sha" | |
Write-Host "::set-output name=phpsdkver::$ver" | |
} | |
} | |
info "Using $PhpVCVer" | |
$ret = 1 | |
phpsdkver | |
./.github/workflows/winext/devpack.ps1 ` | |
-PhpVer ${{ matrix.php-version }} ` | |
-PhpArch x64 ` | |
-PhpVCVer $PhpVCVer ` | |
-PhpTs ${{ matrix.ts == 'ts' && '1' || '0' }} ` | |
-DryRun 1 && | |
./.github/workflows/winext/deps.ps1 ` | |
openssl,libcurl,libssh2,zlib,nghttp2 ` | |
-DryRun 1 && | |
($ret = 0 | Out-Null) | |
exit $ret | |
- name: Cache build environments | |
uses: actions/cache@v2 | |
with: | |
path: | | |
${{ env.tools_path }}\php-sdk-binary-tools | |
${{ env.tools_path }}\deps\*.zip | |
${{ env.tools_path }}\*.zip | |
key: win-v2-${{ matrix.ts }}-${{ steps.cacheprepare.outputs.devpackver }}-${{ steps.cacheprepare.outputs.downloadeddeps }}-${{ steps.cacheprepare.outputs.phpsdkver }} | |
- name: Build Swow extension | |
uses: ./swow/.github/workflows/winext | |
with: | |
ext-path: ./swow/ext | |
tools-path: ${{ env.tools_path }} | |
conf-args: --enable-swow-debug --enable-swow-ssl --enable-swow-curl | |
ext-name: swow | |
deps: openssl,libcurl,libssh2,zlib,nghttp2 | |
fix-pickle: 1 | |
# we donot enable swow by default in ^ | |
- name: Setup Packages | |
run: composer install -o | |
- name: Run Server | |
shell: powershell | |
run: | | |
# add firewall rule | |
New-NetFirewallRule -DisplayName "allowtests" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 9500-9510 | |
# netsh advfirewall firewall add rule name="allowtests" dir=in action=allow protocol=TCP localport=9500-9510 | |
# use php-win to avoid it get killed when conhost exit | |
Start-Process "php-win.exe" -ArgumentList "-dextension=swow examples/http_server.php" -PassThru | |
Start-Process "php-win.exe" -ArgumentList "-dextension=swow examples/tcp_server.php" -PassThru | |
Start-Process "php-win.exe" -ArgumentList "-dextension=swow examples/websocket_server.php" -PassThru | |
Start-Process "php-win.exe" -ArgumentList "-dextension=swow examples/udp_server.php" -PassThru | |
Start-Process "php-win.exe" -ArgumentList "-dextension=swow examples/http_server_v2.php" -PassThru | |
- name: Run Test Cases | |
shell: powershell | |
run: | | |
Write-Host "::group::Start testing" | |
& composer s-test | |
if( 0 -Ne $LastExitCode){ | |
exit 1 | |
} |