Skip to content

Commit 89cf76b

Browse files
committed
Cleaned up AppVeyor module
1 parent 9dd26d5 commit 89cf76b

File tree

2 files changed

+71
-72
lines changed

2 files changed

+71
-72
lines changed

.appveyor.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ build_script:
7070
- ps: InitializeBuildVars
7171
- '"%VSCOMNTOOLS%\VsDevCmd" %PLATFORM%'
7272
- '"%VSCOMNTOOLS%\..\..\VC\vcvarsall.bat" %ARCH%'
73-
- '%PHP_SDK_PATH%\bin\phpsdk_setvars'
73+
- phpsdk_setvars
7474
- cmd /c build-win32-php7.bat
75-
- '%DEVPACK_PATH%\phpize.bat'
76-
- 'configure --with-prefix=%PHP_PATH% --with-php-build=%DEVPACK_PATH% --disable-all --enable-zephir_parser=shared'
77-
- nmake 2> compile-errors.log 1> compile.log
75+
- phpize
76+
- cmd: 'configure --with-prefix=%PHP_PATH% --with-php-build=%DEVPACK_PATH% --disable-all --enable-zephir_parser=shared'
77+
- cmd: nmake 2> compile-errors.log 1> compile.log
7878
- ps: InitializeReleaseVars
7979
- ps: EnableExtension
8080

@@ -88,7 +88,7 @@ artifacts:
8888
name: ZephirParser
8989

9090
on_failure:
91-
- ps: PrintLogs
91+
- ps: PrintBuildArtifacts
9292
- ps: PrintVars
9393
- ps: PrintDirectoriesContent
9494
- ps: PrintPhpInfo

tests/ci/AppVeyor.psm1

Lines changed: 66 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,36 @@ Function EnsureRequiredDirectoriesPresent {
99
}
1010

1111
Function Ensure7ZipIsInstalled {
12-
If (-not (Get-Command "7z" -ErrorAction SilentlyContinue)) {
13-
$7zipInstallationDirectory = "${Env:ProgramFiles}\7-Zip"
12+
If (-not (Get-Command "7z" -ErrorAction SilentlyContinue)) {
13+
$7zipInstallationDirectory = "${Env:ProgramFiles}\7-Zip"
1414

15-
If (-not (Test-Path "$7zipInstallationDirectory")) {
16-
throw "The 7-zip file archiver is needed to use this module"
17-
}
15+
If (-not (Test-Path "$7zipInstallationDirectory")) {
16+
throw "The 7-zip file archiver is needed to use this module"
17+
}
1818

1919
$Env:Path += ";$7zipInstallationDirectory"
20-
}
20+
}
2121
}
2222

2323
Function EnsureChocolateyIsInstalled {
24-
If (-not (Get-Command "choco" -ErrorAction SilentlyContinue)) {
25-
$ChocolateyInstallationDirectory = "${Env:ProgramData}\chocolatey\bin"
24+
If (-not (Get-Command "choco" -ErrorAction SilentlyContinue)) {
25+
$ChocolateyInstallationDirectory = "${Env:ProgramData}\chocolatey\bin"
2626

27-
If (-not (Test-Path "$ChocolateyInstallationDirectory")) {
28-
throw "The choco is needed to use this module"
29-
}
27+
If (-not (Test-Path "$ChocolateyInstallationDirectory")) {
28+
throw "The choco is needed to use this module"
29+
}
3030

3131
$Env:Path += ";$ChocolateyInstallationDirectory"
32-
}
32+
}
3333
}
3434

