Skip to content

Commit

Permalink
Added AppVeyor CI
Browse files Browse the repository at this point in the history
  • Loading branch information
kjdev committed Oct 2, 2020
1 parent 62896bc commit 0327169
Show file tree
Hide file tree
Showing 7 changed files with 213 additions and 0 deletions.
67 changes: 67 additions & 0 deletions .appveyor.yml
@@ -0,0 +1,67 @@
# general configuration
version: '{branch}.{build}'

# environment configuration
image: Visual Studio 2017
clone_folder: c:\projects\snappy
environment:
BIN_SDK_VER: 2.2.0
matrix:
- PHP_VER: 7.2
ARCH: x64
TS: 0
VC: vc15
VCPKG: 0
- PHP_VER: 7.2
ARCH: x86
TS: 1
VC: vc15
VCPKG: 0
- PHP_VER: 7.3
ARCH: x64
TS: 0
VC: vc15
VCPKG: 0
- PHP_VER: 7.3
ARCH: x86
TS: 1
VC: vc15
VCPKG: 0
- PHP_VER: 7.4
ARCH: x64
TS: 0
VC: vc15
VCPKG: 0
- PHP_VER: 7.4
ARCH: x86
TS: 1
VC: vc15
VCPKG: 0
- PHP_VER: 7.4
ARCH: x64
TS: 0
VC: vc15
VCPKG: 1
- PHP_VER: 7.4
ARCH: x86
TS: 1
VC: vc15
VCPKG: 1
cache:
- c:\build-cache -> .appveyor.yml, .appveyor\install.ps1
install:
- ps: .appveyor\install.ps1
- ps: .appveyor\install_submodule.ps1
- ps: .appveyor\install_vcpkg.ps1

# build configuration
build_script:
- ps: .appveyor\build.ps1

# tests configuration
test_script:
- ps: .appveyor\test.ps1

# artifacts configuration
artifacts:
- path: php_snappy.dll
29 changes: 29 additions & 0 deletions .appveyor/build.ps1
@@ -0,0 +1,29 @@
$ErrorActionPreference = "Stop"

Set-Location C:\projects\snappy

$task = New-Item 'task.bat' -Force
Add-Content $task 'call phpize 2>&1'
Add-Content $task 'call configure --with-php-build=C:\build-cache\deps --enable-snappy --enable-debug-pack 2>&1'
Add-Content $task 'nmake /nologo 2>&1'
Add-Content $task 'exit %errorlevel%'
& "C:\build-cache\php-sdk-$env:BIN_SDK_VER\phpsdk-$env:VC-$env:ARCH.bat" -t $task
if (-not $?) {
throw "building failed with errorlevel $LastExitCode"
}

$dname = ''
if ($env:ARCH -eq 'x64') {
$dname += 'x64\'
}
$dname += 'Release';
if ($env:TS -eq '1') {
$dname += '_TS'
}
Copy-Item "$dname\php_snappy.dll" "$env:PHP_PATH\ext\php_snappy.dll"
Copy-Item "$dname\php_snappy.dll" "php_snappy.dll"

$ini = New-Item "$env:PHP_PATH\php.ini" -Force
Add-Content $ini "extension_dir=$env:PHP_PATH\ext"
Add-Content $ini 'extension=php_openssl.dll'
Add-Content $ini 'extension=php_snappy.dll'
78 changes: 78 additions & 0 deletions .appveyor/install.ps1
@@ -0,0 +1,78 @@
$ErrorActionPreference = "Stop"

if (-not (Test-Path 'C:\build-cache')) {
[void](New-Item 'C:\build-cache' -ItemType 'directory')
}

# PHP SDK
$bname = "php-sdk-$env:BIN_SDK_VER.zip"
if (-not (Test-Path C:\build-cache\$bname)) {
Invoke-WebRequest "https://github.com/microsoft/php-sdk-binary-tools/archive/$bname" -OutFile "C:\build-cache\$bname"
}
$dname0 = "php-sdk-binary-tools-php-sdk-$env:BIN_SDK_VER"
$dname1 = "php-sdk-$env:BIN_SDK_VER"
if (-not (Test-Path "C:\build-cache\$dname1")) {
Expand-Archive "C:\build-cache\$bname" "C:\build-cache"
Move-Item "C:\build-cache\$dname0" "C:\build-cache\$dname1"
}

# PHP releases
Invoke-WebRequest "https://windows.php.net/downloads/releases/releases.json" -OutFile "C:\build-cache\releases.json"
$php_version = (Get-Content -Path "C:\build-cache\releases.json" | ConvertFrom-Json | ForEach-Object {
if ($_."$env:PHP_VER") {
return $_."$env:PHP_VER".version
} else {
return "$env:PHP_VER"
}
})

