Skip to content

Commit 4c9dab9

Browse files
committed
ci: Test on Windows
1 parent 4a56a4a commit 4c9dab9

File tree

6 files changed

+202
-2
lines changed

6 files changed

+202
-2
lines changed

.github/workflows/build.ps1

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
$ErrorActionPreference = "Stop"
2+
3+
$env:PATH = "C:\php\devel;C:\php\bin;C:\php\deps\bin;$env:PATH"
4+
5+
$task = New-Item 'task.bat' -Force
6+
Add-Content $task 'call phpize 2>&1'
7+
Add-Content $task "call configure --with-php-build=C:\php\deps --enable-$env:PHP_EXT --enable-debug-pack 2>&1"
8+
Add-Content $task 'nmake /nologo 2>&1'
9+
Add-Content $task 'exit %errorlevel%'
10+
& "C:\php\php-sdk-$env:BIN_SDK_VER\phpsdk-$env:VS-$env:ARCH.bat" -t $task
11+
if (-not $?) {
12+
throw "building failed with errorlevel $LastExitCode"
13+
}
14+
15+
$dname = ''
16+
if ($env:ARCH -eq 'x64') {
17+
$dname += 'x64\'
18+
}
19+
$dname += 'Release';
20+
if ($env:TS -eq 'ts') {
21+
$dname += '_TS'
22+
}
23+
Copy-Item "$dname\php_$env:PHP_EXT.dll" "C:\php\bin\ext\php_$env:PHP_EXT.dll"
24+
Copy-Item "$dname\php_$env:PHP_EXT.dll" "php_$env:PHP_EXT.dll"
25+
26+
$ini = New-Item "C:\php\bin\php.ini" -Force
27+
Add-Content $ini "extension_dir=C:\php\bin\ext"
28+
if (Test-Path 'C:\php\bin\ext\php_apcu.dll') {
29+
Add-Content $ini 'extension=php_apcu.dll'
30+
}
31+
Add-Content $ini "extension=php_openssl.dll"
32+
Add-Content $ini "extension=php_$env:PHP_EXT.dll"

.github/workflows/install.ps1

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
$ErrorActionPreference = "Stop"
2+
3+
if (-not (Test-Path 'C:\php')) {
4+
[void](New-Item 'C:\php' -ItemType 'directory')
5+
}
6+
7+
# PHP SDK
8+
$bname = "php-sdk-$env:BIN_SDK_VER.zip"
9+
if (-not (Test-Path C:\php\$bname)) {
10+
echo "Download: https://github.com/php/php-sdk-binary-tools/archive/$bname"
11+
Invoke-WebRequest "https://github.com/php/php-sdk-binary-tools/archive/$bname" -OutFile "C:\php\$bname"
12+
}
13+
$dname0 = "php-sdk-binary-tools-php-sdk-$env:BIN_SDK_VER"
14+
$dname1 = "php-sdk-$env:BIN_SDK_VER"
15+
if (-not (Test-Path "C:\php\$dname1")) {
16+
Expand-Archive "C:\php\$bname" "C:\php"
17+
Move-Item "C:\php\$dname0" "C:\php\$dname1"
18+
}
19+
20+
# PHP releases
21+
if (-not (Test-Path C:\php\releases.json)) {
22+
echo "Download: https://windows.php.net/downloads/releases/releases.json"
23+
Invoke-WebRequest "https://windows.php.net/downloads/releases/releases.json" -OutFile "C:\php\releases.json"
24+
}
25+
$php_version = (Get-Content -Path "C:\php\releases.json" | ConvertFrom-Json | ForEach-Object {
26+
if ($_."$env:PHP_VER") {
27+
return $_."$env:PHP_VER".version
28+
} else {
29+
return "$env:PHP_VER"
30+
}
31+
})
32+
33+
# PHP devel pack: "C:\php\devel"
34+
$ts_part = ''
35+
if ('nts' -eq $env:TS) {
36+
$ts_part = '-nts'
37+
}
38+
$bname = "php-devel-pack-$php_version$ts_part-Win32-$env:VS-$env:ARCH.zip"
39+
if (-not (Test-Path "C:\php\$bname")) {
40+
try {
41+
echo "Download: https://windows.php.net/downloads/releases/$bname"
42+
Invoke-WebRequest "https://windows.php.net/downloads/releases/$bname" -OutFile "C:\php\$bname"
43+
} catch [System.Net.WebException] {
44+
echo "Downlaod: https://windows.php.net/downloads/releases/archives/$bname"
45+
Invoke-WebRequest "https://windows.php.net/downloads/releases/archives/$bname" -OutFile "C:\php\$bname"
46+
}
47+
}
48+
$dname = "php-$php_version-devel-$env:VS-$env:ARCH"
49+
if (-not (Test-Path "C:\php\devel")) {
50+
Expand-Archive "C:\php\$bname" 'C:\php'
51+
if (-not (Test-Path "C:\php\$dname")) {
52+
$php_normalize_version = $php_version.Split("-")[0]
53+
$dname = "php-$php_normalize_version-devel-$env:VS-$env:ARCH"
54+
}
55+
if (-not (Test-Path "C:\php\devel")) {
56+
Move-Item "C:\php\$dname" "C:\php\devel"
57+
}
58+
}
59+
60+
# PHP binary: "C:\php\bin"
61+
$bname = "php-$php_version$ts_part-Win32-$env:VS-$env:ARCH.zip"
62+
if (-not (Test-Path "C:\php\$bname")) {
63+
try {
64+
echo "Download: https://windows.php.net/downloads/releases/$bname"
65+
Invoke-WebRequest "https://windows.php.net/downloads/releases/$bname" -OutFile "C:\php\$bname"
66+
} catch [System.Net.WebException] {
67+
echo "Download: https://windows.php.net/downloads/releases/archives/$bname"
68+
Invoke-WebRequest "https://windows.php.net/downloads/releases/archives/$bname" -OutFile "C:\php\$bname"
69+
}
70+
}
71+
if (-not (Test-Path "C:\php\bin")) {
72+
Expand-Archive "C:\php\$bname" "C:\php\bin"
73+
}
74+
75+
# library dependency: "C:\php\deps"
76+
if ("$env:DEP" -ne "") {
77+
$bname = "$env:DEP-$env:VS-$env:ARCH.zip"
78+
if (-not (Test-Path "C:\php\$bname")) {
79+
echo "Download: https://windows.php.net/downloads/pecl/deps/$bname"
80+
Invoke-WebRequest "https://windows.php.net/downloads/pecl/deps/$bname" -OutFile "C:\php\$bname"
81+
Expand-Archive "C:\php\$bname" "C:\php\deps"
82+
}
83+
}
File renamed without changes.

