Fix ZTS defination #745
This file contains 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: tests | |
#on: [gollum] | |
on: [push, pull_request] | |
env: | |
SWOW_HAVE_SSL: 1 | |
SWOW_HAVE_CURL: 1 | |
jobs: | |
cs-check: | |
name: Coding style check | |
runs-on: "ubuntu-latest" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Use action to check for CRLF endings | |
uses: erclu/check-crlf@v1 | |
with: | |
path: ./ | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: "8.1" | |
- name: Coding Standards Check | |
shell: bash | |
run: | | |
echo "::group::Accquire composer dependencies" | |
composer update -o --ignore-platform-reqs | |
echo "::endgroup::" | |
echo "::group::Run cs-check" | |
composer cs-check -- -v | |
linux-tests: | |
name: PHP ${{ matrix.php-version }} ${{ matrix.ts }} Test on ubuntu-latest | |
runs-on: "ubuntu-latest" | |
strategy: | |
fail-fast: false | |
matrix: | |
php-version: ['8.3', '8.2', '8.1', '8.0'] | |
#php-version: ['8.0'] | |
#ts: ['nts', 'ts'] | |
max-parallel: 3 | |
services: | |
postgres: | |
image: postgres | |
ports: | |
- 5432:5432 | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup extension dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -yqq libcurl4-openssl-dev lcov | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-version }} | |
tools: phpize | |
ini-values: pcov.enabled = 0 | |
coverage: pcov | |
# coverage: none | |
extensions: curl,openssl,sockets,ffi,pdo,pdo_pgsql | |
#env: | |
#phpts: ${{ matrix.ts }} | |
- name: Setup composer dependencies | |
run: composer update -o --ignore-platform-reqs | |
- name: Build Swow extension | |
run: | | |
cd ext | |
printf "\033[1mRun phpize\033[0m\n" | |
phpize | |
printf "\033[1mStart configure\033[0m\n" | |
./configure --enable-swow\ | |
--enable-swow-debug \ | |
--enable-swow-gcov \ | |
--enable-swow-ssl \ | |
--enable-swow-curl \ | |
--enable-swow-pdo-pgsql | |
printf "\033[1mStart build Swow\033[0m\n" | |
make -j`nproc` | |
printf "\033[1mDone build Swow\033[0m\n" | |
php -d extension=.libs/swow.so --ri swow | |
printf "\033[1mInstall Swow\033[0m\n" | |
sudo make install-modules | |
- name: Run extension tests | |
id: test-extension | |
continue-on-error: true | |
run: | | |
TEST_SWOW_POSTGRESQL=1 composer test-extension | |
- name: Run library tests | |
id: test-library | |
continue-on-error: true | |
run: php --ri pcov && composer test-library-with-pcov | |
- name: Fail if test-extension failed | |
if: steps.test-extension.outcome != 'success' | |
run: exit 1 | |
- name: Fail if test-library failed | |
if: steps.test-library.outcome != 'success' | |
run: exit 1 | |
- name: Coverage ext tests | |
shell: bash | |
run: | | |
lcov \ | |
--capture \ | |
--directory "ext/src" \ | |
--directory "ext/include" \ | |
--output-file coverage.info && | |
lcov \ | |
--extract coverage.info \ | |
"${{github.workspace}}/ext/include/*" \ | |
"${{github.workspace}}/ext/src/*" \ | |
--output-file coverage.info && | |
lcov --list coverage.info && | |
curl -s https://codecov.io/bash -o codecov.sh && | |
chmod +x codecov.sh && | |
./codecov.sh -f coverage.info | |
- name: Coverage phpunit tests | |
shell: bash | |
run: | | |
curl -s https://codecov.io/bash -o codecov.sh && | |
chmod +x codecov.sh && | |
./codecov.sh -f ./lib/swow-library/build/coverage.xml | |
macos-tests: | |
name: PHP ${{ matrix.php-version }} ${{ matrix.ts }} Test on macos-latest | |
runs-on: "macos-latest" | |
strategy: | |
fail-fast: false | |
matrix: | |
php-version: ['8.3', '8.2', '8.1', '8.0'] | |
#php-version: ['8.0'] | |
#ts: ['nts', 'ts'] | |
max-parallel: 3 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup extension dependencies | |
run: | | |
brew install pkg-config | |
brew install openssl@1.1 | |
brew install curl | |
brew install lcov | |
brew install libpq postgresql | |
initdb --locale=C -E UTF-8 -U postgres "$HOME/pgsqldata" | |
pg_ctl -D "$HOME/pgsqldata" start | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-version }} | |
tools: phpize | |
ini-values: pcov.enabled = 0 | |
coverage: pcov | |
# coverage: none | |
extensions: curl,openssl,sockets,ffi,pdo,pdo_pgsql | |
#env: | |
#phpts: ${{ matrix.ts }} | |
- name: Setup composer dependencies | |
run: composer update -o --ignore-platform-reqs | |
- 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 | |
echo "PGSQL_ROOT_DIR=$(php .github/workflows/detect-deps.php libpq)" >> $GITHUB_ENV | |
- name: Build Swow extension | |
run: | | |
cd ext | |
printf "\033[1mRun phpize\033[0m\n" | |
phpize | |
printf "\033[1mStart configure\033[0m\n" | |
./configure --enable-swow\ | |
--enable-swow-debug \ | |
--enable-swow-gcov \ | |
--enable-swow-ssl=${{ env.OPENSSL_ROOT_DIR }} \ | |
--enable-swow-curl=${{ env.CURL_ROOT_DIR }} \ | |
--enable-swow-pdo-pgsql=${{ env.PGSQL_ROOT_DIR }} | |
printf "\033[1mStart build Swow\033[0m\n" | |
make -j`sysctl -n hw.logicalcpu` | |
printf "\033[1mDone build Swow\033[0m\n" | |
php -d extension=.libs/swow.so --ri swow | |
printf "\033[1mInstall Swow\033[0m\n" | |
make install-modules | |
- name: Run extension tests | |
id: test-extension | |
continue-on-error: true | |
run: | | |
TEST_SWOW_POSTGRESQL=1 composer test-extension | |
- name: Run library tests | |
id: test-library | |
continue-on-error: true | |
run: php --ri pcov && composer test-library-with-pcov | |
- name: Fail if test-extension failed | |
if: steps.test-extension.outcome != 'success' | |
run: exit 1 | |
- name: Fail if test-library failed | |
if: steps.test-library.outcome != 'success' | |
run: exit 1 | |
- name: Coverage ext tests | |
shell: bash | |
run: | | |
lcov \ | |
--capture \ | |
--directory "ext/src" \ | |
--directory "ext/include" \ | |
--ignore-errors empty \ | |
--output-file coverage.info && | |
lcov \ | |
--extract coverage.info \ | |
"${{github.workspace}}/ext/include/*" \ | |
"${{github.workspace}}/ext/src/*" \ | |
--output-file coverage.info && | |
lcov --list coverage.info && | |
curl -s https://codecov.io/bash -o codecov.sh && | |
chmod +x codecov.sh && | |
./codecov.sh -f coverage.info | |
- name: Coverage phpunit tests | |
shell: bash | |
run: | | |
curl -s https://codecov.io/bash -o codecov.sh && | |
chmod +x codecov.sh && | |
./codecov.sh -f ./lib/swow-library/build/coverage.xml | |
windows-tests: | |
name: PHP ${{ matrix.php-version }} ${{ matrix.ts }} Test on windows-2019 | |
runs-on: windows-2019 | |
strategy: | |
fail-fast: false | |
matrix: | |
php-version: ["8.3", "8.2", "8.1", "8.0"] | |
ts: [ 'nts', 'ts' ] | |
max-parallel: 8 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# TODO: windows varient of setup-php seems to be so slow | |
# shell we add caches? | |
- name: Setup PHP | |
uses: shivammathur/setup-php@master | |
with: | |
php-version: ${{ matrix.php-version }} | |
# ini-values: pcov.directory=lib | |
# coverage: pcov | |
coverage: none | |
extensions: curl,openssl,sockets,ffi,pdo,pdo_pgsql | |
env: | |
phpts: ${{ matrix.ts }} | |
- name: Setup composer dependencies | |
run: composer update -o --ignore-platform-reqs | |
- name: Build Swow extension | |
uses: ./.github/workflows/winext | |
with: | |
ext-path: ./ext | |
tools-path: C:\tools\phpdev | |
conf-args: --enable-swow-debug --enable-swow-ssl --enable-swow-curl --enable-debug-pack --enable-swow-pdo-pgsql | |
ext-name: swow | |
deps: openssl,libcurl,libssh2,zlib,nghttp2,libpq | |
- name: Prepare coverage dependencies | |
shell: powershell | |
run: | | |
$headers = @{ | |
"accept"="application/vnd.github.v3+json"; | |
"content-type"="application/json"; | |
"authorization"="Bearer ${{github.token}}"; | |
} | |
# get latest OpenCppCoverage download path | |
Write-Host "Fetching latest OpenCppCoverage download path" | |
$info = Invoke-WebRequest ` | |
-UseBasicParsing ` | |
-Headers $headers ` | |
-Uri https://api.github.com/repos/OpenCppCoverage/OpenCppCoverage/releases/latest ` | |
| ConvertFrom-Json | |
foreach ($x in $info.assets) { | |
if ($x.name.EndsWith('.exe')) { | |
Write-Host "Downloading latest OpenCppCoverage" | |
$uri = $x.browser_download_url | |
Invoke-WebRequest -Uri $uri -OutFile OpenCppCoverage.exe -Headers $headers -UseBasicParsing | |
break | |
} | |
} | |
# install OpenCppCoverage | |
Write-Host "Installing OpenCppCoverage" | |
& .\OpenCppCoverage.exe /SP- /NORESTART /VERYSILENT /DIR=C:\OpenCppCoverage | |
# get latest codecov uploader download path | |
Write-Host "Fetching latest codecov uploader download path" | |
$info = Invoke-WebRequest ` | |
-UseBasicParsing ` | |
-Headers $headers ` | |
-Uri https://api.github.com/repos/codecov/codecov-exe/releases/latest ` | |
| ConvertFrom-Json | |
foreach ($x in $info.assets) { | |
if ($x.name.EndsWith('win7-x64.zip')) { | |
Write-Host "Downloading latest codecov uploader" | |
$uri = $x.browser_download_url | |
Invoke-WebRequest -Uri $uri -OutFile codecov.zip -Headers $headers -UseBasicParsing | |
break | |
} | |
} | |
# unzip it | |
Write-Host "Extracting codecov uploader" | |
New-Item C:\Codecov -ItemType Container | Out-Null | |
Expand-Archive .\codecov.zip -DestinationPath C:\Codecov | |
- name: Run extension tests | |
shell: pwsh | |
id: test-extension | |
continue-on-error: true | |
run: | | |
& "${env:PGBIN}\initdb.exe" --locale=C -E UTF-8 -U postgres "C:\pgsqldata" | |
& "${env:PGBIN}\pg_ctl.exe" -D "C:\pgsqldata" start | |
${env:TEST_SWOW_POSTGRESQL} = "1" | |
& C:\OpenCppCoverage\OpenCppCoverage.exe ` | |
--export_type binary:ext_test.cov ` | |
--sources ext\include ` | |
--sources ext\src ` | |
--excluded_sources ext\deps ` | |
--cover_children ` | |
--excluded_line_regex "\s*else.*" ` | |
--excluded_line_regex "\s*\}.*" ` | |
--excluded_line_regex "\s*\{\s*" ` | |
--modules php_swow.dll ` | |
-- C:\tools\php\php.exe C:\tools\php\composer.phar test-extension | |
- name: Run library tests | |
shell: pwsh | |
id: test-library | |
continue-on-error: true | |
run: | | |
& C:\OpenCppCoverage\OpenCppCoverage.exe ` | |
--export_type binary:lib_test.cov ` | |
--sources ext\include ` | |
--sources ext\src ` | |
--excluded_sources ext\deps ` | |
--cover_children ` | |
--excluded_line_regex "\s*else.*" ` | |
--excluded_line_regex "\s*\}.*" ` | |
--excluded_line_regex "\s*\{\s*" ` | |
--modules php_swow.dll ` | |
-- C:\tools\php\php.exe C:\tools\php\composer.phar test-library | |
- name: Fail if test-extension failed | |
if: steps.test-extension.outcome != 'success' | |
run: exit 1 | |
- name: Fail if test-library failed | |
if: steps.test-library.outcome != 'success' | |
run: exit 1 | |
- name: Upload coverage tests results | |
shell: pwsh | |
run: | | |
# merge results | |
& C:\OpenCppCoverage\OpenCppCoverage.exe ` | |
--input_coverage=ext_test.cov ` | |
--input_coverage=lib_test.cov ` | |
--export_type cobertura:coverage.xml ` | |
--sources ext\include ` | |
--sources ext\src ` | |
--excluded_sources ext\deps ` | |
--excluded_line_regex "\s*else.*" ` | |
--excluded_line_regex "\s*\}.*" ` | |
--excluded_line_regex "\s*\{\s*" ` | |
--modules php_swow.dll ` | |
-- C:\tools\php\php.exe -dextension=swow --ri swow | |
& C:\Codecov\codecov.exe -f coverage.xml |