Skip to content

Instantly share code, notes, and snippets.

@cmb69
Created November 22, 2020 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmb69/2e27d4da00a776ddde7aea8584bd9649 to your computer and use it in GitHub Desktop.
Save cmb69/2e27d4da00a776ddde7aea8584bd9649 to your computer and use it in GitHub Desktop.
ext-fiber AppVeyor CI
From 2da6ec6f9a622ae22dea8cd8c98d57085b5904d0 Mon Sep 17 00:00:00 2001
From: "Christoph M. Becker" <cmbecker69@gmx.de>
Date: Sun, 22 Nov 2020 18:33:08 +0100
Subject: [PATCH] Appveyor CI integration
Besides building the DLLs and running the tests, we also create
downloadable binary packages for Windows users.
---
.appveyor.yml | 34 +++++++++++++++++++++++
.appveyor/build.ps1 | 13 +++++++++
.appveyor/install.ps1 | 64 +++++++++++++++++++++++++++++++++++++++++++
.appveyor/package.ps1 | 26 ++++++++++++++++++
.appveyor/test.ps1 | 30 ++++++++++++++++++++
.gitignore | 2 ++
6 files changed, 169 insertions(+)
create mode 100644 .appveyor.yml
create mode 100644 .appveyor/build.ps1
create mode 100644 .appveyor/install.ps1
create mode 100644 .appveyor/package.ps1
create mode 100644 .appveyor/test.ps1
diff --git a/.appveyor.yml b/.appveyor.yml
new file mode 100644
index 0000000..0e29b9a
--- /dev/null
+++ b/.appveyor.yml
@@ -0,0 +1,34 @@
+# general configuration
+version: '{branch}.{build}'
+
+# environment configuration
+image: Visual Studio 2019
+clone_folder: C:\projects\ext-fiber
+environment:
+ BIN_SDK_VER: 2.2.0
+ matrix:
+ - PHP_VER: 8.0
+ TS: 0
+ VC: vs16
+ ARCH: x64
+ OPCACHE: 0
+ - PHP_VER: 8.0
+ TS: 1
+ VC: vs16
+ ARCH: x64
+ OPCACHE: 1
+cache:
+ - C:\build-cache -> .appveyor.yml, .appveyor\install.ps1
+install:
+ - ps: .appveyor\install.ps1
+
+# build configuration
+build_script:
+ - ps: .appveyor\build.ps1
+
+after_build:
+ - ps: .appveyor\package.ps1
+
+# tests configuration
+test_script:
+ - ps: .appveyor\test.ps1
diff --git a/.appveyor/build.ps1 b/.appveyor/build.ps1
new file mode 100644
index 0000000..a2a4775
--- /dev/null
+++ b/.appveyor/build.ps1
@@ -0,0 +1,13 @@
+$ErrorActionPreference = "Stop"
+
+Set-Location 'C:\projects\ext-fiber'
+
+$task = New-Item 'task.bat' -Force
+Add-Content $task "call phpize 2>&1"
+Add-Content $task "call configure --enable-fiber --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 "build failed with errorlevel $LastExitCode"
+}
diff --git a/.appveyor/install.ps1 b/.appveyor/install.ps1
new file mode 100644
index 0000000..fbcd032
--- /dev/null
+++ b/.appveyor/install.ps1
@@ -0,0 +1,64 @@
+$ErrorActionPreference = "Stop"
+
+if (-not (Test-Path 'C:\build-cache')) {
+ [void](New-Item 'C:\build-cache' -ItemType 'directory')
+}
+
+$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"
+}
+
+$gareleases = Invoke-WebRequest "https://windows.php.net/downloads/releases/releases.json" | ConvertFrom-Json
+$qareleases = Invoke-WebRequest "https://windows.php.net/downloads/qa/releases.json" | ConvertFrom-Json
+$garev = [regex]::split($gareleases.$env:PHP_VER.version, '[^\d]')[2]
+$qarev = [regex]::split($qareleases.$env:PHP_VER.version, '[^\d]')[2]
+if ($qarev -gt $garev) {
+ $phpversion = $qareleases.$env:PHP_VER.version
+ $phprelease = 'QA'
+} else {
+ $phpversion = $gareleases.$env:PHP_VER.version
+ $phprelease = 'GA'
+}
+
+$ts_part = ''
+if ($env:TS -eq '0') {
+ $ts_part += '-nts'
+}
+$bname = "php-devel-pack-$phpversion$ts_part-Win32-$env:VC-$env:ARCH.zip"
+if (-not (Test-Path "C:\build-cache\$bname")) {
+ if ($phprelease -eq "GA") {
+ Invoke-WebRequest "https://windows.php.net/downloads/releases/$bname" -OutFile "C:\build-cache\$bname"
+ } else {
+ Invoke-WebRequest "https://windows.php.net/downloads/qa/$bname" -OutFile "C:\build-cache\$bname"
+ }
+}
+$dname0 = "php-$phpversion-devel-$env:VC-$env:ARCH"
+$dname1 = "php-$phpversion$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 ($dname0 -ne $dname1) {
+ Move-Item "C:\build-cache\$dname0" "C:\build-cache\$dname1"
+ }
+}
+$env:PATH = "C:\build-cache\$dname1;$env:PATH"
+
+$bname = "php-$phpversion$ts_part-Win32-$env:VC-$env:ARCH.zip"
+if (-not (Test-Path "C:\build-cache\$bname")) {
+ if ($phprelease -eq "GA") {
+ Invoke-WebRequest "https://windows.php.net/downloads/releases/$bname" -OutFile "C:\build-cache\$bname"
+ } else {
+ Invoke-WebRequest "https://windows.php.net/downloads/qa/$bname" -OutFile "C:\build-cache\$bname"
+ }
+}
+$dname = "php-$phpversion$ts_part-$env:VC-$env:ARCH"
+if (-not (Test-Path "C:\build-cache\$dname")) {
+ Expand-Archive "C:\build-cache\$bname" "C:\build-cache\$dname"
+}
+$env:PATH = "c:\build-cache\$dname;$env:PATH"
diff --git a/.appveyor/package.ps1 b/.appveyor/package.ps1
new file mode 100644
index 0000000..8900f7e
--- /dev/null
+++ b/.appveyor/package.ps1
@@ -0,0 +1,26 @@
+$ErrorActionPreference = "Stop"
+
+if ($env:TS -eq '0') {
+ $ts_part = 'nts'
+} else {
+ $ts_part = 'ts';
+}
+
+if ($env:APPVEYOR_REPO_TAG -eq "true") {
+ $bname = "php_fiber-$env:APPVEYOR_REPO_TAG_NAME-$env:PHP_VER-$ts_part-$env:VC-$env:ARCH"
+} else {
+ $bname = "php_fiber-$($env:APPVEYOR_REPO_COMMIT.substring(0, 8))-$env:PHP_VER-$ts_part-$env:VC-$env:ARCH"
+}
+$zip_bname = "$bname.zip"
+
+$dir = 'C:\projects\ext-fiber\';
+if ($env:ARCH -eq 'x64') {
+ $dir += 'x64\'
+}
+$dir += 'Release'
+if ($env:TS -eq '1') {
+ $dir += '_TS'
+}
+
+Compress-Archive "$dir\php_fiber.dll", "$dir\php_fiber.pdb", "C:\projects\fiber\LICENSE" "C:\$zip_bname"
+Push-AppveyorArtifact "C:\$zip_bname"
diff --git a/.appveyor/test.ps1 b/.appveyor/test.ps1
new file mode 100644
index 0000000..ce72f62
--- /dev/null
+++ b/.appveyor/test.ps1
@@ -0,0 +1,30 @@
+$ErrorActionPreference = "Stop"
+
+$dir = 'C:\projects\ext-fiber\'
+if ($env:ARCH -eq 'x64') {
+ $dir += 'x64\'
+}
+$dir += 'Release'
+if ($env:TS -eq '1') {
+ $dir += '_TS'
+}
+
+$fiber_dll_opt = "-d extension=$dir\php_fiber.dll"
+
+Set-Location "C:\projects\ext-fiber"
+
+$php = Get-Command 'php' | Select-Object -ExpandProperty 'Definition'
+$dname = (Get-Item $php).Directory.FullName
+
+$opts = '-n'
+if ($env:OPCACHE -ne '0') {
+ $opts += " -d zend_extension=$dname\ext\php_opcache.dll -d opcache.enabled=1 -d opcache.enable_cli=1 -d opcache.optimization_level=0"
+}
+$opts += " $fiber_dll_opt"
+$env:TEST_PHP_ARGS = $opts
+
+$env:TEST_PHP_EXECUTABLE = $php
+& $php run-tests.php -q --show-diff tests
+if (-not $?) {
+ throw "tests failed with errorlevel $LastExitCode"
+}
diff --git a/.gitignore b/.gitignore
index 5136d7d..9ff75e2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,7 @@
.*
!.gitignore
+!.appveyor.yml
+!.appveyor
!.travis.yml
*.cache
--
2.29.2.windows.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment