Skip to content

Commit

Permalink
Fixed issue #1493: Run test suite on Windows by using AppVeyor CI
Browse files Browse the repository at this point in the history
  • Loading branch information
derickr committed Dec 3, 2017
1 parent 2108228 commit 5bf79e0
Show file tree
Hide file tree
Showing 6 changed files with 277 additions and 0 deletions.
82 changes: 82 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
image: Visual Studio 2015
version: '{branch}.{build}'

cache:
- c:\build-cache -> .appveyor.yml
- c:\build-cache\sdk -> .appveyor.yml

environment:
PHP_BUILD_CACHE_BASE_DIR: c:\build-cache
PHP_BUILD_OBJ_DIR: c:\obj
PHP_BUILD_CACHE_SDK_DIR: c:\build-cache\sdk
PHP_BUILD_SDK_BRANCH: php-sdk-2.0.10
SDK_REMOTE: https://github.com/OSTC/php-sdk-binary-tools.git
SDK_BRANCH: php-sdk-2.0.10

matrix:
- PHP_REL: 7.2
ARCHITECTURE: x64
ZTS_STATE: enable
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
PHP_BUILD_CRT: vc15
- PHP_REL: 7.1
ARCHITECTURE: x64
ZTS_STATE: enable
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
PHP_BUILD_CRT: vc14
- PHP_REL: 7.0
ARCHITECTURE: x64
ZTS_STATE: enable
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
PHP_BUILD_CRT: vc14
- PHP_REL: 7.2
ARCHITECTURE: x64
ZTS_STATE: disable
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
PHP_BUILD_CRT: vc15
- PHP_REL: 7.1
ARCHITECTURE: x64
ZTS_STATE: disable
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
PHP_BUILD_CRT: vc14
- PHP_REL: 7.0
ARCHITECTURE: x64
ZTS_STATE: disable
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
PHP_BUILD_CRT: vc14
- PHP_REL: 7.2
ARCHITECTURE: x86
ZTS_STATE: enable
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
PHP_BUILD_CRT: vc15
- PHP_REL: 7.1
ARCHITECTURE: x86
ZTS_STATE: enable
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
PHP_BUILD_CRT: vc14
- PHP_REL: 7.0
ARCHITECTURE: x86
ZTS_STATE: enable
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
PHP_BUILD_CRT: vc14
- PHP_REL: 7.2
ARCHITECTURE: x86
ZTS_STATE: disable
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
PHP_BUILD_CRT: vc15
- PHP_REL: 7.1
ARCHITECTURE: x86
ZTS_STATE: disable
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
PHP_BUILD_CRT: vc14
- PHP_REL: 7.0
ARCHITECTURE: x86
ZTS_STATE: disable
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
PHP_BUILD_CRT: vc14

install:
- .appveyor\install.cmd

build_script:
- .appveyor\build.cmd
15 changes: 15 additions & 0 deletions .appveyor/build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@echo off

setlocal enableextensions enabledelayedexpansion
set SDK_RUNNER=%PHP_BUILD_CACHE_SDK_DIR%\phpsdk-%PHP_BUILD_CRT%-%ARCHITECTURE%.bat
if not exist "!SDK_RUNNER!" (
echo "!SDK_RUNNER!" doesn't exist
exit /b 3
)

cmd /c !SDK_RUNNER! -t %APPVEYOR_BUILD_FOLDER%\.appveyor\build_task.cmd

if %errorlevel% neq 0 exit /b 3
endlocal

exit /b 0
72 changes: 72 additions & 0 deletions .appveyor/build_task.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
@echo off
setlocal enableextensions enabledelayedexpansion

cd /D %APPVEYOR_BUILD_FOLDER%
if %errorlevel% neq 0 exit /b 3