# PHP devel pack
$ts_part = ''
if ('0' -eq $env:TS) {
$ts_part = '-nts'
}
$bname = "php-devel-pack-$php_version$ts_part-Win32-$env:VC-$env:ARCH.zip"
if (-not (Test-Path "C:\build-cache\$bname")) {
try {
Invoke-WebRequest "https://windows.php.net/downloads/releases/$bname" -OutFile "C:\build-cache\$bname"
} catch [System.Net.WebException] {
Invoke-WebRequest "https://windows.php.net/downloads/releases/archives/$bname" -OutFile "C:\build-cache\$bname"
}
}
$dname0 = "php-$php_version-devel-$env:VC-$env:ARCH"
$dname1 = "php-$php_version$ts_part-devel-$env:VC-$env:ARCH"
if (-not (Test-Path "C:\build-cache\$dname1")) {
Expand-Archive "C:\build-cache\$bname" 'C:\build-cache'
if (-not (Test-Path "C:\build-cache\$dname0")) {
$php_normalize_version = $php_version.Split("-")[0]
$dname0 = "php-$php_normalize_version-devel-$env:VC-$env:ARCH"
}
if ($dname0 -ne $dname1) {
Move-Item "C:\build-cache\$dname0" "C:\build-cache\$dname1"
}
}
$env:PATH = "C:\build-cache\$dname1;$env:PATH"

# PHP binary
$bname = "php-$php_version$ts_part-Win32-$env:VC-$env:ARCH.zip"
if (-not (Test-Path "C:\build-cache\$bname")) {
try {
Invoke-WebRequest "https://windows.php.net/downloads/releases/$bname" -OutFile "C:\build-cache\$bname"
} catch [System.Net.WebException] {
Invoke-WebRequest "https://windows.php.net/downloads/releases/archives/$bname" -OutFile "C:\build-cache\$bname"
}
}
$dname = "php-$php_version$ts_part-Win32-$env:VC-$env:ARCH"
if (-not (Test-Path "C:\build-cache\$dname")) {
Expand-Archive "C:\build-cache\$bname" "C:\build-cache\$dname"
}
$env:PHP_PATH = "C:\build-cache\$dname"
$env:PATH = "$env:PHP_PATH;$env:PATH"

# # library dependency
# $bname = "$env:DEP-$env:VC-$env:ARCH.zip"
# if (-not (Test-Path "C:\build-cache\$bname")) {
# Invoke-WebRequest "https://windows.php.net/downloads/pecl/deps/$bname" -OutFile "C:\build-cache\$bname"
# Expand-Archive "C:\build-cache\$bname" 'C:\build-cache\deps'
# }
$env:PATH = "C:\build-cache\deps\bin;$env:PATH"
15 changes: 15 additions & 0 deletions .appveyor/install_submodule.ps1
@@ -0,0 +1,15 @@
$ErrorActionPreference = "Stop"

Set-Location C:\projects\snappy

if ($env:VCPKG -eq '0') {
$command = "git"
$args = "submodule update --init --recursive"
$process = Start-Process $command -ArgumentList $args -Wait -NoNewWindow -PassThru
if ($process.ExitCode -ne 0) {
Write-Error -Category InvalidResult -Message "$command exits with $($process.ExitCode)"
}

# Create "snappy\snappy-stubs-public.h"
Get-Content "snappy\snappy-stubs-public.h.in" | ForEach-Object { $_ -replace '\${HAVE_SYS_UIO_H_01}', "0" } | Out-File "snappy\snappy-stubs-public.h"
}
14 changes: 14 additions & 0 deletions .appveyor/install_vcpkg.ps1
@@ -0,0 +1,14 @@
$ErrorActionPreference = "Stop"

if ($env:VCPKG -eq '1' -and -not (Test-Path 'C:\build-cache\deps')) {
[void](New-Item 'C:\build-cache\deps' -ItemType 'directory')

vcpkg install "snappy:$env:ARCH-windows"
if (-not $?) {
throw "installing failed with errorlevel $LastExitCode"
}

Copy-Item "C:\tools\vcpkg\installed\$env:ARCH-windows\bin" "C:\build-cache\deps" -Recurse -Force
Copy-Item "C:\tools\vcpkg\installed\$env:ARCH-windows\include" "C:\build-cache\deps" -Recurse -Force
Copy-Item "C:\tools\vcpkg\installed\$env:ARCH-windows\lib" "C:\build-cache\deps" -Recurse -Force
}
9 changes: 9 additions & 0 deletions .appveyor/test.ps1
@@ -0,0 +1,9 @@
$ErrorActionPreference = "Stop"

Set-Location C:\projects\snappy

$env:TEST_PHP_EXECUTABLE = "$env:PHP_PATH\php.exe"
& $env:TEST_PHP_EXECUTABLE 'run-tests.php' --show-diff tests
if (-not $?) {
throw "testing failed with errorlevel $LastExitCode"
}
1 change: 1 addition & 0 deletions README.md
@@ -1,6 +1,7 @@
# Snappy Extension for PHP

[![Build Status](https://secure.travis-ci.org/kjdev/php-ext-snappy.png?branch=master)](http://travis-ci.org/kjdev/php-ext-snappy)
[![Build status](https://ci.appveyor.com/api/projects/status/20i7jiflddmfhkus/branch/master?svg=true)](https://ci.appveyor.com/project/kjdev/php-ext-snappy/branch/master)

This extension allows Snappy.

Expand Down

0 comments on commit 0327169

Please sign in to comment.