.github/workflows/test.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
$ErrorActionPreference = "Stop"
2+
3+
$env:PATH = "C:\php\devel;C:\php\bin;C:\php\deps\bin;$env:PATH"
4+
5+
$env:TEST_PHP_EXECUTABLE = "C:\php\bin\php.exe"
6+
& $env:TEST_PHP_EXECUTABLE 'run-tests.php' --color --show-diff tests
7+
if (-not $?) {
8+
throw "testing failed with errorlevel $LastExitCode"
9+
}

.github/workflows/windows.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Windows
2+
3+
on:
4+
push:
5+
release:
6+
types: [published]
7+
8+
env:
9+
PHP_EXT: simdjson
10+
PHP_EXT_VERSION: ${{ github.event.release.tag_name }}
11+
BIN_SDK_VER: 2.3.0
12+
13+
jobs:
14+
ci:
15+
strategy:
16+
matrix:
17+
php:
18+
- '8.4'
19+
- '8.3'
20+
- '8.2'
21+
- '8.1'
22+
- '8.0'
23+
ts:
24+
- 'nts'
25+
- 'ts'
26+
vs:
27+
- vs16
28+
- vs17
29+
exclude:
30+
- php: '8.4'
31+
vs: vs16
32+
- php: '8.3'
33+
vs: vs17
34+
- php: '8.2'
35+
vs: vs17
36+
- php: '8.1'
37+
vs: vs17
38+
- php: '8.0'
39+
vs: vs17
40+
41+
runs-on: ${{ matrix.vs == 'vs17' && 'windows-2022' || 'windows-2019' }}
42+
43+
env:
44+
PHP_VER: ${{ matrix.php }}
45+
VS: ${{ matrix.vs }}
46+
ARCH: x64
47+
TS: ${{ matrix.ts }}
48+
49+
steps:
50+
- name: Checkout repository
51+
uses: actions/checkout@v4
52+
with:
53+
persist-credentials: false
54+
55+
- uses: actions/cache@v4
56+
with:
57+
path: |
58+
C:\php\php-*.zip
59+
key: ${{ runner.os }}-php-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.vs }}
60+
restore-keys: |
61+
${{ runner.os }}-php-
62+
63+
- name: Install build command
64+
run: .\.github\workflows\install.ps1
65+
shell: pwsh
66+
67+
- name: Build
68+
run: .\.github\workflows\build.ps1
69+
shell: pwsh
70+
71+
- name: Test
72+
run: .\.github\workflows\test.ps1
73+
shell: pwsh
74+
env:
75+
REPORT_EXIT_STATUS: 1
76+
NO_INTERACTION: 1

config.w32

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ if (PHP_SIMDJSON == "yes") {
99
'php_simdjson.cpp',
1010
'yes',
1111
'/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 /std:c++latest');
12-
ADD_SOURCES(configure_module_dirname + '/src', 'simdjson.cpp simdjson_bindings.cpp', 'simdjson');
12+
ADD_SOURCES(configure_module_dirname + '/src', 'simdjson.cpp simdjson_decoder.cpp countlut.cpp simdjson_encoder.cpp simdutf.cpp', 'simdjson');
1313
ADD_FLAG('CFLAGS_SIMDJSON', '/I' + configure_module_dirname);
14-
PHP_INSTALL_HEADERS('ext/simdjson', 'php_simdjson.h src/simdjson_bindings_defs.h');
14+
PHP_INSTALL_HEADERS('ext/simdjson', 'php_simdjson.h src/simdjson_decoder_defs.h');
1515
}
1616
// vim:ft=javascript

0 commit comments

Comments
 (0)