set STABILITY=staging
set DEPS_DIR=%PHP_BUILD_CACHE_BASE_DIR%\deps-%PHP_REL%-%PHP_SDK_VC%-%PHP_SDK_ARCH%
rem SDK is cached, deps info is cached as well
echo Updating dependencies in %DEPS_DIR%
cmd /c phpsdk_deps --update --no-backup --branch %PHP_REL% --stability %STABILITY% --deps %DEPS_DIR%
if %errorlevel% neq 0 exit /b 3

rem Something went wrong, most likely when concurrent builds were to fetch deps
rem updates. It might be, that some locking mechanism is needed.
if not exist "%DEPS_DIR%" (
cmd /c phpsdk_deps --update --force --no-backup --branch %PHP_REL% --stability %STABILITY% --deps %DEPS_DIR%
)
if %errorlevel% neq 0 exit /b 3

if "%ZTS_STATE%"=="enable" set ZTS_SHORT=ts
if "%ZTS_STATE%"=="disable" set ZTS_SHORT=nts
if "%ZTS_STATE%"=="enable" set ZTS_IN_FILENAME=
if "%ZTS_STATE%"=="disable" set ZTS_IN_FILENAME=-nts
if "%PHP_SDK_ARCH%"=="x86" set ARCH_IN_FILENAME=
if "%PHP_SDK_ARCH%"=="x64" set ARCH_IN_FILENAME=-x86_64

cd /d C:\projects\php-src

cmd /c buildconf.bat --force

if %errorlevel% neq 0 exit /b 3

cmd /c configure.bat --disable-all --with-mp=auto --enable-cli --%ZTS_STATE%-zts --with-xdebug=shared --enable-object-out-dir=%PHP_BUILD_OBJ_DIR% --with-config-file-scan-dir=%APPVEYOR_BUILD_FOLDER%\build\modules.d --with-prefix=%APPVEYOR_BUILD_FOLDER%\build --with-php-build=%DEPS_DIR%

if %errorlevel% neq 0 exit /b 3

nmake /NOLOGO
if %errorlevel% neq 0 exit /b 3

nmake install

if %errorlevel% neq 0 exit /b 3

mkdir c:\tests_tmp
set TEST_PHP_EXECUTABLE=%APPVEYOR_BUILD_FOLDER%\build\php.exe
set TEST_PHP_JUNIT=c:\tests_tmp\tests-junit.xml
if "%OPCACHE%" equ "1" set TEST_PHP_ARGS=!TEST_PHP_ARGS! -d zend_extension=%APPVEYOR_BUILD_FOLDER%\build\ext\php_opcache.so -d opcache.enable=1 -d opcache.enable_cli=1
set TEST_PHP_ARGS=-n -d -foo=1 -d zend_extension=%APPVEYOR_BUILD_FOLDER%\build\ext\php_xdebug.dll -dxdebug.remote_enable=1
set SKIP_DBGP_TESTS=1
set SKIP_IPV6_TESTS=1
set REPORT_EXIT_STATUS=1
echo !TEST_PHP_EXECUTABLE! !TEST_PHP_ARGS! -v
echo !TEST_PHP_EXECUTABLE! -n run-tests.php -q -x --show-diff %APPVEYOR_BUILD_FOLDER%\tests
!TEST_PHP_EXECUTABLE! !TEST_PHP_ARGS! -v
!TEST_PHP_EXECUTABLE! -n run-tests.php -q -x --show-diff %APPVEYOR_BUILD_FOLDER%\tests

set EXIT_CODE=%errorlevel%
powershell -Command "$wc = New-Object 'System.Net.WebClient'; $wc.UploadFile('https://ci.appveyor.com/api/testresults/junit/%APPVEYOR_JOB_ID%', 'c:\tests_tmp\tests-junit.xml')"
if %EXIT_CODE% neq 0 exit /b 3

cd /d %APPVEYOR_BUILD_FOLDER%

if not exist "%APPVEYOR_BUILD_FOLDER%\build\ext\php_xdebug.dll" exit /b 3

