Skip to content

Commit 8ea53c2

Browse files
cmb69nikic
authored andcommitted
Appveyor CI integration
Besides building the DLLs and running the tests, we also create downloadable binary packages for Windows users.
1 parent 24899ec commit 8ea53c2

File tree

5 files changed

+199
-0
lines changed

5 files changed

+199
-0
lines changed

.appveyor.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# general configuration
2+
version: '{branch}.{build}'
3+
4+
# environment configuration
5+
image: Visual Studio 2017
6+
clone_folder: C:\projects\scalar_objects
7+
environment:
8+
BIN_SDK_VER: 2.2.0
9+
matrix:
10+
- PHP_VER: 7.2
11+
TS: 0
12+
VC: vc15
13+
ARCH: x64
14+
OPCACHE: 0
15+
- PHP_VER: 7.2
16+
TS: 1
17+
VC: vc15
18+
ARCH: x64
19+
OPCACHE: 1
20+
- PHP_VER: 7.3
21+
TS: 0
22+
VC: vc15
23+
ARCH: x64
24+
OPCACHE: 0
25+
- PHP_VER: 7.3
26+
TS: 1
27+
VC: vc15
28+
ARCH: x64
29+
OPCACHE: 1
30+
- PHP_VER: 7.4
31+
TS: 0
32+
VC: vc15
33+
ARCH: x64
34+
OPCACHE: 0
35+
- PHP_VER: 7.4
36+
TS: 1
37+
VC: vc15
38+
ARCH: x64
39+
OPCACHE: 1
40+
- PHP_VER: 8.0
41+
TS: 0
42+
VC: vs16
43+
ARCH: x64
44+
OPCACHE: 0
45+
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
46+
- PHP_VER: 8.0
47+
TS: 1
48+
VC: vs16
49+
ARCH: x64
50+
OPCACHE: 1
51+
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
52+
cache:
53+
- C:\build-cache -> .appveyor.yml, .appveyor\install.ps1
54+
install:
55+
- ps: .appveyor\install.ps1
56+
57+
# build configuration
58+
build_script:
59+
- ps: .appveyor\build.ps1
60+
61+
after_build:
62+
- ps: .appveyor\package.ps1
63+
64+
# tests configuration
65+
test_script:
66+
- ps: .appveyor\test.ps1

.appveyor/build.ps1

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
$ErrorActionPreference = "Stop"
2+
3+
Set-Location 'C:\projects\scalar_objects'
4+
5+
$task = New-Item 'task.bat' -Force
6+
Add-Content $task "call phpize 2>&1"
7+
Add-Content $task "call configure --enable-scalar-objects --enable-debug-pack 2>&1"
8+
Add-Content $task "nmake /nologo 2>&1"
9+
Add-Content $task "exit %errorlevel%"
10+
& "C:\build-cache\php-sdk-$env:BIN_SDK_VER\phpsdk-$env:VC-$env:ARCH.bat" -t $task
11+
if (-not $?) {
12+
throw "build failed with errorlevel $LastExitCode"
13+
}

