Skip to content

Commit 916b132

Browse files
mvorisekiluuu1994
authored andcommitted
Add Windows GitHub actions build
Closes GH-10664
1 parent 729f006 commit 916b132

File tree

9 files changed

+103
-44
lines changed

9 files changed

+103
-44
lines changed

.github/scripts/windows/build.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ if not exist "%SDK_RUNNER%" (
3838
exit /b 3
3939
)
4040

41-
cmd /c %SDK_RUNNER% -t %APPVEYOR_BUILD_FOLDER%\.github\scripts\windows\build_task.bat
41+
cmd /c %SDK_RUNNER% -t .github\scripts\windows\build_task.bat
4242
if %errorlevel% neq 0 exit /b 3
4343

4444
exit /b 0

.github/scripts/windows/build_task.bat

+9-11
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,12 @@ if "%APPVEYOR%" equ "True" rmdir /s /q c:\OpenSSL-v11-Win32 >NUL 2>NUL
1818
if %errorlevel% neq 0 exit /b 3
1919
if "%APPVEYOR%" equ "True" rmdir /s /q c:\OpenSSL-v11-Win64 >NUL 2>NUL
2020
if %errorlevel% neq 0 exit /b 3
21-
if "%APPVEYOR%" equ "True" del /f /q C:\Windows\System32\libcrypto-1_1-x64.dll >NUL 2>NUL
21+
del /f /q C:\Windows\System32\libcrypto-1_1-x64.dll >NUL 2>NUL
2222
if %errorlevel% neq 0 exit /b 3
23-
if "%APPVEYOR%" equ "True" del /f /q C:\Windows\System32\libssl-1_1-x64.dll >NUL 2>NUL
23+
del /f /q C:\Windows\System32\libssl-1_1-x64.dll >NUL 2>NUL
2424
if %errorlevel% neq 0 exit /b 3
2525

26-
cd /D %APPVEYOR_BUILD_FOLDER%
27-
if %errorlevel% neq 0 exit /b 3
28-
29-
if /i "%APPVEYOR_REPO_BRANCH:~0,4%" equ "php-" (
30-
set BRANCH=%APPVEYOR_REPO_BRANCH:~4,3%
31-
) else (
32-
set BRANCH=master
33-
)
26+
call %~dp0find-target-branch.bat
3427
set STABILITY=staging
3528
set DEPS_DIR=%PHP_BUILD_CACHE_BASE_DIR%\deps-%BRANCH%-%PHP_SDK_VS%-%PHP_SDK_ARCH%
3629
rem SDK is cached, deps info is cached as well
@@ -51,7 +44,12 @@ if %errorlevel% neq 0 exit /b 3
5144
if "%THREAD_SAFE%" equ "0" set ADD_CONF=%ADD_CONF% --disable-zts
5245
if "%INTRINSICS%" neq "" set ADD_CONF=%ADD_CONF% --enable-native-intrinsics=%INTRINSICS%
5346

54-
set CFLAGS=/W1 /WX
47+
rem Some undefined behavior is reported on 32-bit, this should be fixed
48+
if "%PLATFORM%" == "x86" (
49+
set CFLAGS=/W1
50+
) else (
51+
set CFLAGS=/W1 /WX
52+
)
5553

5654
cmd /c configure.bat ^
5755
--enable-snapshot-build ^
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@echo off
2+
3+
for /f "usebackq tokens=3" %%i in (`findstr PHP_MAJOR_VERSION main\php_version.h`) do set BRANCH=%%i
4+
for /f "usebackq tokens=3" %%i in (`findstr PHP_MINOR_VERSION main\php_version.h`) do set BRANCH=%BRANCH%.%%i
5+
6+
if /i "%BRANCH%" equ "8.3" (
7+
set BRANCH=master
8+
)

.github/scripts/windows/test.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ if not exist "%SDK_RUNNER%" (
66
exit /b 3
77
)
88