xcopy %APPVEYOR_BUILD_FOLDER%\LICENSE %APPVEYOR_BUILD_FOLDER%\php_xdebug-%PHP_REL%-!ZTS_SHORT!-%PHP_BUILD_CRT%-%PHP_SDK_ARCH%\ /y /f
echo F|xcopy %APPVEYOR_BUILD_FOLDER%\build\ext\php_xdebug.dll %APPVEYOR_BUILD_FOLDER%\php_xdebug-%PHP_REL%-!ZTS_SHORT!-%PHP_BUILD_CRT%-%PHP_SDK_ARCH%\php_xdebug-%APPVEYOR_REPO_TAG_NAME%-%PHP_REL%-%PHP_BUILD_CRT%!ZTS_IN_FILENAME!!ARCH_IN_FILENAME!.dll /y /f
7z a php_xdebug-%APPVEYOR_REPO_TAG_NAME%-%PHP_REL%-%PHP_BUILD_CRT%!ZTS_IN_FILENAME!!ARCH_IN_FILENAME!.zip %APPVEYOR_BUILD_FOLDER%\php_xdebug-%PHP_REL%-!ZTS_SHORT!-%PHP_BUILD_CRT%-%PHP_SDK_ARCH%\*
appveyor PushArtifact php_xdebug-%APPVEYOR_REPO_TAG_NAME%-%PHP_REL%-%PHP_BUILD_CRT%!ZTS_IN_FILENAME!!ARCH_IN_FILENAME!.zip -FileName php_xdebug-%APPVEYOR_REPO_TAG_NAME%-%PHP_REL%-%PHP_BUILD_CRT%!ZTS_IN_FILENAME!!ARCH_IN_FILENAME!.zip

rem move build\ext\php_xdebug.dll artifacts\php_xdebug-%PHP_REL%-!ZTS_SHORT!-%PHP_BUILD_CRT%-%PHP_SDK_ARCH%.dll
endlocal
61 changes: 61 additions & 0 deletions .appveyor/install.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
@echo off
setlocal enableextensions enabledelayedexpansion
cinst wget

if not exist "%PHP_BUILD_CACHE_BASE_DIR%" (
echo Creating %PHP_BUILD_CACHE_BASE_DIR%
mkdir "%PHP_BUILD_CACHE_BASE_DIR%"
)

if not exist "%PHP_BUILD_OBJ_DIR%" (
echo Creating %PHP_BUILD_OBJ_DIR%
mkdir "%PHP_BUILD_OBJ_DIR%"
)

if not exist "%PHP_BUILD_CACHE_SDK_DIR%" (
echo Cloning remote SDK repository
rem git clone -q --depth=1 --branch %SDK_BRANCH% %SDK_REMOTE% "%PHP_BUILD_CACHE_SDK_DIR%" 2>&1
git clone --branch %SDK_BRANCH% %SDK_REMOTE% "%PHP_BUILD_CACHE_SDK_DIR%" 2>&1
) else (
echo Fetching remote SDK repository
git --git-dir="%PHP_BUILD_CACHE_SDK_DIR%\.git" --work-tree="%PHP_BUILD_CACHE_SDK_DIR%" fetch --prune origin 2>&1
echo Checkout SDK repository branch
git --git-dir="%PHP_BUILD_CACHE_SDK_DIR%\.git" --work-tree="%PHP_BUILD_CACHE_SDK_DIR%" checkout --force %SDK_BRANCH%
)

if "%PHP_REL%"=="master" (
echo git clone -q --depth=1 --branch=%PHP_REL% https://github.com/php/php-src C:\projects\php-src
git clone -q --depth=1 --branch=%PHP_REL% https://github.com/php/php-src C:\projects\php-src
) else (
echo git clone -q --depth=1 --branch=PHP-%PHP_REL% https://github.com/php/php-src C:\projects\php-src
git clone -q --depth=1 --branch=PHP-%PHP_REL% https://github.com/php/php-src C:\projects\php-src
)

