From 202216b98ce5048f82bc86d115003e39981b5041 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Sat, 12 Nov 2022 18:48:02 +0100 Subject: [PATCH] Add Windows GitHub actions build --- .github/scripts/windows/build.bat | 2 +- .github/scripts/windows/build_task.bat | 20 +++--- .../scripts/windows/find-target-branch.bat | 8 +++ .github/scripts/windows/test.bat | 2 +- .github/scripts/windows/test_task.bat | 71 +++++++++++-------- .github/workflows/push.yml | 41 +++++++++++ ext/gd/tests/bug77269.phpt | 1 + ext/gd/tests/bug77272.phpt | 1 + ext/sysvshm/tests/bug72858.phpt | 1 + 9 files changed, 103 insertions(+), 44 deletions(-) create mode 100644 .github/scripts/windows/find-target-branch.bat diff --git a/.github/scripts/windows/build.bat b/.github/scripts/windows/build.bat index cb85f605c610e..5f29baefabad0 100644 --- a/.github/scripts/windows/build.bat +++ b/.github/scripts/windows/build.bat @@ -38,7 +38,7 @@ if not exist "%SDK_RUNNER%" ( exit /b 3 ) -cmd /c %SDK_RUNNER% -t %APPVEYOR_BUILD_FOLDER%\.github\scripts\windows\build_task.bat +cmd /c %SDK_RUNNER% -t .github\scripts\windows\build_task.bat if %errorlevel% neq 0 exit /b 3 exit /b 0 diff --git a/.github/scripts/windows/build_task.bat b/.github/scripts/windows/build_task.bat index 61e3042fadd28..dde252d2ef7c2 100644 --- a/.github/scripts/windows/build_task.bat +++ b/.github/scripts/windows/build_task.bat @@ -18,19 +18,12 @@ if "%APPVEYOR%" equ "True" rmdir /s /q c:\OpenSSL-v11-Win32 >NUL 2>NUL if %errorlevel% neq 0 exit /b 3 if "%APPVEYOR%" equ "True" rmdir /s /q c:\OpenSSL-v11-Win64 >NUL 2>NUL if %errorlevel% neq 0 exit /b 3 -if "%APPVEYOR%" equ "True" del /f /q C:\Windows\System32\libcrypto-1_1-x64.dll >NUL 2>NUL +del /f /q C:\Windows\System32\libcrypto-1_1-x64.dll >NUL 2>NUL if %errorlevel% neq 0 exit /b 3 -if "%APPVEYOR%" equ "True" del /f /q C:\Windows\System32\libssl-1_1-x64.dll >NUL 2>NUL +del /f /q C:\Windows\System32\libssl-1_1-x64.dll >NUL 2>NUL if %errorlevel% neq 0 exit /b 3 -cd /D %APPVEYOR_BUILD_FOLDER% -if %errorlevel% neq 0 exit /b 3 - -if /i "%APPVEYOR_REPO_BRANCH:~0,4%" equ "php-" ( - set BRANCH=%APPVEYOR_REPO_BRANCH:~4,3% -) else ( - set BRANCH=master -) +call %~dp0find-target-branch.bat set STABILITY=staging set DEPS_DIR=%PHP_BUILD_CACHE_BASE_DIR%\deps-%BRANCH%-%PHP_SDK_VS%-%PHP_SDK_ARCH% rem SDK is cached, deps info is cached as well @@ -51,7 +44,12 @@ if %errorlevel% neq 0 exit /b 3 if "%THREAD_SAFE%" equ "0" set ADD_CONF=%ADD_CONF% --disable-zts if "%INTRINSICS%" neq "" set ADD_CONF=%ADD_CONF% --enable-native-intrinsics=%INTRINSICS% -set CFLAGS=/W1 /WX +rem Some undefined behavior is reported on 32-bit, this should be fixed +if "%PLATFORM%" == "x86" ( + set CFLAGS=/W1 +) else ( + set CFLAGS=/W1 /WX +) cmd /c configure.bat ^ --enable-snapshot-build ^ diff --git a/.github/scripts/windows/find-target-branch.bat b/.github/scripts/windows/find-target-branch.bat new file mode 100644 index 0000000000000..43b285214971c --- /dev/null +++ b/.github/scripts/windows/find-target-branch.bat @@ -0,0 +1,8 @@ +@echo off + +for /f "usebackq tokens=3" %%i in (`findstr PHP_MAJOR_VERSION main\php_version.h`) do set BRANCH=%%i +for /f "usebackq tokens=3" %%i in (`findstr PHP_MINOR_VERSION main\php_version.h`) do set BRANCH=%BRANCH%.%%i + +if /i "%BRANCH%" equ "8.3" ( + set BRANCH=master +) diff --git a/.github/scripts/windows/test.bat b/.github/scripts/windows/test.bat index f51a14b9dc64c..24ee260464fde 100644 --- a/.github/scripts/windows/test.bat +++ b/.github/scripts/windows/test.bat @@ -6,7 +6,7 @@ if not exist "%SDK_RUNNER%" ( exit /b 3 ) -cmd /c %SDK_RUNNER% -t %APPVEYOR_BUILD_FOLDER%\.github\scripts\windows\test_task.bat +cmd /c %SDK_RUNNER% -t .github\scripts\windows\test_task.bat if %errorlevel% neq 0 exit /b 3 exit /b 0 diff --git a/.github/scripts/windows/test_task.bat b/.github/scripts/windows/test_task.bat index 39f0eb07c048a..bca81878527e6 100644 --- a/.github/scripts/windows/test_task.bat +++ b/.github/scripts/windows/test_task.bat @@ -4,11 +4,10 @@ set NO_INTERACTION=1 set REPORT_EXIT_STATUS=1 set SKIP_IO_CAPTURE_TESTS=1 -if /i "%APPVEYOR_REPO_BRANCH:~0,4%" equ "php-" ( - set BRANCH=%APPVEYOR_REPO_BRANCH:~4,3% +call %~dp0find-target-branch.bat +if "%BRANCH%" neq "master" ( set STABILITY=stable ) else ( - set BRANCH=master set STABILITY=staging ) set DEPS_DIR=%PHP_BUILD_CACHE_BASE_DIR%\deps-%BRANCH%-%PHP_SDK_VS%-%PHP_SDK_ARCH% @@ -28,7 +27,12 @@ set PDO_MYSQL_TEST_PASS=%MYSQL_PWD% set PDO_MYSQL_TEST_HOST=%MYSQL_TEST_HOST% set PDO_MYSQL_TEST_PORT=%MYSQL_TEST_PORT% set PDO_MYSQL_TEST_DSN=mysql:host=%PDO_MYSQL_TEST_HOST%;port=%PDO_MYSQL_TEST_PORT%;dbname=test -"C:\Program Files\MySql\MySQL Server 5.7\bin\mysql.exe" --user=%MYSQL_TEST_USER% -e "CREATE DATABASE IF NOT EXISTS test" +if /i "%APPVEYOR%" equ "True" ( + set TMP_MYSQL_BIN=%ProgramFiles%\MySql\MySQL Server 5.7\bin +) else ( + set TMP_MYSQL_BIN=C:\mysql\bin +) +"%TMP_MYSQL_BIN%\mysql.exe" --host=%PDO_MYSQL_TEST_HOST% --port=%MYSQL_TEST_PORT% --user=%MYSQL_TEST_USER% --password=%MYSQL_TEST_PASSWD% -e "CREATE DATABASE IF NOT EXISTS test" if %errorlevel% neq 0 exit /b 3 rem setup PostgreSQL related exts @@ -37,23 +41,35 @@ set PGPASSWORD=Password12! rem set PGSQL_TEST_CONNSTR=host=127.0.0.1 dbname=test port=5432 user=postgres password=Password12! echo ^ >> "./ext/pgsql/tests/config.inc" set PDO_PGSQL_TEST_DSN=pgsql:host=127.0.0.1 port=5432 dbname=test user=%PGUSER% password=%PGPASSWORD% -"C:\Program Files\PostgreSQL\10\bin\createdb.exe" test +if /i "%APPVEYOR%" equ "True" ( + set TMP_POSTGRESQL_BIN=%ProgramFiles%\PostgreSQL\10\bin +) else ( + set TMP_POSTGRESQL_BIN=%PGBIN% +) +"%TMP_POSTGRESQL_BIN%\createdb.exe" test if %errorlevel% neq 0 exit /b 3 rem setup ODBC related exts set ODBC_TEST_USER=sa set ODBC_TEST_PASS=Password12! -set ODBC_TEST_DSN=Driver={ODBC Driver 13 for SQL Server};Server=(local)\SQL2017;Database=master;uid=%ODBC_TEST_USER%;pwd=%ODBC_TEST_PASS% +if /i "%APPVEYOR%" equ "True" ( + set ODBC_TEST_DSN=Driver={ODBC Driver 13 for SQL Server};Server=^(local^)\SQL2017;Database=master;uid=%ODBC_TEST_USER%;pwd=%ODBC_TEST_PASS% +) else ( + set ODBC_TEST_DSN=Driver={ODBC Driver 17 for SQL Server};Server=^(local^)\SQLEXPRESS;Database=master;uid=%ODBC_TEST_USER%;pwd=%ODBC_TEST_PASS% +) set PDOTEST_DSN=odbc:%ODBC_TEST_DSN% rem prepare for ext/openssl -if "%APPVEYOR%" equ "True" rmdir /s /q C:\OpenSSL-Win32 >NUL 2>NUL -if "%APPVEYOR%" equ "True" rmdir /s /q C:\OpenSSL-Win64 >NUL 2>NUL +rmdir /s /q C:\OpenSSL-Win32 >NUL 2>NUL +rmdir /s /q C:\OpenSSL-Win64 >NUL 2>NUL if "%PLATFORM%" == "x64" ( set OPENSSLDIR="C:\Program Files\Common Files\SSL" ) else ( set OPENSSLDIR="C:\Program Files (x86)\Common Files\SSL" ) +if /i "%GITHUB_ACTIONS%" equ "True" ( + rmdir /s /q %OPENSSLDIR% >nul 2>&1 +) mkdir %OPENSSLDIR% if %errorlevel% neq 0 exit /b 3 copy %DEPS_DIR%\template\ssl\openssl.cnf %OPENSSLDIR% @@ -68,28 +84,18 @@ rem work-around for failing to dl(mysqli) with OPcache (https://github.com/php/p if "%OPCACHE%" equ "1" set OPCACHE_OPTS=%OPCACHE_OPTS% -d extension=mysqli rem prepare for enchant -mkdir C:\usr\local\lib\enchant-2 +mkdir %~d0\usr\local\lib\enchant-2 if %errorlevel% neq 0 exit /b 3 -copy %DEPS_DIR%\bin\libenchant2_hunspell.dll C:\usr\local\lib\enchant-2 +copy %DEPS_DIR%\bin\libenchant2_hunspell.dll %~d0\usr\local\lib\enchant-2 if %errorlevel% neq 0 exit /b 3 -reg add HKEY_CURRENT_USER\SOFTWARE\Enchant\Config /v Module_Dir /t REG_SZ /d c:\enchant_plugins +mkdir %~d0\usr\local\share\enchant\hunspell if %errorlevel% neq 0 exit /b 3 -set PHP_BUILD_CACHE_ENCHANT_DICT_DIR=%PHP_BUILD_CACHE_BASE_DIR%\enchant_dict -if not exist "%PHP_BUILD_CACHE_ENCHANT_DICT_DIR%" ( - echo Creating %PHP_BUILD_CACHE_ENCHANT_DICT_DIR% - mkdir "%PHP_BUILD_CACHE_ENCHANT_DICT_DIR%" -) -if not exist "%PHP_BUILD_CACHE_ENCHANT_DICT_DIR%\en_US.aff" ( - echo Fetching enchant dicts - pushd %PHP_BUILD_CACHE_ENCHANT_DICT_DIR% - del /q * - powershell -Command wget http://windows.php.net/downloads/qa/appveyor/ext/enchant/dict.zip -OutFile dict.zip - unzip dict.zip - del /q dict.zip - popd -) -mkdir %LOCALAPPDATA%\enchant\hunspell -copy %PHP_BUILD_CACHE_ENCHANT_DICT_DIR%\* %LOCALAPPDATA%\enchant\hunspell +echo Fetching enchant dicts +pushd %~d0\usr\local\share\enchant\hunspell +powershell -Command wget http://windows.php.net/downloads/qa/appveyor/ext/enchant/dict.zip -OutFile dict.zip +unzip dict.zip +del /q dict.zip +popd set PHP_BUILD_DIR=%PHP_BUILD_OBJ_DIR%\Release if "%THREAD_SAFE%" equ "1" set PHP_BUILD_DIR=%PHP_BUILD_DIR%_TS @@ -113,17 +119,20 @@ mkdir c:\tests_tmp set TEST_PHP_JUNIT=c:\junit.out.xml -cd "%APPVEYOR_BUILD_FOLDER%" nmake test TESTS="%OPCACHE_OPTS% -q --offline --show-diff --show-slow 1000 --set-timeout 120 --temp-source c:\tests_tmp --temp-target c:\tests_tmp --bless %PARALLEL%" set EXIT_CODE=%errorlevel% -appveyor PushArtifact %TEST_PHP_JUNIT% - if %EXIT_CODE% GEQ 1 ( git checkout ext\pgsql\tests\config.inc git diff > bless_tests.patch - appveyor PushArtifact bless_tests.patch +) + +if /i "%APPVEYOR%" equ "True" ( + appveyor PushArtifact %TEST_PHP_JUNIT% + if %EXIT_CODE% GEQ 1 ( + appveyor PushArtifact bless_tests.patch + ) ) exit /b %EXIT_CODE% diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 7c8e5698c7aae..1a8a169114d9a 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -152,3 +152,44 @@ jobs: -d opcache.jit_buffer_size=16M - name: Verify generated files are up to date uses: ./.github/actions/verify-generated-files + WINDOWS: + strategy: + fail-fast: false + matrix: + include: + - x64: true + zts: false + - x64: false + zts: true + name: "WINDOWS_${{ matrix.x64 && 'X64' || 'X86' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}" + runs-on: windows-2019 + env: + 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.2.0 + PHP_BUILD_CRT: vs16 + PLATFORM: ${{ matrix.x64 && 'x64' || 'x86' }} + THREAD_SAFE: "${{ matrix.zts && '1' || '0' }}" + INTRINSICS: "${{ matrix.zts && 'AVX2' || '' }}" + PARALLEL: -j2 + steps: + - name: git config + run: git config --global core.autocrlf false && git config --global core.eol lf + - name: git checkout + uses: actions/checkout@v2 + - name: Setup MySQL + run: | + choco install mysql -y --no-progress --params="/port:3306" + mysql.exe --port=3306 --user=root --password="" -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'Password12!'; FLUSH PRIVILEGES;" + - name: Setup MSSQL + run: | + choco install sql-server-express -y --no-progress --install-arguments="/SECURITYMODE=SQL /SAPWD=Password12!" + - name: Setup PostgreSQL + run: | + Set-Service -Name "postgresql-x64-14" -StartupType manual -Status Running + pwsh -Command { $env:PGPASSWORD="root"; & "$env:PGBIN\psql" -U postgres -c "ALTER USER postgres WITH PASSWORD 'Password12!';" } + - name: Build + run: .github/scripts/windows/build.bat + - name: Test + run: .github/scripts/windows/test.bat diff --git a/ext/gd/tests/bug77269.phpt b/ext/gd/tests/bug77269.phpt index 5d1f73a8bf005..f9b0b7bf3197d 100644 --- a/ext/gd/tests/bug77269.phpt +++ b/ext/gd/tests/bug77269.phpt @@ -5,6 +5,7 @@ gd --SKIPIF-- --INI-- memory_limit=2G diff --git a/ext/gd/tests/bug77272.phpt b/ext/gd/tests/bug77272.phpt index 4de532a5c7b3e..fc5ee464a07bb 100644 --- a/ext/gd/tests/bug77272.phpt +++ b/ext/gd/tests/bug77272.phpt @@ -8,6 +8,7 @@ gd --FILE-- --FILE--