feat: single setup, mass-pass progress, per-server homes, Desktop shares its library (owner review 5, v1.1.0) (#68)
CI / Build and test (push) Successful in 11m36s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 12s
Release / Build, test and publish (push) Successful in 14m56s
CI / PostgreSQL 16 integration (push) Successful in 10m11s
CI / PostgreSQL 17 integration (push) Successful in 10m15s
CI / Docker image (push) Successful in 45s
Release / Server image (push) Successful in 4m55s
CI / Build and test (push) Successful in 11m36s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 12s
Release / Build, test and publish (push) Successful in 14m56s
CI / PostgreSQL 16 integration (push) Successful in 10m11s
CI / PostgreSQL 17 integration (push) Successful in 10m15s
CI / Docker image (push) Successful in 45s
Release / Server image (push) Successful in 4m55s
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #68.
This commit is contained in:
1 parent
988068ee8e
commit
20d64af4a4
793 files changed
+23882
-2096
No files matched your search
@@ -1,10 +1,13 @@
|
||||
# Installs, runs, upgrades and removes the packed installers on a clean Windows runner (BRIEF §18): silent mode,
|
||||
# folder with a space, Add/Remove Programs entry, shortcuts, the .chronos file type, upgrade in place (files of the
|
||||
# previous version removed), user data kept, the uninstaller removing itself, and the documented exit codes.
|
||||
# previous version removed), user data kept, the uninstaller removing itself, and the documented exit codes. Then the
|
||||
# single setup: a program added to and removed from an installation in place (a changed file is kept), the separate
|
||||
# 1.0 Uploader replaced, and a 1.0 Server for Windows retained until the switches leave it out.
|
||||
param(
|
||||
[Parameter(Mandatory)] [string] $Setup1,
|
||||
[Parameter(Mandatory)] [string] $Setup2,
|
||||
[Parameter(Mandatory)] [string] $UploaderSetup,
|
||||
[Parameter(Mandatory)] [string] $LegacyUploaderSetup,
|
||||
[Parameter(Mandatory)] [string] $ServerSetup,
|
||||
[Parameter(Mandatory)] [string] $Version1,
|
||||
[Parameter(Mandatory)] [string] $Version2,
|
||||
[Parameter(Mandatory)] [string] $Screenshots
|
||||
@@ -17,7 +20,8 @@ Set-StrictMode -Version Latest
|
||||
# Set-Location does not move, and the programs get the screenshot folder as an argument.
|
||||
$Setup1 = (Resolve-Path -LiteralPath $Setup1).Path
|
||||
$Setup2 = (Resolve-Path -LiteralPath $Setup2).Path
|
||||
$UploaderSetup = (Resolve-Path -LiteralPath $UploaderSetup).Path
|
||||
$LegacyUploaderSetup = (Resolve-Path -LiteralPath $LegacyUploaderSetup).Path
|
||||
$ServerSetup = (Resolve-Path -LiteralPath $ServerSetup).Path
|
||||
$Screenshots = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Screenshots)
|
||||
|
||||
function Invoke-Program([string] $Exe, [string[]] $Arguments) {
|
||||
@@ -48,6 +52,14 @@ function Get-DefaultValue([string] $Key) {
|
||||
return (Get-Item -LiteralPath $Key).GetValue('')
|
||||
}
|
||||
|
||||
function Get-LinkTarget([string] $Link) {
|
||||
return (New-Object -ComObject WScript.Shell).CreateShortcut($Link).TargetPath
|
||||
}
|
||||
|
||||
function Get-InstallLog([string] $Directory) {
|
||||
return Get-Content -Raw -LiteralPath (Join-Path $Directory 'install-log.json') | ConvertFrom-Json
|
||||
}
|
||||
|
||||
$dir = Join-Path $env:RUNNER_TEMP 'Chronos Test'
|
||||
$entryKey = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\Chronos'
|
||||
$programs = [Environment]::GetFolderPath('Programs')
|
||||
@@ -63,9 +75,10 @@ Set-Content -LiteralPath $userFile -Value 'user data'
|
||||
Write-Host '--- Arguments'
|
||||
Assert-True ((Invoke-Program $Setup1 @('/BOGUS')) -eq 2) 'an unknown switch exits with 2 (invalid arguments)'
|
||||
Assert-True ((Invoke-Program $Setup1 @('/S', '/uninstall')) -eq 6) 'removing a product that is not installed exits with 6'
|
||||
Assert-True ((Invoke-Program $Setup2 @('/S', '/COMPONENTS=Server')) -eq 2) 'a component the setup does not ship and nothing retains exits with 2'
|
||||
|
||||
Write-Host "--- Install $Version1 into '$dir'"
|
||||
Assert-True ((Invoke-Program $Setup1 @('/S', "/DIR=$dir")) -eq 0) 'silent install exits with 0'
|
||||
Assert-True ((Invoke-Program $Setup1 @('/S', "/DIR=$dir", '/COMPONENTS=Desktop,Uploader')) -eq 0) 'silent install exits with 0'
|
||||
foreach ($file in 'Chronos.exe', 'Chronos.Uploader.exe', 'Uninstall Chronos.exe', 'install-log.json', 'legacy.txt') {
|
||||
Assert-True (Test-Path -LiteralPath (Join-Path $dir $file)) "$file installed"
|
||||
}
|
||||
@@ -76,6 +89,8 @@ Assert-True ($entry.QuietUninstallString -eq "`"$(Join-Path $dir 'Uninstall Chro
|
||||
foreach ($link in $links) { Assert-True (Test-Path -LiteralPath $link) "shortcut '$link' created" }
|
||||
Assert-True ((Get-DefaultValue 'HKCU:\Software\Classes\.chronos') -eq 'Chronos.Project') '.chronos opens with Chronos'
|
||||
Assert-True ((Get-DefaultValue 'HKCU:\Software\Classes\Chronos.Project\shell\open\command') -eq "`"$(Join-Path $dir 'Chronos.exe')`" `"%1`"") 'Chronos.Project opens the installed Chronos.exe'
|
||||
$log = Get-InstallLog $dir
|
||||
Assert-True ($log.formatVersion -eq 2 -and $null -ne $log.hashes.'Chronos.exe') 'the install log records each file with its SHA-256 (format 2)'
|
||||
|
||||
Write-Host '--- Run the installed programs'
|
||||
foreach ($program in 'Chronos.exe', 'Chronos.Uploader.exe') {
|
||||
@@ -88,8 +103,9 @@ foreach ($program in 'Chronos.exe', 'Chronos.Uploader.exe') {
|
||||
Write-Host "--- Upgrade in place to $Version2"
|
||||
Assert-True ((Invoke-Program $Setup2 @('/S')) -eq 0) 'silent upgrade exits with 0'
|
||||
Assert-True ((Get-ItemProperty -LiteralPath $entryKey).DisplayVersion -eq $Version2) "Add/Remove Programs lists version $Version2"
|
||||
Assert-True ((Get-Content -Raw -LiteralPath (Join-Path $dir 'install-log.json') | ConvertFrom-Json).version -eq $Version2) "install log records version $Version2"
|
||||
Assert-True ((Get-InstallLog $dir).version -eq $Version2) "install log records version $Version2"
|
||||
Assert-True (Test-Path -LiteralPath (Join-Path $dir 'Chronos.exe')) 'Chronos.exe still installed'
|
||||
Assert-True (Test-Path -LiteralPath (Join-Path $dir 'Chronos.Uploader.exe')) 'the Uploader installed before is kept by the upgrade'
|
||||
Assert-True (-not (Test-Path -LiteralPath (Join-Path $dir 'legacy.txt'))) 'a file only the previous version had is removed'
|
||||
foreach ($link in $links) { Assert-True (Test-Path -LiteralPath $link) "shortcut '$link' kept" }
|
||||
Assert-True (Test-Path -LiteralPath $userFile) 'user data kept by the upgrade'
|
||||
@@ -103,15 +119,79 @@ Assert-True (-not (Test-Path -LiteralPath 'HKCU:\Software\Classes\Chronos.Projec
|
||||
Assert-True ($null -eq (Get-DefaultValue 'HKCU:\Software\Classes\.chronos')) '.chronos no longer opens with Chronos'
|
||||
Assert-True (Test-Path -LiteralPath $userFile) 'user data kept by the uninstall'
|
||||
|
||||
Write-Host '--- Uploader installer: default folder, removal through the installer itself'
|
||||
$uploaderDir = Join-Path $env:LOCALAPPDATA 'Programs\Chronos Uploader'
|
||||
$uploaderKey = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\ChronosUploader'
|
||||
Assert-True ((Invoke-Program $UploaderSetup @('/S')) -eq 0) 'silent Uploader install exits with 0'
|
||||
Assert-True (Test-Path -LiteralPath (Join-Path $uploaderDir 'Chronos.Uploader.exe')) 'Uploader installed in %LOCALAPPDATA%\Programs\Chronos Uploader'
|
||||
Assert-True (Test-Path -LiteralPath $uploaderKey) 'Uploader listed in Add/Remove Programs'
|
||||
Assert-True ((Invoke-Program $UploaderSetup @('/uninstall', '/S')) -eq 0) 'silent Uploader removal exits with 0'
|
||||
Assert-True (Wait-Removed $uploaderDir) 'Uploader folder removed'
|
||||
Assert-True (-not (Test-Path -LiteralPath $uploaderKey)) 'Uploader entry removed'
|
||||
$single = Join-Path $env:LOCALAPPDATA 'Programs\Chronos'
|
||||
$uploaderLinks = @((Join-Path $programs 'Chronos Uploader.lnk'), (Join-Path $desktop 'Chronos Uploader.lnk'))
|
||||
$desktopLinks = @((Join-Path $programs 'Chronos.lnk'), (Join-Path $desktop 'Chronos.lnk'))
|
||||
|
||||
Write-Host '--- One setup: the Uploader alone, then the desktop app added, then the Uploader removed'
|
||||
Assert-True ((Invoke-Program $Setup2 @('/S', '/COMPONENTS=Uploader')) -eq 0) 'silent install of the Uploader alone exits with 0'
|
||||
Assert-True (Test-Path -LiteralPath (Join-Path $single 'Chronos.Uploader.exe')) 'Uploader installed in %LOCALAPPDATA%\Programs\Chronos'
|
||||
Assert-True (-not (Test-Path -LiteralPath (Join-Path $single 'Chronos.exe'))) 'the desktop app is not installed'
|
||||
foreach ($link in $desktopLinks) { Assert-True (-not (Test-Path -LiteralPath $link)) "no shortcut '$link'" }
|
||||
Assert-True ($null -eq (Get-DefaultValue 'HKCU:\Software\Classes\.chronos')) '.chronos is not registered without the desktop app'
|
||||
Assert-True ((Invoke-Program $Setup2 @('/S', '/COMPONENTS=Desktop,Uploader')) -eq 0) 'adding the desktop app in place exits with 0'
|
||||
Assert-True (Test-Path -LiteralPath (Join-Path $single 'Chronos.exe')) 'the desktop app is added in place'
|
||||
foreach ($link in $desktopLinks) { Assert-True (Test-Path -LiteralPath $link) "shortcut '$link' created" }
|
||||
Assert-True ((Get-DefaultValue 'HKCU:\Software\Classes\.chronos') -eq 'Chronos.Project') '.chronos opens with the added desktop app'
|
||||
# A changed file of a removed program is never deleted: setup checks it against the SHA-256 it recorded.
|
||||
$changed = Join-Path $single 'Chronos.Uploader.exe'
|
||||
[System.IO.File]::AppendAllText($changed, 'changed after setup')
|
||||
Assert-True ((Invoke-Program $Setup2 @('/S', '/COMPONENTS=Desktop')) -eq 0) 'removing the Uploader in place exits with 0'
|
||||
Assert-True (Test-Path -LiteralPath $changed) 'the Uploader file changed since setup installed it is kept'
|
||||
Assert-True (-not ((Get-InstallLog $single).components -contains 'Uploader')) 'the install log no longer lists the Uploader'
|
||||
foreach ($link in $uploaderLinks) { Assert-True (-not (Test-Path -LiteralPath $link)) "shortcut '$link' removed with the Uploader" }
|
||||
Remove-Item -LiteralPath $changed
|
||||
Assert-True ((Invoke-Program (Join-Path $single 'Uninstall Chronos.exe') @('/uninstall', '/S')) -eq 0) 'silent uninstall exits with 0'
|
||||
Assert-True (Wait-Removed $single) 'install folder removed'
|
||||
|
||||
Write-Host '--- One setup replaces the separate 1.0 Uploader'
|
||||
$legacyDir = Join-Path $env:LOCALAPPDATA 'Programs\Chronos Uploader'
|
||||
$legacyKey = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\ChronosUploader'
|
||||
$runKey = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Run'
|
||||
$approvedKey = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run'
|
||||
Assert-True ((Invoke-Program $LegacyUploaderSetup @('/S')) -eq 0) 'the separate Uploader installs'
|
||||
Assert-True (Test-Path -LiteralPath (Join-Path $legacyDir 'Chronos.Uploader.exe')) 'separate Uploader in %LOCALAPPDATA%\Programs\Chronos Uploader'
|
||||
# Its sign-in entry, turned off in Task Manager, as the Uploader and Windows write them.
|
||||
New-Item -Force -Path $runKey | Out-Null
|
||||
New-Item -Force -Path $approvedKey | Out-Null
|
||||
Set-ItemProperty -LiteralPath $runKey -Name 'Chronos Uploader' -Value "`"$(Join-Path $legacyDir 'Chronos.Uploader.exe')`" --tray"
|
||||
Set-ItemProperty -LiteralPath $approvedKey -Name 'Chronos Uploader' -Type Binary -Value ([byte[]](3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
|
||||
Assert-True ((Invoke-Program $Setup2 @('/S')) -eq 0) 'the single setup exits with 0'
|
||||
Assert-True (Test-Path -LiteralPath (Join-Path $single 'Chronos.Uploader.exe')) 'the Uploader is now in %LOCALAPPDATA%\Programs\Chronos'
|
||||
Assert-True (-not (Test-Path -LiteralPath (Join-Path $single 'Chronos.exe'))) 'only the Uploader is installed: it replaces the separate one'
|
||||
Assert-True (-not (Test-Path -LiteralPath $legacyKey)) 'the separate Uploader entry is gone'
|
||||
Assert-True (Wait-Removed $legacyDir) 'the separate Uploader folder is gone'
|
||||
Assert-True ((Get-ItemProperty -LiteralPath $runKey).'Chronos Uploader' -eq "`"$(Join-Path $single 'Chronos.Uploader.exe')`" --tray") 'the sign-in entry starts the new copy with its option'
|
||||
Assert-True ($null -ne (Get-ItemProperty -LiteralPath $approvedKey -Name 'Chronos Uploader' -ErrorAction SilentlyContinue)) 'the sign-in entry stays turned off'
|
||||
$link = Join-Path $programs 'Chronos Uploader.lnk'
|
||||
Assert-True ((Test-Path -LiteralPath $link) -and ((Get-LinkTarget $link) -eq (Join-Path $single 'Chronos.Uploader.exe'))) 'the Start menu shortcut starts the new copy'
|
||||
Assert-True (Test-Path -LiteralPath $userFile) 'user data kept by the replacement'
|
||||
Assert-True ((Invoke-Program (Join-Path $single 'Uninstall Chronos.exe') @('/uninstall', '/S')) -eq 0) 'silent uninstall exits with 0'
|
||||
Assert-True (Wait-Removed $single) 'install folder removed'
|
||||
Assert-True ($null -eq (Get-ItemProperty -LiteralPath $runKey -Name 'Chronos Uploader' -ErrorAction SilentlyContinue)) 'the sign-in entry goes with the uninstall'
|
||||
|
||||
Write-Host '--- One setup keeps a 1.0 Server for Windows until the switches leave it out'
|
||||
Assert-True ((Invoke-Program $ServerSetup @('/S', '/COMPONENTS=Desktop,Server')) -eq 0) 'the 1.0 Server installs'
|
||||
$serverLink = Join-Path $programs 'Chronos Server.lnk'
|
||||
Assert-True (Test-Path -LiteralPath $serverLink) 'its Start menu shortcut is created'
|
||||
# As Chronos 1.0 wrote it: format 1, no record of which component installed what, no hashes.
|
||||
$log = Get-InstallLog $single
|
||||
foreach ($name in 'componentFiles', 'componentShortcuts', 'componentVersions', 'hashes') { $log.PSObject.Properties.Remove($name) }
|
||||
$log.formatVersion = 1
|
||||
[System.IO.File]::WriteAllText((Join-Path $single 'install-log.json'), ($log | ConvertTo-Json -Depth 5))
|
||||
Assert-True ((Invoke-Program $Setup2 @('/S')) -eq 0) 'the upgrade exits with 0'
|
||||
Assert-True (Test-Path -LiteralPath (Join-Path $single 'Chronos.Server.exe')) 'Chronos.Server.exe is kept'
|
||||
Assert-True (Test-Path -LiteralPath (Join-Path $single 'legacy.txt')) 'a file the 1.0 log lists and this setup does not ship is kept with it'
|
||||
Assert-True (Test-Path -LiteralPath $serverLink) 'its shortcut is kept'
|
||||
$log = Get-InstallLog $single
|
||||
Assert-True (($log.components -contains 'Server') -and ($log.componentVersions.Server -eq $Version1)) 'the install log keeps the Server at its own version'
|
||||
Assert-True ((Invoke-Program $Setup2 @('/S', '/COMPONENTS=Desktop')) -eq 0) 'switches that leave the Server out exit with 0'
|
||||
Assert-True (-not (Test-Path -LiteralPath (Join-Path $single 'Chronos.Server.exe'))) 'Chronos.Server.exe is removed'
|
||||
Assert-True (-not (Test-Path -LiteralPath (Join-Path $single 'legacy.txt'))) 'the files kept with it are removed'
|
||||
Assert-True (-not (Test-Path -LiteralPath $serverLink)) 'its shortcut is removed'
|
||||
Assert-True (-not ((Get-InstallLog $single).components -contains 'Server')) 'the install log no longer lists the Server'
|
||||
Assert-True ((Invoke-Program (Join-Path $single 'Uninstall Chronos.exe') @('/uninstall', '/S')) -eq 0) 'silent uninstall exits with 0'
|
||||
Assert-True (Wait-Removed $single) 'install folder removed'
|
||||
Assert-True (Test-Path -LiteralPath $userFile) 'user data kept'
|
||||
|
||||
Write-Host 'Installer test passed.'
|
||||
Reference in new issue
Block a user