xcopy %APPVEYOR_BUILD_FOLDER% C:\projects\php-src\ext\xdebug\ /s /e /y /f

xcopy %APPVEYOR_BUILD_FOLDER%\LICENSE %APPVEYOR_BUILD_FOLDER%\artifacts\ /y /f

if "%APPVEYOR%" equ "True" rmdir /s /q C:\cygwin >NUL 2>NUL
if %errorlevel% neq 0 exit /b 3
if "%APPVEYOR%" equ "True" rmdir /s /q C:\cygwin64 >NUL 2>NUL
if %errorlevel% neq 0 exit /b 3
if "%APPVEYOR%" equ "True" rmdir /s /q C:\mingw >NUL 2>NUL
if %errorlevel% neq 0 exit /b 3
if "%APPVEYOR%" equ "True" rmdir /s /q C:\mingw-w64 >NUL 2>NUL
if %errorlevel% neq 0 exit /b 3

if "%APPVEYOR_REPO_TAG_NAME%"=="" (
set APPVEYOR_REPO_TAG_NAME=%APPVEYOR_REPO_BRANCH%-%APPVEYOR_REPO_COMMIT:~0,8%
for /f "delims=" %%l in (php_xdebug.h) do (
if not "%%l"=="" (
set line=%%l
if "!line:~8,14!"=="XDEBUG_VERSION" (
set APPVEYOR_REPO_TAG_NAME=!line:~27,-1!-%APPVEYOR_REPO_BRANCH%-%APPVEYOR_REPO_COMMIT:~0,8%
)
)
)
echo Final repo tag name: !APPVEYOR_REPO_TAG_NAME!

appveyor SetVariable -Name APPVEYOR_REPO_TAG_NAME -Value !APPVEYOR_REPO_TAG_NAME!
)
endlocal
15 changes: 15 additions & 0 deletions .appveyor/test.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@echo off

setlocal enableextensions enabledelayedexpansion
set SDK_RUNNER=%PHP_BUILD_CACHE_SDK_DIR%\phpsdk-%PHP_BUILD_CRT%-%ARCHITECTURE%.bat
if not exist "!SDK_RUNNER!" (
echo "!SDK_RUNNER!" doesn't exist
exit /b 3
)

cmd /c !SDK_RUNNER! -t %APPVEYOR_BUILD_FOLDER%\.appveyor\test_task.cmd

if %errorlevel% neq 0 exit /b 3
endlocal

exit /b 0
32 changes: 32 additions & 0 deletions .appveyor/test_task.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@echo off

set NO_INTERACTION=1
set REPORT_EXIT_STATUS=1
set SKIP_IO_CAPTURE_TESTS=1

if /i "%APPVEYOR_REPO_BRANCH:~0,7%" equ "XDEBUG_" (
set BRANCH=%APPVEYOR_REPO_BRANCH:~7,3%
set STABILITY=stable
) else (
set BRANCH=master
set STABILITY=staging
)

set BRANCH=%PHP_REL%

set DEPS_DIR=%PHP_BUILD_CACHE_BASE_DIR%\deps-%BRANCH%-%PHP_SDK_VC%-%PHP_SDK_ARCH%
if not exist "%DEPS_DIR%" (
echo "%DEPS_DIR%" doesn't exist
exit /b 3
)

rem prepare for Opcache
if "%OPCACHE%" equ "1" set OPCACHE_OPTS=-d opcache.enabled=1 -d opcache.enable_cli=1

mkdir c:\tests_tmp

cd "%APPVEYOR_BUILD_FOLDER%"
nmake test TESTS="%OPCACHE_OPTS% -q --offline --show-diff --show-slow 1000 --set-timeout 120 -g FAIL,XFAIL,BORK,WARN,LEAK,SKIP --temp-source c:\tests_tmp --temp-target c:\tests_tmp"

exit /b %errorlevel%

0 comments on commit 5bf79e0

Please sign in to comment.