.appveyor/install.ps1

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
$ErrorActionPreference = "Stop"
2+
3+
if (-not (Test-Path 'C:\build-cache')) {
4+
[void](New-Item 'C:\build-cache' -ItemType 'directory')
5+
}
6+
7+
$bname = "php-sdk-$env:BIN_SDK_VER.zip"
8+
if (-not (Test-Path "C:\build-cache\$bname")) {
9+
Invoke-WebRequest "https://github.com/Microsoft/php-sdk-binary-tools/archive/$bname" -OutFile "C:\build-cache\$bname"
10+
}
11+
$dname0 = "php-sdk-binary-tools-php-sdk-$env:BIN_SDK_VER"
12+
$dname1 = "php-sdk-$env:BIN_SDK_VER"
13+
if (-not (Test-Path "C:\build-cache\$dname1")) {
14+
Expand-Archive "C:\build-cache\$bname" 'C:\build-cache'
15+
Move-Item "C:\build-cache\$dname0" "C:\build-cache\$dname1"
16+
}
17+
18+
$gareleases = Invoke-WebRequest "https://windows.php.net/downloads/releases/releases.json" | ConvertFrom-Json
19+
$qareleases = Invoke-WebRequest "https://windows.php.net/downloads/qa/releases.json" | ConvertFrom-Json
20+
$garev = [regex]::split($gareleases.$env:PHP_VER.version, '[^\d]')[2]
21+
$qarev = [regex]::split($qareleases.$env:PHP_VER.version, '[^\d]')[2]
22+
if ($qarev -gt $garev) {
23+
$phpversion = $qareleases.$env:PHP_VER.version
24+
$phprelease = 'QA'
25+
} else {
26+
$phpversion = $gareleases.$env:PHP_VER.version
27+
$phprelease = 'GA'
28+
}
29+
30+
$ts_part = ''
31+
if ($env:TS -eq '0') {
32+
$ts_part += '-nts'
33+
}
34+
$bname = "php-devel-pack-$phpversion$ts_part-Win32-$env:VC-$env:ARCH.zip"
35+
if (-not (Test-Path "C:\build-cache\$bname")) {
36+
if ($phprelease -eq "GA") {
37+
Invoke-WebRequest "https://windows.php.net/downloads/releases/$bname" -OutFile "C:\build-cache\$bname"
38+
} else {
39+
Invoke-WebRequest "https://windows.php.net/downloads/qa/$bname" -OutFile "C:\build-cache\$bname"
40+
}
41+
}
42+
$dname0 = "php-$phpversion-devel-$env:VC-$env:ARCH"
43+
$dname1 = "php-$phpversion$ts_part-devel-$env:VC-$env:ARCH"
44+
if (-not (Test-Path "C:\build-cache\$dname1")) {
45+
Expand-Archive "C:\build-cache\$bname" 'C:\build-cache'
46+
if ($dname0 -ne $dname1) {
47+
Move-Item "C:\build-cache\$dname0" "C:\build-cache\$dname1"
48+
}
49+
}
50+
$env:PATH = "C:\build-cache\$dname1;$env:PATH"
51+
52+
$bname = "php-$phpversion$ts_part-Win32-$env:VC-$env:ARCH.zip"
53+
if (-not (Test-Path "C:\build-cache\$bname")) {
54+
if ($phprelease -eq "GA") {
55+
Invoke-WebRequest "https://windows.php.net/downloads/releases/$bname" -OutFile "C:\build-cache\$bname"
56+
} else {
57+
Invoke-WebRequest "https://windows.php.net/downloads/qa/$bname" -OutFile "C:\build-cache\$bname"
58+
}
59+
}
60+
$dname = "php-$phpversion$ts_part-$env:VC-$env:ARCH"
61+
if (-not (Test-Path "C:\build-cache\$dname")) {
62+
Expand-Archive "C:\build-cache\$bname" "C:\build-cache\$dname"
63+
}
64+
$env:PATH = "c:\build-cache\$dname;$env:PATH"

.appveyor/package.ps1

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
$ErrorActionPreference = "Stop"
2+
3+
if ($env:TS -eq '0') {
4+
$ts_part = 'nts'
5+
} else {
6+
$ts_part = 'ts';
7+
}
8+
9+
if ($env:APPVEYOR_REPO_TAG -eq "true") {
10+
$bname = "php_scalar_objects-$env:APPVEYOR_REPO_TAG_NAME-$env:PHP_VER-$ts_part-$env:VC-$env:ARCH"
11+
} else {
12+
$bname = "php_scalar_objects-$($env:APPVEYOR_REPO_COMMIT.substring(0, 8))-$env:PHP_VER-$ts_part-$env:VC-$env:ARCH"
13+
}
14+
$zip_bname = "$bname.zip"
15+
16+
$dir = 'C:\projects\scalar_objects\';
17+
if ($env:ARCH -eq 'x64') {
18+
$dir += 'x64\'
19+
}
20+
$dir += 'Release'
21+
if ($env:TS -eq '1') {
22+
$dir += '_TS'
23+
}
24+
25+
Compress-Archive "$dir\php_scalar_objects.dll", "$dir\php_scalar_objects.pdb", "C:\projects\scalar_objects\LICENSE" "C:\$zip_bname"
26+
Push-AppveyorArtifact "C:\$zip_bname"

.appveyor/test.ps1

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
$ErrorActionPreference = "Stop"
2+
3+
$dir = 'C:\projects\scalar_objects\'
4+
if ($env:ARCH -eq 'x64') {
5+
$dir += 'x64\'
6+
}
7+
$dir += 'Release'
8+
if ($env:TS -eq '1') {
9+
$dir += '_TS'
10+
}
11+
12+
$scalar_objects_dll_opt = "-d extension=$dir\php_scalar_objects.dll"
13+
14+
Set-Location "C:\projects\scalar_objects"
15+
16+
$php = Get-Command 'php' | Select-Object -ExpandProperty 'Definition'
17+
$dname = (Get-Item $php).Directory.FullName
18+
19+
$opts = '-n'
20+
if ($env:OPCACHE -ne '0') {
21+
$opts += " -d zend_extension=$dname\ext\php_opcache.dll -d opcache.enabled=1 -d opcache.enable_cli=1 -d opcache.optimization_level=0"
22+
}
23+
$opts += " $scalar_objects_dll_opt"
24+
$env:TEST_PHP_ARGS = $opts
25+
26+
$env:TEST_PHP_EXECUTABLE = $php
27+
& $php run-tests.php -q --show-diff tests
28+
if (-not $?) {
29+
throw "tests failed with errorlevel $LastExitCode"
30+
}

0 commit comments

Comments
 (0)