9-
cmd /c %SDK_RUNNER% -t %APPVEYOR_BUILD_FOLDER%\.github\scripts\windows\test_task.bat
9+
cmd /c %SDK_RUNNER% -t .github\scripts\windows\test_task.bat
1010
if %errorlevel% neq 0 exit /b 3
1111

1212
exit /b 0

.github/scripts/windows/test_task.bat

+40-31
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ set NO_INTERACTION=1
44
set REPORT_EXIT_STATUS=1
55
set SKIP_IO_CAPTURE_TESTS=1
66

7-
if /i "%APPVEYOR_REPO_BRANCH:~0,4%" equ "php-" (
8-
set BRANCH=%APPVEYOR_REPO_BRANCH:~4,3%
7+
call %~dp0find-target-branch.bat
8+
if "%BRANCH%" neq "master" (
99
set STABILITY=stable
1010
) else (
11-
set BRANCH=master
1211
set STABILITY=staging
1312
)
1413
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%
2827
set PDO_MYSQL_TEST_HOST=%MYSQL_TEST_HOST%
2928
set PDO_MYSQL_TEST_PORT=%MYSQL_TEST_PORT%
3029
set PDO_MYSQL_TEST_DSN=mysql:host=%PDO_MYSQL_TEST_HOST%;port=%PDO_MYSQL_TEST_PORT%;dbname=test
31-
"C:\Program Files\MySql\MySQL Server 5.7\bin\mysql.exe" --user=%MYSQL_TEST_USER% -e "CREATE DATABASE IF NOT EXISTS test"
30+
if /i "%APPVEYOR%" equ "True" (
31+
set TMP_MYSQL_BIN=%ProgramFiles%\MySql\MySQL Server 5.7\bin
32+
) else (
33+
set TMP_MYSQL_BIN=C:\mysql\bin
34+
)
35+
"%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"
3236
if %errorlevel% neq 0 exit /b 3
3337

3438
rem setup PostgreSQL related exts
@@ -37,23 +41,35 @@ set PGPASSWORD=Password12!
3741
rem set PGSQL_TEST_CONNSTR=host=127.0.0.1 dbname=test port=5432 user=postgres password=Password12!
3842
echo ^<?php $conn_str = "host=127.0.0.1 dbname=test port=5432 user=%PGUSER% password=%PGPASSWORD%"; ?^> >> "./ext/pgsql/tests/config.inc"
3943
set PDO_PGSQL_TEST_DSN=pgsql:host=127.0.0.1 port=5432 dbname=test user=%PGUSER% password=%PGPASSWORD%
40-
"C:\Program Files\PostgreSQL\10\bin\createdb.exe" test
44+
if /i "%APPVEYOR%" equ "True" (
45+
set TMP_POSTGRESQL_BIN=%ProgramFiles%\PostgreSQL\10\bin
46+
) else (
47+
set TMP_POSTGRESQL_BIN=%PGBIN%
48+
)
49+
"%TMP_POSTGRESQL_BIN%\createdb.exe" test
4150
if %errorlevel% neq 0 exit /b 3
4251

4352
rem setup ODBC related exts
4453
set ODBC_TEST_USER=sa
4554
set ODBC_TEST_PASS=Password12!
46-
set ODBC_TEST_DSN=Driver={ODBC Driver 13 for SQL Server};Server=(local)\SQL2017;Database=master;uid=%ODBC_TEST_USER%;pwd=%ODBC_TEST_PASS%
55+
if /i "%APPVEYOR%" equ "True" (
56+
set ODBC_TEST_DSN=Driver={ODBC Driver 13 for SQL Server};Server=^(local^)\SQL2017;Database=master;uid=%ODBC_TEST_USER%;pwd=%ODBC_TEST_PASS%
57+
) else (
58+
set ODBC_TEST_DSN=Driver={ODBC Driver 17 for SQL Server};Server=^(local^)\SQLEXPRESS;Database=master;uid=%ODBC_TEST_USER%;pwd=%ODBC_TEST_PASS%
59+
)
4760
set PDOTEST_DSN=odbc:%ODBC_TEST_DSN%
4861

4962
rem prepare for ext/openssl
50-
if "%APPVEYOR%" equ "True" rmdir /s /q C:\OpenSSL-Win32 >NUL 2>NUL
51-
if "%APPVEYOR%" equ "True" rmdir /s /q C:\OpenSSL-Win64 >NUL 2>NUL
63+
rmdir /s /q C:\OpenSSL-Win32 >NUL 2>NUL
64+
rmdir /s /q C:\OpenSSL-Win64 >NUL 2>NUL
5265
if "%PLATFORM%" == "x64" (
5366
set OPENSSLDIR="C:\Program Files\Common Files\SSL"
5467
) else (
5568
set OPENSSLDIR="C:\Program Files (x86)\Common Files\SSL"
5669
)
70+
if /i "%GITHUB_ACTIONS%" equ "True" (
71+
rmdir /s /q %OPENSSLDIR% >nul 2>&1
72+
)
5773
mkdir %OPENSSLDIR%
5874
if %errorlevel% neq 0 exit /b 3
5975
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
6884
if "%OPCACHE%" equ "1" set OPCACHE_OPTS=%OPCACHE_OPTS% -d extension=mysqli
6985

7086
rem prepare for enchant
71-
mkdir C:\usr\local\lib\enchant-2
87+
mkdir %~d0\usr\local\lib\enchant-2
7288
if %errorlevel% neq 0 exit /b 3
73-
copy %DEPS_DIR%\bin\libenchant2_hunspell.dll C:\usr\local\lib\enchant-2
89+
copy %DEPS_DIR%\bin\libenchant2_hunspell.dll %~d0\usr\local\lib\enchant-2
7490
if %errorlevel% neq 0 exit /b 3
75-
reg add HKEY_CURRENT_USER\SOFTWARE\Enchant\Config /v Module_Dir /t REG_SZ /d c:\enchant_plugins
91+
mkdir %~d0\usr\local\share\enchant\hunspell
7692
if %errorlevel% neq 0 exit /b 3
77-
set PHP_BUILD_CACHE_ENCHANT_DICT_DIR=%PHP_BUILD_CACHE_BASE_DIR%\enchant_dict
78-
if not exist "%PHP_BUILD_CACHE_ENCHANT_DICT_DIR%" (
79-
echo Creating %PHP_BUILD_CACHE_ENCHANT_DICT_DIR%
80-
mkdir "%PHP_BUILD_CACHE_ENCHANT_DICT_DIR%"
81-
)
82-
if not exist "%PHP_BUILD_CACHE_ENCHANT_DICT_DIR%\en_US.aff" (
83-
echo Fetching enchant dicts
84-
pushd %PHP_BUILD_CACHE_ENCHANT_DICT_DIR%
85-
del /q *
86-
powershell -Command wget http://windows.php.net/downloads/qa/appveyor/ext/enchant/dict.zip -OutFile dict.zip
87-
unzip dict.zip
88-
del /q dict.zip
89-
popd
90-
)
91-
mkdir %LOCALAPPDATA%\enchant\hunspell
92-
copy %PHP_BUILD_CACHE_ENCHANT_DICT_DIR%\* %LOCALAPPDATA%\enchant\hunspell
93+
echo Fetching enchant dicts
94+
pushd %~d0\usr\local\share\enchant\hunspell
95+
powershell -Command wget http://windows.php.net/downloads/qa/appveyor/ext/enchant/dict.zip -OutFile dict.zip
96+
unzip dict.zip
97+
del /q dict.zip
98+
popd
9399

94100
set PHP_BUILD_DIR=%PHP_BUILD_OBJ_DIR%\Release
95101
if "%THREAD_SAFE%" equ "1" set PHP_BUILD_DIR=%PHP_BUILD_DIR%_TS
@@ -113,17 +119,20 @@ mkdir c:\tests_tmp
113119

114120
set TEST_PHP_JUNIT=c:\junit.out.xml
115121

116-
cd "%APPVEYOR_BUILD_FOLDER%"
117122
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%"
118123

119124
set EXIT_CODE=%errorlevel%
120125

121-
appveyor PushArtifact %TEST_PHP_JUNIT%
122-
123126
if %EXIT_CODE% GEQ 1 (
124127
git checkout ext\pgsql\tests\config.inc
125128
git diff > bless_tests.patch
126-
appveyor PushArtifact bless_tests.patch
129+
)
130+
131+
if /i "%APPVEYOR%" equ "True" (
132+
appveyor PushArtifact %TEST_PHP_JUNIT%
133+
if %EXIT_CODE% GEQ 1 (
134+
appveyor PushArtifact bless_tests.patch
135+
)
127136
)
128137

129138
exit /b %EXIT_CODE%

.github/workflows/push.yml

+41
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,44 @@ jobs:
152152
-d opcache.jit_buffer_size=16M
153153
- name: Verify generated files are up to date
154154
uses: ./.github/actions/verify-generated-files
155+
WINDOWS:
156+
strategy:
157+
fail-fast: false
158+
matrix:
159+
include:
160+
- x64: true
161+
zts: false
162+
- x64: false
163+
zts: true
164+
name: "WINDOWS_${{ matrix.x64 && 'X64' || 'X86' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}"
165+
runs-on: windows-2019
166+
env:
167+
PHP_BUILD_CACHE_BASE_DIR: C:\build-cache
168+
PHP_BUILD_OBJ_DIR: C:\obj
169+
PHP_BUILD_CACHE_SDK_DIR: C:\build-cache\sdk
170+
PHP_BUILD_SDK_BRANCH: php-sdk-2.2.0
171+
PHP_BUILD_CRT: vs16
172+
PLATFORM: ${{ matrix.x64 && 'x64' || 'x86' }}
173+
THREAD_SAFE: "${{ matrix.zts && '1' || '0' }}"
174+
INTRINSICS: "${{ matrix.zts && 'AVX2' || '' }}"
175+
PARALLEL: -j2
176+
steps:
177+
- name: git config
178+
run: git config --global core.autocrlf false && git config --global core.eol lf
179+
- name: git checkout
180+
uses: actions/checkout@v2
181+
- name: Setup MySQL
182+
run: |
183+
choco install mysql -y --no-progress --params="/port:3306"
184+
mysql.exe --port=3306 --user=root --password="" -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'Password12!'; FLUSH PRIVILEGES;"
185+
- name: Setup MSSQL
186+
run: |
187+
choco install sql-server-express -y --no-progress --install-arguments="/SECURITYMODE=SQL /SAPWD=Password12!"
188+
- name: Setup PostgreSQL
189+
run: |
190+
Set-Service -Name "postgresql-x64-14" -StartupType manual -Status Running
191+
pwsh -Command { $env:PGPASSWORD="root"; & "$env:PGBIN\psql" -U postgres -c "ALTER USER postgres WITH PASSWORD 'Password12!';" }
192+
- name: Build
193+
run: .github/scripts/windows/build.bat
194+
- name: Test
195+
run: .github/scripts/windows/test.bat

ext/gd/tests/bug77269.phpt

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ gd
55
--SKIPIF--
66
<?php
77
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
8+
if (substr(PHP_OS, 0, 3) == 'WIN' && PHP_INT_SIZE === 4) die("skip not for Windows x86");
89
?>
910
--INI--
1011
memory_limit=2G

ext/gd/tests/bug77272.phpt

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ gd
88
<?php
99
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.2.5', '<=')) die('skip upstream fix not yet released');
1010
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
11+
if (substr(PHP_OS, 0, 3) == 'WIN' && PHP_INT_SIZE === 4) die("skip not for Windows x86");
1112
?>
1213
--FILE--
1314
<?php

ext/sysvshm/tests/bug72858.phpt

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ sysvshm
77

88
if (4 < PHP_INT_SIZE) { print "skip 32-bit only"; }
99
if (substr(PHP_OS, 0, 3) != "WIN") { print "skip windows only"; }
10+
if (getenv('GITHUB_ACTIONS')) die('skip on GitHub actions');
1011
?>
1112
--FILE--
1213
<?php

0 commit comments

Comments
 (0)