Skip to content

Commit 2fde5fa

Browse files
committed
Add windows builds flow
1 parent b20c9fd commit 2fde5fa

File tree

1 file changed

+216
-0
lines changed

1 file changed

+216
-0
lines changed

.github/workflows/ci.yml

Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- 'wip-*'
7+
paths-ignore:
8+
- '*.md'
9+
pull_request:
10+
branches:
11+
- master
12+
- development
13+
schedule:
14+
- cron: '0 11 * * *'
15+
16+
env:
17+
PHP_SDK_VERSION: 2.2.0
18+
PHP_DEVPACK: C:\tools\php-devpack
19+
PHP_SDK_PATH: C:\tools\php-sdk
20+
EXTENSION_FILE: php_zephir_parser.dll
21+
22+
jobs:
23+
windows:
24+
# To prevent build a particular commit use
25+
# git commit -m "......... [win skip] - skip Windows builds only"
26+
# git commit -m "......... [ci skip] - skip all builds"
27+
if: "!contains(github.event.head_commit.message, '[win skip]') || !contains(github.event.head_commit.message, '[ci skip]') "
28+
29+
strategy:
30+
fail-fast: false
31+
32+
matrix:
33+
php: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
34+
arch: ['x86', 'x64']
35+
build_type: ['ts', 'nts']
36+
37+
include:
38+
- php: '7.0'
39+
vc_num: 14
40+
vc_prefix: 'vc'
41+
os: windows-2016
42+
43+
- php: '7.1'
44+
vc_num: 14
45+
vc_prefix: 'vc'
46+
os: windows-2016
47+
48+
- php: '7.2'
49+
vc_num: 15
50+
vc_prefix: 'vc'
51+
os: windows-2016
52+
53+
- php: '7.3'
54+
vc_num: 15
55+
vc_prefix: 'vc'
56+
os: windows-2016
57+
58+
- php: '7.4'
59+
vc_num: 15
60+
vc_prefix: 'vc'
61+
os: windows-2016
62+
63+
- php: '8.0'
64+
vc_num: 16
65+
vc_prefix: 'vs'
66+
os: windows-2019
67+
68+
name: "PHP-${{ matrix.php }}-${{ matrix.build_type }}-win32-${{ matrix.vc_prefix }}${{ matrix.vc_num }}-${{ matrix.arch }}"
69+
runs-on: ${{ matrix.os}}
70+
71+
steps:
72+
- uses: actions/checkout@v2
73+
with:
74+
fetch-depth: 1
75+
76+
- name: Setup PHP
77+
uses: shivammathur/setup-php@v2
78+
with:
79+
php-version: ${{ matrix.php }}
80+
coverage: none
81+
env:
82+
PHPTS: ${{ matrix.build_type }}
83+
84+
- name: Set Environment Variables
85+
run: |
86+
Write-Output "PHP_VERSION=$(php -r 'echo phpversion();')" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
87+
Write-Output "PHP_MINOR=${{ matrix.php }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
88+
Write-Output "TEST_PHP_EXECUTABLE=${env:PHPROOT}\php.exe" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
89+
Write-Output "BUILD_TYPE=${{ matrix.build_type }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
90+
Write-Output "VC_VERSION=${{ matrix.vc_num }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
91+
Write-Output "PHP_ARCH=${{ matrix.arch }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
92+
Write-Output "BUILD_VERSION=${env:GITHUB_RUN_NUMBER}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
93+
94+
- name: Setup Common Environmet
95+
run: |
96+
Import-Module .\.ci\win-ci-tools.psm1
97+
SetupCommonEnvironment
98+
InitializeReleaseVars
99+
100+
- name: Cache Downloads
101+
uses: actions/cache@v2
102+
with:
103+
path: C:\Downloads
104+
key: ${{ runner.os }}-zephir_parser-php-${{ matrix.php }}-${{ matrix.build_type }}-win32-${{ matrix.vc_prefix }}${{ matrix.vc_num }}-${{ matrix.arch }}
105+
106+
- name: Install System Dependencies
107+
run: |
108+
choco install -y --no-progress --cache-location=C:\Downloads\Choco pandoc
109+
110+
- name: Install PHP SDK Binary Tools
111+
run: |
112+
Import-Module .\.ci\win-ci-tools.psm1
113+
InstallPhpSdk
114+
115+
- name: Install PHP Dev pack
116+
run: |
117+
Import-Module .\.ci\win-ci-tools.psm1
118+
InstallPhpDevPack
119+
120+
- name: Install MSVC Compiler Tool
121+
uses: ilammy/msvc-dev-cmd@v1
122+
with:
123+
arch: ${{ matrix.arch }}
124+
125+
- name: Set PHP SDK Environment variables
126+
shell: cmd
127+
run: |
128+
call C:\tools\php-sdk\phpsdk-${{ matrix.vc_prefix }}${{ matrix.vc_num }}-${{ matrix.arch }}.bat
129+
call C:\tools\php-sdk\bin\phpsdk_setvars.bat
130+
131+
- name: Parse Zephir Parser (Lemon)
132+
shell: cmd
133+
run: |
134+
call C:\tools\php-sdk\bin\phpsdk_setvars.bat
135+
powershell.exe -File .\.ci\lemon-parser.ps1
136+
137+
- name: Phpize
138+
shell: cmd
139+
run: |
140+
call C:\tools\php-devpack\phpize.bat
141+
142+
- name: Configure
143+
shell: cmd
144+
run: |
145+
call C:\tools\php-sdk\phpsdk-${{ matrix.vc_prefix }}${{ matrix.vc_num }}-${{ matrix.arch }}.bat
146+
call C:\tools\php-sdk\bin\phpsdk_setvars.bat
147+
configure --with-codegen-arch=yes --with-prefix=C:\php --with-php-build=C:\php-devpack --disable-all --enable-zephir-parser=shared
148+
149+
- name: Compile
150+
shell: cmd
151+
run: |
152+
call C:\tools\php-sdk\phpsdk-${{ matrix.vc_prefix }}${{ matrix.vc_num }}-${{ matrix.arch }}.bat
153+
call C:\tools\php-sdk\bin\phpsdk_setvars.bat
154+
nmake
155+
156+
- name: Get Zephir Parser extension info
157+
run: |
158+
Get-Php "${env:PHPROOT}"
159+
Get-PhpExtension "${env:RELEASE_DLL_PATH}"
160+
& ${env:TEST_PHP_EXECUTABLE} --ini
161+
162+
- name: Enable Zephir Parser
163+
run: |
164+
Add-Content -Path "${env:PHPROOT}\php.ini" -Value 'extension=php_zephir_parser.dll'
165+
Copy-Item -Path "${env:RELEASE_DLL_PATH}" -Destination "${env:PHPROOT}\ext\"
166+
167+
# Run tests only for x64 PHP builds (Windows currently not support setup php with multi arch)
168+
- name: Run Tests
169+
if: matrix.arch == 'x64'
170+
run: |
171+
& ${env:TEST_PHP_EXECUTABLE} --ri 'Zephir Parser'
172+
& ${env:TEST_PHP_EXECUTABLE} run-tests.php
173+
174+
- name: Prepare Release Package
175+
run: |
176+
Import-Module .\.ci\win-ci-tools.psm1
177+
PrepareReleasePackage `
178+
-PhpVersion $Env:PHP_VERSION `
179+
-BuildType $Env:BUILD_TYPE `
180+
-Platform $Env:PLATFORM `
181+
-ZipballName $Env:RELEASE_ZIPBALL `
182+
-ConvertMd2Html $true `
183+
-ReleaseFiles "${Env:RELEASE_DLL_PATH}",`
184+
"${Env:GITHUB_WORKSPACE}\LICENSE",`
185+
"${Env:GITHUB_WORKSPACE}\CREDITS",`
186+
"${Env:GITHUB_WORKSPACE}\VERSION",`
187+
"${Env:GITHUB_WORKSPACE}\NO_WARRANTY"
188+
189+
- name: Upload Zephir Parser
190+
uses: actions/upload-artifact@v2
191+
with:
192+
name: zephir-parser-php-${{ matrix.php }}-${{ matrix.build_type }}-win32-${{ matrix.vc_prefix }}${{ matrix.vc_num }}-${{ matrix.arch }}
193+
path: |
194+
${{ github.workspace }}\zephir-parser-*.zip
195+
196+
- name: Check for Errors
197+
if: always()
198+
run: |
199+
Get-ChildItem (Get-Item -Path ".\" -Verbose).FullName *.log |
200+
ForEach-Object{
201+
$BaseName = $_.BaseName
202+
Write-Output "-- Log details: ${BaseName}.log --"
203+
Get-Content -Path "${env:GITHUB_WORKSPACE}\${BaseName}.log"
204+
}
205+
206+
- name: Upload Info for Debug on Fail
207+
if: failure()
208+
uses: actions/upload-artifact@v2
209+
with:
210+
retention-days: 2
211+
name: errors-zephir-parser-php-${{ matrix.php }}-${{ matrix.build_type }}-win32-${{ matrix.vc_prefix }}${{ matrix.vc_num }}-${{ matrix.arch }}
212+
path: |
213+
${{ github.workspace }}\tests
214+
${{ github.workspace }}\parser
215+
${{ github.workspace }}\Release*
216+
${{ github.workspace }}\**\Release*

0 commit comments

Comments
 (0)