Skip to content

Commit 0ee6bc5

Browse files
committed
Add Windows Build using GitHub Actions
1 parent c4d69c2 commit 0ee6bc5

File tree

5 files changed

+338
-0
lines changed

5 files changed

+338
-0
lines changed

.github/workflows/windows-build.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Windows Build
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- '**/*.md'
7+
- '**/*.gitignore'
8+
- '**/*.gitatributes'
9+
- 'docs/**'
10+
pull_request:
11+
paths-ignore:
12+
- '**/*.md'
13+
- '**/*.gitignore'
14+
- '**/*.gitatributes'
15+
- 'docs/**'
16+
17+
env:
18+
PHP_BUILD_CACHE_BASE_DIR: C:\build-cache
19+
PHP_BUILD_OBJ_DIR: C:\obj
20+
PHP_BUILD_CACHE_SDK_DIR: C:\build-cache\sdk
21+
PHP_BUILD_SDK_BRANCH: php-sdk-2.2.0
22+
PHP_BUILD_CRT: vs16
23+
PLATFORM: x64
24+
25+
jobs:
26+
pipeline:
27+
runs-on: windows-2019
28+
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
# thread-safe: [0, 1]
33+
thread-safe: [0]
34+
include:
35+
- thread-safe: 0
36+
opcache: 0
37+
parallel: -j2
38+
intrinsics: ''
39+
# - thread-safe: 1
40+
# opcache: 1
41+
# parallel: -j2
42+
# intrinsics: 'AVX'
43+
44+
env:
45+
THREAD_SAFE: ${{ matrix.thread-safe }}
46+
OPCACHE: ${{ matrix.opcache }}
47+
PARALLEL: ${{ matrix.parallel }}
48+
INTRINSICS: ${{ matrix.intrinsics }}
49+
50+
steps:
51+
- uses: actions/checkout@v2
52+
with:
53+
fetch-depth: 64
54+
55+
- name: Build PHP
56+
shell: cmd
57+
run: call .\.github\workflows\windows-build\build.bat
58+
59+
- name: Setup MySQL
60+
run: choco install mysql
61+
62+
- name: Setup SQLServer
63+
run: choco install mssql2014express-defaultinstance -y --allow-empty-checksums
64+
65+
- name: Start PostgreSQL
66+
run: |
67+
$postgreSqlSvc = Get-Service "postgresql*"
68+
Set-Service $postgreSqlSvc.Name -StartupType manual
69+
$postgreSqlSvc.Start()
70+
try {
71+
(Get-Service "postgresql*").Start()
72+
} catch {
73+
$_ | select *
74+
}
75+
76+
- name: Run Test Suite
77+
shell: cmd
78+
run: call .\.github\workflows\windows-build\test.bat
79+
80+
# services:
81+
# mysql:
82+
# image: mysql:5.7
83+
# ports:
84+
# - 3306:3306
85+
# env:
86+
# MYSQL_ROOT_PASSWORD: Password12!
87+
# MYSQL_DATABASE: test
88+
# postgres:
89+
# image: postgres:10.1
90+
# ports:
91+
# - 5432:5432
92+
# env:
93+
# POSTGRES_USER: postgres
94+
# POSTGRES_PASSWORD: Password12!
95+
# POSTGRES_DB: test
96+
# mssql:
97+
# image: mcr.microsoft.com/mssql/server:2017-latest
98+
# ports:
99+
# - 1433:1433
100+
# env:
101+
# ACCEPT_EULA: Y
102+
# SA_PASSWORD: Password12!
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
@echo off
2+
3+
set SDK_REMOTE=https://github.com/Microsoft/php-sdk-binary-tools.git
4+
set SDK_BRANCH=%PHP_BUILD_SDK_BRANCH%
5+
set SDK_RUNNER=%PHP_BUILD_CACHE_SDK_DIR%\phpsdk-%PHP_BUILD_CRT%-%PLATFORM%.bat
6+
7+
if not exist "%PHP_BUILD_CACHE_BASE_DIR%" (
8+
echo Creating %PHP_BUILD_CACHE_BASE_DIR%
9+
mkdir "%PHP_BUILD_CACHE_BASE_DIR%"
10+
)
11+
12+
if not exist "%PHP_BUILD_OBJ_DIR%" (
13+
echo Creating %PHP_BUILD_OBJ_DIR%
14+
mkdir "%PHP_BUILD_OBJ_DIR%"
15+
)
16+
17+
if not exist "%SDK_RUNNER%" (
18+
if exist "%PHP_BUILD_CACHE_SDK_DIR%" rmdir /s /q "%PHP_BUILD_CACHE_SDK_DIR%"
19+
)
20+
21+
if not exist "%PHP_BUILD_CACHE_SDK_DIR%" (
22+
echo Cloning remote SDK repository
23+
git clone --branch %SDK_BRANCH% %SDK_REMOTE% --depth 1 "%PHP_BUILD_CACHE_SDK_DIR%" 2>&1
24+
)
25+
26+
for /f "tokens=*" %%a in ('type %PHP_BUILD_CACHE_SDK_DIR%\VERSION') do set GOT_SDK_VER=%%a
27+
echo Got SDK version %GOT_SDK_VER%
28+
if NOT "%GOT_SDK_VER%" == "%PHP_BUILD_SDK_BRANCH:~8%" (
29+
echo Switching to the configured SDK version %SDK_BRANCH:~8%
30+
echo Fetching remote SDK repository
31+
git --git-dir="%PHP_BUILD_CACHE_SDK_DIR%\.git" --work-tree="%PHP_BUILD_CACHE_SDK_DIR%" fetch --prune origin 2>&1
32+
echo Checkout SDK repository branch
33+
git --git-dir="%PHP_BUILD_CACHE_SDK_DIR%\.git" --work-tree="%PHP_BUILD_CACHE_SDK_DIR%" checkout --force %SDK_BRANCH%
34+
)
35+
36+
if not exist "%SDK_RUNNER%" (
37+
echo "%SDK_RUNNER%" doesn't exist
38+
exit /b 3
39+
)
40+
41+
cmd /c %SDK_RUNNER% -t %GITHUB_WORKSPACE%\.github\workflows\windows-build\build_task.bat
42+
if %errorlevel% neq 0 exit /b 3
43+
44+
exit /b 0
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
@echo off
2+
3+
if "%CI%" equ "True" rmdir /s /q C:\cygwin >NUL 2>NUL
4+
if %errorlevel% neq 0 exit /b 3
5+
if "%CI%" equ "True" rmdir /s /q C:\cygwin64 >NUL 2>NUL
6+
if %errorlevel% neq 0 exit /b 3
7+
if "%CI%" equ "True" rmdir /s /q C:\mingw >NUL 2>NUL
8+
if %errorlevel% neq 0 exit /b 3
9+
if "%CI%" equ "True" rmdir /s /q C:\mingw-w64 >NUL 2>NUL
10+
if %errorlevel% neq 0 exit /b 3
11+
if "%CI%" equ "True" rmdir /s /q C:\msys64 >NUL 2>NUL
12+
if %errorlevel% neq 0 exit /b 3
13+
if "%CI%" equ "True" rmdir /s /q C:\OpenSSL-Win32 >NUL 2>NUL
14+
if %errorlevel% neq 0 exit /b 3
15+
if "%CI%" equ "True" rmdir /s /q C:\OpenSSL-Win64 >NUL 2>NUL
16+
if %errorlevel% neq 0 exit /b 3
17+
if "%CI%" equ "True" rmdir /s /q C:\OpenSSL-v11-Win32 >NUL 2>NUL
18+
if %errorlevel% neq 0 exit /b 3
19+
if "%CI%" equ "True" rmdir /s /q C:\OpenSSL-v11-Win64 >NUL 2>NUL
20+
if %errorlevel% neq 0 exit /b 3
21+
if "%CI%" equ "True" del /f /q C:\Windows\System32\libcrypto-1_1-x64.dll >NUL 2>NUL
22+
if %errorlevel% neq 0 exit /b 3
23+
if "%CI%" equ "True" del /f /q C:\Windows\System32\libssl-1_1-x64.dll >NUL 2>NUL
24+
if %errorlevel% neq 0 exit /b 3
25+
26+
cd /D %GITHUB_WORKSPACE%
27+
if %errorlevel% neq 0 exit /b 3
28+
29+
if /i "%GITHUB_REF:~0,4%" equ "php-" (
30+
set BRANCH=%GITHUB_REF:~4,3%
31+
) else (
32+
set BRANCH=master
33+
)
34+
set STABILITY=staging
35+
set DEPS_DIR=%PHP_BUILD_CACHE_BASE_DIR%\deps-%BRANCH%-%PHP_SDK_VS%-%PHP_SDK_ARCH%
36+
rem SDK is cached, deps info is cached as well
37+
echo Updating dependencies in %DEPS_DIR%
38+
cmd /c phpsdk_deps --update --no-backup --branch %BRANCH% --stability %STABILITY% --deps %DEPS_DIR% --crt %PHP_BUILD_CRT%
39+
if %errorlevel% neq 0 exit /b 3
40+
41+
rem Something went wrong, most likely when concurrent builds were to fetch deps
42+
rem updates. It might be, that some locking mechanism is needed.
43+
if not exist "%DEPS_DIR%" (
44+
cmd /c phpsdk_deps --update --force --no-backup --branch %BRANCH% --stability %STABILITY% --deps %DEPS_DIR%
45+
)
46+
if %errorlevel% neq 0 exit /b 3
47+
48+
cmd /c buildconf.bat --force
49+
if %errorlevel% neq 0 exit /b 3
50+
51+
if "%THREAD_SAFE%" equ "0" set ADD_CONF=%ADD_CONF% --disable-zts
52+
if "%INTRINSICS%" neq "" set ADD_CONF=%ADD_CONF% --enable-native-intrinsics=%INTRINSICS%
53+
54+
set EXT_EXCLUDE_FROM_TEST=snmp,oci8_12c,pdo_oci,pdo_firebird,ldap,imap,ftp
55+
if "%OPCACHE%" equ "0" set EXT_EXCLUDE_FROM_TEST=%EXT_EXCLUDE_FROM_TEST%,opcache
56+
57+
set CFLAGS=/W1 /WX
58+
59+
cmd /c configure.bat ^
60+
--enable-snapshot-build ^
61+
--disable-debug-pack ^
62+
--enable-com-dotnet=shared ^
63+
--without-analyzer ^
64+
--enable-object-out-dir=%PHP_BUILD_OBJ_DIR% ^
65+
--with-php-build=%DEPS_DIR% ^
66+
%ADD_CONF% ^
67+
--with-test-ini-ext-exclude=%EXT_EXCLUDE_FROM_TEST%
68+
if %errorlevel% neq 0 exit /b 3
69+
70+
nmake /NOLOGO
71+
if %errorlevel% neq 0 exit /b 3
72+
73+
exit /b 0
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@echo off
2+
3+
set SDK_RUNNER=%PHP_BUILD_CACHE_SDK_DIR%\phpsdk-%PHP_BUILD_CRT%-%PLATFORM%.bat
4+
if not exist "%SDK_RUNNER%" (
5+
echo "%SDK_RUNNER%" doesn't exist
6+
exit /b 3
7+
)
8+
9+
cmd /c %SDK_RUNNER% -t %GITHUB_WORKSPACE%\.github\workflows\windows-build\test_task.bat
10+
if %errorlevel% neq 0 exit /b 3
11+
12+
exit /b 0
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
@echo off
2+
3+
set NO_INTERACTION=1
4+
set REPORT_EXIT_STATUS=1
5+
set SKIP_IO_CAPTURE_TESTS=1
6+
7+
if /i "%GITHUB_REF:~0,4%" equ "php-" (
8+
set BRANCH=%GITHUB_REF:~4,3%
9+
set STABILITY=stable
10+
) else (
11+
set BRANCH=master
12+
set STABILITY=staging
13+
)
14+
set DEPS_DIR=%PHP_BUILD_CACHE_BASE_DIR%\deps-%BRANCH%-%PHP_SDK_VS%-%PHP_SDK_ARCH%
15+
if not exist "%DEPS_DIR%" (
16+
echo "%DEPS_DIR%" doesn't exist
17+
exit /b 3
18+
)
19+
20+
echo "Setup MySQL related exts"
21+
set MYSQL_PWD=Password12!
22+
set MYSQL_TEST_PASSWD=%MYSQL_PWD%
23+
set MYSQL_TEST_USER=root
24+
set MYSQL_TEST_HOST=127.0.0.1
25+
set MYSQL_TEST_PORT=3306
26+
set PDO_MYSQL_TEST_USER=%MYSQL_TEST_USER%
27+
set PDO_MYSQL_TEST_PASS=%MYSQL_PWD%
28+
set PDO_MYSQL_TEST_HOST=%MYSQL_TEST_HOST%
29+
set PDO_MYSQL_TEST_PORT=%MYSQL_TEST_PORT%
30+
set PDO_MYSQL_TEST_DSN=mysql:host=%PDO_MYSQL_TEST_HOST%;port=%PDO_MYSQL_TEST_PORT%;dbname=test
31+
"C:\tools\mysql\current\bin\mysql.exe" --user=%MYSQL_TEST_USER% -e "CREATE DATABASE IF NOT EXISTS test"
32+
if %errorlevel% neq 0 exit /b 3
33+
34+
echo "Setup PostgreSQL related exts"
35+
set PGUSER=postgres
36+
set PGPASSWORD=Password12!
37+
rem set PGSQL_TEST_CONNSTR=host=127.0.0.1 dbname=test port=5432 user=postgres password=Password12!
38+
echo ^<?php $conn_str = "host=127.0.0.1 dbname=test port=5432 user=%PGUSER% password=%PGPASSWORD%"; ?^> >> "./ext/pgsql/tests/config.inc"
39+
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
41+
if %errorlevel% neq 0 exit /b 3
42+
43+
echo "Setup ODBC related exts"
44+
set ODBC_TEST_USER=sa
45+
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%
47+
set PDOTEST_DSN=odbc:%ODBC_TEST_DSN%
48+
49+
echo "Prepare for ext/openssl"
50+
if "%CI%" equ "True" rmdir /s /q C:\OpenSSL-Win32 >NUL 2>NUL
51+
if "%CI%" equ "True" rmdir /s /q C:\OpenSSL-Win64 >NUL 2>NUL
52+
if "%PLATFORM%" == "x64" (
53+
set OPENSSLDIR="C:\Program Files\Common Files\SSL"
54+
) else (
55+
set OPENSSLDIR="C:\Program Files (x86)\Common Files\SSL"
56+
)
57+
mkdir %OPENSSLDIR%
58+
if %errorlevel% neq 0 exit /b 3
59+
copy %DEPS_DIR%\template\ssl\openssl.cnf %OPENSSLDIR%
60+
if %errorlevel% neq 0 exit /b 3
61+
rem set OPENSSL_CONF=%OPENSSLDIR%\openssl.cnf
62+
set OPENSSL_CONF=
63+
rem set SSLEAY_CONF=
64+
65+
echo "Prepare for OPcache"
66+
if "%OPCACHE%" equ "1" set OPCACHE_OPTS=-d opcache.enable=1 -d opcache.enable_cli=1 -d opcache.protect_memory=1 -d opcache.jit_buffer_size=16M
67+
68+
echo "Prepare for enchant"
69+
mkdir C:\usr\local\lib\enchant-2
70+
if %errorlevel% neq 0 exit /b 3
71+
copy %DEPS_DIR%\bin\libenchant2_hunspell.dll C:\usr\local\lib\enchant-2
72+
if %errorlevel% neq 0 exit /b 3
73+
reg add HKEY_CURRENT_USER\SOFTWARE\Enchant\Config /v Module_Dir /t REG_SZ /d c:\enchant_plugins
74+
if %errorlevel% neq 0 exit /b 3
75+
set PHP_BUILD_CACHE_ENCHANT_DICT_DIR=%PHP_BUILD_CACHE_BASE_DIR%\enchant_dict
76+
if not exist "%PHP_BUILD_CACHE_ENCHANT_DICT_DIR%" (
77+
echo Creating %PHP_BUILD_CACHE_ENCHANT_DICT_DIR%
78+
mkdir "%PHP_BUILD_CACHE_ENCHANT_DICT_DIR%"
79+
)
80+
if not exist "%PHP_BUILD_CACHE_ENCHANT_DICT_DIR%\en_US.aff" (
81+
echo Fetching enchant dicts
82+
pushd %PHP_BUILD_CACHE_ENCHANT_DICT_DIR%
83+
del /q *
84+
powershell -Command wget http://windows.php.net/downloads/qa/appveyor/ext/enchant/dict.zip -OutFile dict.zip
85+
unzip dict.zip
86+
del /q dict.zip
87+
popd
88+
)
89+
mkdir %LOCALAPPDATA%\enchant\hunspell
90+
copy %PHP_BUILD_CACHE_ENCHANT_DICT_DIR%\* %LOCALAPPDATA%\enchant\hunspell
91+
92+
set TEST_PHPDBG_EXECUTABLE=%PHP_BUILD_OBJ_DIR%\Release
93+
if "%THREAD_SAFE%" equ "1" set TEST_PHPDBG_EXECUTABLE=%TEST_PHPDBG_EXECUTABLE%_TS
94+
set TEST_PHPDBG_EXECUTABLE=%TEST_PHPDBG_EXECUTABLE%\phpdbg.exe
95+
96+
mkdir c:\tests_tmp
97+
98+
set TEST_PHP_JUNIT=c:\junit.out.xml
99+
100+
cd "%GITHUB_WORKSPACE%"
101+
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 %PARALLEL%"
102+
103+
set EXIT_CODE=%errorlevel%
104+
105+
rem powershell -Command "$wc = New-Object 'System.Net.WebClient'; $wc.UploadFile('https://ci.appveyor.com/api/testresults/junit/%APPVEYOR_JOB_ID%', 'c:\junit.out.xml')"
106+
107+
exit /b %EXIT_CODE%

0 commit comments

Comments
 (0)