3535
Function EnsurePandocIsInstalled {
36-
If (-not (Get-Command "pandoc" -ErrorAction SilentlyContinue)) {
37-
$PandocInstallationDirectory = "${Env:ProgramData}\chocolatey\bin"
36+
If (-not (Get-Command "pandoc" -ErrorAction SilentlyContinue)) {
37+
$PandocInstallationDirectory = "${Env:ProgramData}\chocolatey\bin"
3838

39-
If (-not (Test-Path "$PandocInstallationDirectory")) {
40-
throw "The pandoc is needed to use this module"
41-
}
39+
If (-not (Test-Path "$PandocInstallationDirectory")) {
40+
throw "The pandoc is needed to use this module"
41+
}
4242

4343
$Env:Path += ";$PandocInstallationDirectory"
4444
}
@@ -230,7 +230,7 @@ Function FormatReleaseFiles {
230230
}
231231

232232
Function SetupPhpVersionString {
233-
$RemoteUrl = 'http://windows.php.net/downloads/releases/sha1sum.txt';
233+
$RemoteUrl = 'http://windows.php.net/downloads/releases/sha1sum.txt'
234234
$DestinationPath = "${Env:Temp}\php-sha1sum.txt"
235235

236236
If (-not [System.IO.File]::Exists($DestinationPath)) {
@@ -293,9 +293,7 @@ Function EnableExtension {
293293
}
294294
}
295295

296-
Function PrintLogs {
297-
Set-Location -Path "${Env:APPVEYOR_BUILD_FOLDER}"
298-
296+
Function PrintBuildArtifacts {
299297
If (Test-Path -Path "${Env:APPVEYOR_BUILD_FOLDER}\compile-errors.log") {
300298
Get-Content -Path "${Env:APPVEYOR_BUILD_FOLDER}\compile-errors.log"
301299
}
@@ -316,9 +314,7 @@ Function PrintVars {
316314
}
317315

318316
Function PrintDirectoriesContent {
319-
If (Test-Path -Path "${Env:APPVEYOR_BUILD_FOLDER}") {
320-
Get-ChildItem -Path "${Env:APPVEYOR_BUILD_FOLDER}"
321-
}
317+
Get-ChildItem -Path "${Env:APPVEYOR_BUILD_FOLDER}"
322318

323319
If (Test-Path -Path "C:\Downloads") {
324320
Get-ChildItem -Path "C:\Downloads"
@@ -331,54 +327,52 @@ Function PrintDirectoriesContent {
331327

332328
Function PrintPhpInfo {
333329
$IniFile = "${Env:PHP_PATH}\php.ini"
334-
335-
If (Test-Path -Path "${IniFile}") {
336-
Get-Content -Path "${IniFile}"
337-
}
338-
339330
$PhpExe = "${Env:PHP_PATH}\php.exe"
340331

341-
If (Test-Path -Path "${IniFile}") {
332+
If (Test-Path -Path "${PhpExe}") {
342333
& "${PhpExe}" -v
343334
& "${PhpExe}" -m
335+
& "${PhpExe}" -i
336+
} ElseIf (Test-Path -Path "${IniFile}") {
337+
Get-Content -Path "${IniFile}"
344338
}
345339
}
346340

347341
Function Expand-Item7zip {
348-
param(
349-
[Parameter(Mandatory=$true)]
350-
[string] $Archive,
351-
[Parameter(Mandatory=$true)]
352-
[string] $Destination
353-
)
354-
355-
If (-not (Test-Path -Path $Archive -PathType Leaf)) {
356-
throw "Specified archive File is invalid: [$Archive]"
357-
}
358-
359-
If (-not (Test-Path -Path $Destination -PathType Container)) {
360-
New-Item $Destination -ItemType Directory | Out-Null
361-
}
362-
363-
$result = (& 7z x "$Archive" "-o$Destination" -aoa -bd -y -r)
364-
365-
$7zipExitCode = $LASTEXITCODE
366-
If ($7zipExitCode -ne 0) {
367-
throw "An error occurred while unzipping [$Archive] to [$Destination]. 7Zip Exit Code was [$7zipExitCode]"
368-
}
342+
param(
343+
[Parameter(Mandatory=$true)]
344+
[System.String] $Archive,
345+
[Parameter(Mandatory=$true)]
346+
[System.String] $Destination
347+
)
348+
349+
If (-not (Test-Path -Path $Archive -PathType Leaf)) {
350+
throw "Specified archive File is invalid: [$Archive]"
351+
}
352+
353+
If (-not (Test-Path -Path $Destination -PathType Container)) {
354+
New-Item $Destination -ItemType Directory | Out-Null
355+
}
356+
357+
$result = (& 7z x "$Archive" "-o$Destination" -aoa -bd -y -r)
358+
359+
$7zipExitCode = $LASTEXITCODE
360+
If ($7zipExitCode -ne 0) {
361+
throw "An error occurred while unzipping [$Archive] to [$Destination]. 7Zip Exit Code was [$7zipExitCode]"
362+
}
369363
}
370364

371365
Function DownloadFile {
372-
param(
373-
[Parameter(Mandatory=$true)]
374-
[string] $RemoteUrl,
375-
[Parameter(Mandatory=$true)]
376-
[string] $DestinationPath
366+
param(
367+
[Parameter(Mandatory=$true)]
368+
[System.String] $RemoteUrl,
369+
[Parameter(Mandatory=$true)]
370+
[System.String] $DestinationPath
377371
)
378372

379-
$Retrycount = 5
380-
$Retrycount = 0
381-
$Completed = $false
373+
$RetryMax = 5
374+
$RetryCount = 0
375+
$Completed = $false
382376

383377
$WebClient = new-object System.Net.WebClient
384378

@@ -387,24 +381,29 @@ Function DownloadFile {
387381
$WebClient.DownloadFile($RemoteUrl, $DestinationPath)
388382
$Completed = $true
389383
} Catch {
390-
If ($Retrycount -ge $Retrycount) {
384+
If ($RetryCount -ge $RetryMax) {
391385
$ErrorMessage = $_.Exception.Message
392386
Write-Host "Error downloadingig ${RemoteUrl}: $ErrorMessage"
393387
$Completed = $true
394388
} Else {
395-
$Retrycount++
389+
$RetryCount++
396390
}
397391
}
398392
}
399393
}
400394

401395
Function AppendSessionPath {
402-
$PathsCollection = @("C:\Program Files (x86)\MSBuild\${Env:VC_VERSION}.0\Bin")
403-
$PathsCollection += "C:\Program Files (x86)\Microsoft Visual Studio ${Env:VC_VERSION}.0\VC"
404-
$PathsCollection += "C:\Program Files (x86)\Microsoft Visual Studio ${Env:VC_VERSION}.0\VC\bin"
405-
$PathsCollection += "${Env:PHP_SDK_PATH}\bin"
406-
$PathsCollection += "${Env:PHP_PATH}\bin"
407-
$PathsCollection += "${Env:PHP_PATH}"
396+
[string[]] $PathsCollection = @(
397+
"${Env:VSCOMNTOOLS}\..\..\VC",
398+
"C:\Program Files (x86)\MSBuild\${Env:VC_VERSION}.0\Bin",
399+
"C:\Program Files (x86)\Microsoft Visual Studio ${Env:VC_VERSION}.0\VC",
400+
"C:\Program Files (x86)\Microsoft Visual Studio ${Env:VC_VERSION}.0\VC\bin",
401+
"${Env:VSCOMNTOOLS}",
402+
"${Env:PHP_PATH}"
403+
"${Env:PHP_PATH}\bin"
404+
"${Env:PHP_SDK_PATH}\bin",
405+
"${Env:DEVPACK_PATH}"
406+
)
408407

409408
$CurrentPath = (Get-Item -Path ".\" -Verbose).FullName
410409

0 commit comments

Comments
 (0)