Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 0 additions & 59 deletions .appveyor.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Publish
Expand Down
34 changes: 28 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ jobs:
Remove-Item -Force -Recurse -LiteralPath C:\tools\php
}
- name: Checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
uses: actions/checkout@v7
- name: Setup
shell: powershell
run: .\test\setup.ps1
Expand All @@ -44,9 +42,7 @@ jobs:
Remove-Item -Force -Recurse -LiteralPath C:\tools\php
}
- name: Checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
uses: actions/checkout@v7
- name: Setup
shell: pwsh
run: .\test\setup.ps1
Expand All @@ -57,3 +53,29 @@ jobs:
if ($pesterResult.FailedCount -ne 0) {
throw "$($pesterResult.FailedCount) tests failed!"
}
docker:
strategy:
matrix:
include:
- name: nanoserver
shell: pwsh.exe
- name: windowsservercore
shell: powershell.exe
fail-fast: false
name: Docker (${{ matrix.name }})
# Windows containers need a base image matching the host kernel: see the FROM lines in test/Dockerfile.*
runs-on: windows-2022
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Prepare files for Docker image
run: .\test\Prepare-Dockerfile.ps1 "${{ matrix.name }}"
- name: Build Docker image
run: docker build --tag phpmanager/test .\test\docker-build
- name: Test
run: |
docker run --rm --user ContainerAdministrator --volume "$($Env:GITHUB_WORKSPACE):C:\App" --workdir C:\App --env "PM_TEST_DOCKER=1" phpmanager/test ${{ matrix.shell }} -Command '$pesterResult = .\test\pester.ps1; if ($null -eq $pesterResult) { exit 1 }; exit $pesterResult.FailedCount'
$failCount = $LASTEXITCODE
if ($failCount -ne 0) {
throw "$failCount tests failed!"
}
5 changes: 4 additions & 1 deletion PhpManager/private/Edit-FolderInPath.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@
} else {
$originalPath = [System.Environment]::GetEnvironmentVariable('Path', $target)
}
if ($null -eq $originalPath -or $originalPath -eq '') {
if ($null -eq $originalPath) {
$originalPath = ''
}
if ($originalPath -eq '') {
$parts = @()
} else {
$parts = $originalPath.Split($pathSeparator)
Expand Down
4 changes: 4 additions & 0 deletions PhpManager/private/Set-EnvVar.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
[ValidateLength(1, [int]::MaxValue)]
[string] $Name,
[Parameter(Mandatory = $true, Position = 1)]
[AllowEmptyString()]
[string] $Value,
[Parameter(Mandatory = $false, Position = 2)]
[ValidateNotNull()]
Expand All @@ -51,6 +52,9 @@
}
$needDirectRegistryAccess = [System.Environment]::GetEnvironmentVariable[0].OverloadDefinitions.Count -lt 2
if ($User) {
if (-not(Test-Path -LiteralPath 'HKCU:\Environment')) {
New-Item -Path 'HKCU:\Environment' -Force | Out-Null
}
if ($needDirectRegistryAccess) {
New-ItemProperty -Path 'HKCU:\Environment' -Name $Name -Value $Value -PropertyType ExpandString -Force | Out-Null
} else {
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/mlocati/powershell-phpmanager?branch=master&svg=true)](https://ci.appveyor.com/project/mlocati/powershell-phpmanager)
[![GitHub Actions Test Status](https://github.com/mlocati/powershell-phpmanager/actions/workflows/test.yml/badge.svg)](https://github.com/mlocati/powershell-phpmanager/actions?query=workflow:Test)
[![PowerShell Gallery Download Count](https://img.shields.io/powershellgallery/dt/PhpManager?label=downloads%20from%20PSGallery)](https://www.powershellgallery.com/packages/PhpManager)
[![Github Releases Download Count](https://img.shields.io/github/downloads/mlocati/powershell-phpmanager/total?label=downloads%20from%20GitHub)](https://github.com/mlocati/powershell-phpmanager/releases)
Expand Down
9 changes: 6 additions & 3 deletions test/Dockerfile.nanoserver
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# escape=`

FROM mcr.microsoft.com/windows/nanoserver:10.0.14393.2007
# Nano Server has no PowerShell: use the image published by the PowerShell team
FROM mcr.microsoft.com/powershell:lts-nanoserver-ltsc2022

SHELL ["powershell", "-Command"]
USER ContainerAdministrator

COPY vcruntime140.dll C:/Windows/System32/
SHELL ["pwsh", "-Command"]

COPY *.dll C:/Windows/System32/

COPY setup-nodejs.ps1 C:/
RUN C:\setup-nodejs.ps1
Expand Down
17 changes: 0 additions & 17 deletions test/Dockerfile.nanoserver.ps1

This file was deleted.

2 changes: 1 addition & 1 deletion test/Dockerfile.windowsservercore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# escape=`

FROM mcr.microsoft.com/windows/servercore:10.0.14393.2007
FROM mcr.microsoft.com/windows/servercore:ltsc2022

SHELL ["powershell", "-Command"]

Expand Down
18 changes: 0 additions & 18 deletions test/Dockerfile.windowsservercore.ps1

This file was deleted.

12 changes: 12 additions & 0 deletions test/Prepare-Dockerfile.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
param ([string] $DockerImage)

$dockerBuildPath = Join-Path -Path $PSScriptRoot -ChildPath docker-build
if (-Not(Test-Path -LiteralPath $dockerBuildPath)) {
New-Item -ItemType Directory -Path $dockerBuildPath | Out-Null
}
Copy-Item -LiteralPath "$($Env:SystemRoot)\System32\vcruntime140.dll" -Destination $dockerBuildPath
Copy-Item -LiteralPath "$($Env:SystemRoot)\System32\vcruntime140_1.dll" -Destination $dockerBuildPath
Copy-Item -LiteralPath "$($Env:SystemRoot)\System32\vcomp140.dll" -Destination $dockerBuildPath
Copy-Item -LiteralPath (Join-Path -Path $PSScriptRoot -ChildPath setup-nodejs.ps1) -Destination $dockerBuildPath
Copy-Item -LiteralPath (Join-Path -Path $PSScriptRoot -ChildPath setup.ps1) -Destination $dockerBuildPath
Copy-Item -LiteralPath (Join-Path -Path $PSScriptRoot -ChildPath "Dockerfile.$DockerImage") -Destination (Join-Path -Path $dockerBuildPath -ChildPath Dockerfile)
2 changes: 1 addition & 1 deletion test/pester.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

$Global:ProgressPreference = 'SilentlyContinue'

Import-Module -Name Pester -MinimumVersion 4.5 -MaximumVersion 4.9999.9999
Import-Module -Name Pester -MinimumVersion 4.5 -MaximumVersion 4.9999.9999 -ErrorAction Stop

New-Variable -Scope Global -Option ReadOnly -Name PHPMANAGER_MODULEPATH -Value (Split-Path -LiteralPath $PSScriptRoot | Join-Path -ChildPath PhpManager) -Force

Expand Down
2 changes: 1 addition & 1 deletion test/setup-nodejs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ Expand-Archive -LiteralPath C:\nodejs.zip -DestinationPath 'C:\Program Files'
Remove-Item -LiteralPath C:\nodejs.zip
Rename-Item -LiteralPath "C:\Program Files\node-v$version" -NewName 'C:\Program Files\NodeJS'
$newPath = "$Env:Path;C:\Program Files\NodeJS"
setx.exe Path $newPath /m
[Environment]::SetEnvironmentVariable('Path', $newPath, 'Machine')
$Env:Path = $newPath
16 changes: 11 additions & 5 deletions test/setup.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
Write-Host "Setting up test dependencies"
$pcInfo = Get-ComputerInfo
Write-Host " - Windows installation type: $($pcInfo.WindowsInstallationType)"
Write-Host " - Windows version name: $($pcInfo.WindowsProductName)"
$ErrorActionPreference = 'Stop'

Write-Host "Setting up test dependencies"
# Get-ComputerInfo is not available on Nano Server
$winInfo = Get-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'
Write-Host " - Windows installation type: $($winInfo.InstallationType)"
Write-Host " - Windows version name: $($winInfo.ProductName)"
Write-Host " - PowerShell edition: $($PSVersionTable.PSEdition)"
Write-Host " - PowerShell version: $($PSVersionTable.PSVersion.ToString())"
try {
Expand Down Expand Up @@ -56,8 +59,11 @@ if (-Not($pester)) {
}
if (-Not($pester)) {
Write-Host ' - installing Pester'
Install-Module -Name Pester -Force -SkipPublisherCheck -MinimumVersion '4.5' -MaximumVersion '4.9999.9999'
Install-Module -Name Pester -Force -SkipPublisherCheck -Scope AllUsers -MinimumVersion '4.5' -MaximumVersion '4.9999.9999'
$pester = Get-Module -ListAvailable | Where-Object { $_.Name -eq 'Pester' -and $_.Version -ge '4.5' -and $_.Version -le '4.9999.9999' }
if (-Not($pester)) {
throw 'Failed to install Pester'
}
}
}
Write-Host " - Pester version: $($pester.Version.ToString())"
2 changes: 1 addition & 1 deletion test/tests/Get-PhpVersionFromUrl.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Describe 'Get-PhpVersionFromUrl' {
}
It 'parses a release candidate with build number' {
$v = Get-PhpVersionFromUrl -Url 'php-8.6.0RC4-2-nts-Win32-vs18-x64.zip' -ReleaseState QA
$v.FullVersion | Should -BeExactly '8.6.0RC4'
$v.FullVersion | Should -BeExactly '8.6.0rc4'
$v.Build | Should -Be 2
}
It 'prefers higher build numbers of the same version' {
Expand Down
2 changes: 1 addition & 1 deletion test/tests/Install-Composer.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
Remove-Item -LiteralPath $composerPath -Recurse -Force
}
try {
Install-Php -Version 7.1.0 -Architecture x64 -ThreadSafe $true -Path $phpPath
Install-Php -Version 8.0.0 -Architecture x64 -ThreadSafe $true -Path $phpPath
Enable-PhpExtension -Extension curl,openssl -Path $phpPath
Update-PhpCAInfo -Path $phpPath
Install-Composer -Path $composerPath -PhpPath $phpPath -Scope User -NoAddToPath -NoCache
Expand Down
16 changes: 8 additions & 8 deletions test/tests/Install-Get-Update-Uninstall-Php.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
Describe 'Install-Get-Update-Uninstall-Php' {

Mock -ModuleName PhpManager Get-PhpDownloadCache { return Join-Path -Path $Global:PHPMANAGER_TESTPATH -ChildPath download-cache }
$isNanoServer = (Get-ComputerInfo -Property WindowsInstallationType).WindowsInstallationType -eq 'Nano Server'
$isNanoServer = (Get-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name InstallationType).InstallationType -eq 'Nano Server'
$phpPath = Join-Path -Path $Global:PHPMANAGER_TESTINSTALLS -ChildPath (New-Guid).Guid
It 'should install/get/update/remove PHP' {
if (Test-Path -LiteralPath $phpPath) {
Remove-Item -LiteralPath $phpPath -Recurse -Force
}
try {
Install-Php -Version 7.1.0 -Architecture x64 -ThreadSafe $true -Path $phpPath
Install-Php -Version 8.0.0 -Architecture x64 -ThreadSafe $true -Path $phpPath
$initialPhpVersion = Get-Php -Path $phpPath
$initialPhpVersion | Should -Not -BeNullOrEmpty
$initialPhpVersion.GetType().FullName | Should -BeExactly 'PhpVersionInstalled'
$initialPhpVersion.Version | Should -BeOfType [string]
$initialPhpVersion.Version | Should -BeExactly '7.1.0'
$initialPhpVersion.MajorMinorVersion | Should -BeExactly '7.1'
$initialPhpVersion.Version | Should -BeExactly '8.0.0'
$initialPhpVersion.MajorMinorVersion | Should -BeExactly '8.0'
$initialPhpVersion.ComparableVersion | Should -BeOfType [version]
$initialPhpVersion.UnstabilityLevel | Should -BeNullOrEmpty
$initialPhpVersion.UnstabilityVersion | Should -BeNullOrEmpty
Expand All @@ -33,7 +33,7 @@
$updatedPhpVersion | Should -Not -BeNullOrEmpty
$updatedPhpVersion.GetType().FullName | Should -BeExactly 'PhpVersionInstalled'
$updatedPhpVersion.Version | Should -BeOfType [string]
$updatedPhpVersion.Version | Should -Match '^7\.1\.'
$updatedPhpVersion.Version | Should -Match '^8\.0\.'
$updatedPhpVersion.ComparableVersion | Should -BeOfType [version]
$updatedPhpVersion.ComparableVersion | Should -BeGreaterThan $initialPhpVersion.ComparableVersion
$updatedPhpVersion.UnstabilityLevel | Should -BeNullOrEmpty
Expand Down Expand Up @@ -177,13 +177,13 @@
Remove-Item -LiteralPath $phpPath -Recurse -Force
}
try {
Install-Php -Version 7.1.0 -Architecture x64 -ThreadSafe $true -Path $phpPath
Install-Php -Version 8.0.0 -Architecture x64 -ThreadSafe $true -Path $phpPath
Get-PhpIniKey -Key display_errors -Path $phpPath | Should -BeNullOrEmpty
Uninstall-Php -Path $phpPath
Install-Php -Version 7.1.0 -Architecture x64 -ThreadSafe $true -Path $phpPath -InitialPhpIni Development
Install-Php -Version 8.0.0 -Architecture x64 -ThreadSafe $true -Path $phpPath -InitialPhpIni Development
Get-PhpIniKey -Key display_errors -Path $phpPath | Should -BeExactly 'On'
Uninstall-Php -Path $phpPath
Install-Php -Version 7.1.0 -Architecture x64 -ThreadSafe $true -Path $phpPath -InitialPhpIni Production
Install-Php -Version 8.0.0 -Architecture x64 -ThreadSafe $true -Path $phpPath -InitialPhpIni Production
Get-PhpIniKey -Key display_errors -Path $phpPath | Should -BeExactly 'Off'
} finally {
try {
Expand Down