diff --git a/.github/workflows/.common.yml b/.github/workflows/.common.yml index 5944ba8f..8ce53048 100644 --- a/.github/workflows/.common.yml +++ b/.github/workflows/.common.yml @@ -6,11 +6,17 @@ on: type: string default: ${{ github.workflow }} test: - description: Test + description: Test update type: boolean force: description: Force update type: boolean + test_cases: + description: | + List of test cases + - {title} + {script} + type: string jobs: update: @@ -113,6 +119,32 @@ jobs: with: name: Packages + - name: Tests before install + if: inputs.test_cases + run: | + if ($env:debug) { + $VerbosePreference = $DebugPreference = $InformationPreference = "Continue" + } + $test_cases = $env:test_cases -split "^-\s+(.+)\s*$", 0, "Multiline" + for ($i = 1; $i -lt $test_cases.length - 1; $i += 2) { + try { + $out = @() + Invoke-Expression $test_cases[$i + 1] *>&1 | ForEach-Object { $out += $_ } + if ($LASTEXITCODE) { throw "Test failed." } + "❌ {0}" -f $test_cases[$i] | Write-Host + $out | Out-Host + return $true + } catch { + "✅ {0}" -f $test_cases[$i] | Write-Host + } + } + if ($results -contains $true) { + throw "Tests failed." + } + env: + debug: ${{ runner.debug }} + test_cases: ${{ inputs.test_cases }} + - name: Install package run: | $debug = if ($env:debug) { "--verbose --debug" } @@ -136,6 +168,32 @@ jobs: name: Information ${{ env.package_name }} ${{ env.package_version }} on ${{ matrix.os }} path: ${{ steps.information.outputs.path }} + - name: Tests after install + if: inputs.test_cases + run: | + if ($env:debug) { + $VerbosePreference = $DebugPreference = $InformationPreference = "Continue" + } + $test_cases = $env:test_cases -split "^-\s+(.+)\s*$", 0, "Multiline" + for ($i = 1; $i -lt $test_cases.length - 1; $i += 2) { + try { + $out = @() + Invoke-Expression $test_cases[$i + 1] *>&1 | ForEach-Object { $out += $_ } + if ($LASTEXITCODE) { throw "Test failed." } + "✅ {0}" -f $test_cases[$i] | Write-Host + } catch { + "❌ {0}" -f $test_cases[$i] | Write-Host + $out, $_ | Out-Host + return $true + } + } + if ($results -contains $true) { + throw "Tests failed." + } + env: + debug: ${{ runner.debug }} + scripts: ${{ inputs.test_cases }} + - name: Uninstall package # AirServer requires Wireless-Networking while uninstalling, feature not installed on GitHub agents if: env.package_name != 'airserver' @@ -147,6 +205,32 @@ jobs: debug: ${{ runner.debug }} timeout-minutes: 10 + - name: Tests after uninstall + if: inputs.test_cases + run: | + if ($env:debug) { + $VerbosePreference = $DebugPreference = $InformationPreference = "Continue" + } + $test_cases = $env:test_cases -split "^-\s+(.+)\s*$", 0, "Multiline" + for ($i = 1; $i -lt $test_cases.length - 1; $i += 2) { + try { + $out = @() + Invoke-Expression $test_cases[$i + 1] *>&1 | ForEach-Object { $out += $_ } + if ($LASTEXITCODE) { throw "Test failed." } + "❌ {0}" -f $test_cases[$i] | Write-Host + $out | Out-Host + return $true + } catch { + "✅ {0}" -f $test_cases[$i] | Write-Host + } + } + if ($results -contains $true) { + throw "Tests failed." + } + env: + debug: ${{ runner.debug }} + scripts: ${{ inputs.test_cases }} + - name: Take failure screenshot if: failure() run: | diff --git a/.github/workflows/diskmon.yml b/.github/workflows/diskmon.yml index 91044788..4a2bcb78 100644 --- a/.github/workflows/diskmon.yml +++ b/.github/workflows/diskmon.yml @@ -32,4 +32,19 @@ jobs: with: test: ${{ github.event_name == 'pull_request' || github.event.schedule == '0 4 * * *' || inputs.type == 'Test' }} force: ${{ inputs.type == 'Force update' }} + test_cases: | + - Start diskmon + diskmon + $sw = [System.Diagnostics.Stopwatch]::StartNew() + while ($sw.ElapsedMilliseconds -lt 30000) { + if (Get-Process diskmon* | Where-Object MainWindowHandle -NE 0) { + return + } + Start-Sleep -Milliseconds 500 + } + throw "Process start timed out." + - Close diskmon + Get-Process diskmon* | Should -Not -BeNullOrEmpty + Get-Process diskmon* | ForEach-Object CloseMainWindow | Out-Null + Wait-Process diskmon* -Timeout 30 secrets: inherit diff --git a/.github/workflows/ilspy.yml b/.github/workflows/ilspy.yml index 7411d66f..591a9cbe 100644 --- a/.github/workflows/ilspy.yml +++ b/.github/workflows/ilspy.yml @@ -32,4 +32,19 @@ jobs: with: test: ${{ github.event_name == 'pull_request' || github.event.schedule == '0 4 * * *' || inputs.type == 'Test' }} force: ${{ inputs.type == 'Force update' }} + test_cases: | + - Start ILSpy + ILSpy + $sw = [System.Diagnostics.Stopwatch]::StartNew() + while ($sw.ElapsedMilliseconds -lt 30000) { + if (Get-Process ILSpy* | Where-Object MainWindowHandle -NE 0) { + return + } + Start-Sleep -Milliseconds 500 + } + throw "Process start timed out." + - Close ILSpy + Get-Process ILSpy* | Should -Not -BeNullOrEmpty + Get-Process ILSpy* | ForEach-Object CloseMainWindow | Out-Null + Wait-Process ILSpy* -Timeout 30 secrets: inherit diff --git a/.github/workflows/imdisk.yml b/.github/workflows/imdisk.yml index b5ec2eb3..2f6d4a32 100644 --- a/.github/workflows/imdisk.yml +++ b/.github/workflows/imdisk.yml @@ -32,4 +32,7 @@ jobs: with: test: ${{ github.event_name == 'pull_request' || github.event.schedule == '0 4 * * *' || inputs.type == 'Test' }} force: ${{ inputs.type == 'Force update' }} + test_cases: | + - Run imdisk --version + imdisk --version secrets: inherit diff --git a/.github/workflows/procexp.yml b/.github/workflows/procexp.yml index 0a29e540..90e0453a 100644 --- a/.github/workflows/procexp.yml +++ b/.github/workflows/procexp.yml @@ -32,4 +32,19 @@ jobs: with: test: ${{ github.event_name == 'pull_request' || github.event.schedule == '0 4 * * *' || inputs.type == 'Test' }} force: ${{ inputs.type == 'Force update' }} + test_cases: | + - Start procexp + procexp + $sw = [System.Diagnostics.Stopwatch]::StartNew() + while ($sw.ElapsedMilliseconds -lt 30000) { + if (Get-Process procexp* | Where-Object MainWindowHandle -NE 0) { + return + } + Start-Sleep -Milliseconds 500 + } + throw "Process start timed out." + - Close procexp + Get-Process procexp* | Should -Not -BeNullOrEmpty + Get-Process procexp* | ForEach-Object CloseMainWindow | Out-Null + Wait-Process procexp* -Timeout 30 secrets: inherit diff --git a/.github/workflows/procmon.yml b/.github/workflows/procmon.yml index 696deeb4..a59bdf5c 100644 --- a/.github/workflows/procmon.yml +++ b/.github/workflows/procmon.yml @@ -32,4 +32,19 @@ jobs: with: test: ${{ github.event_name == 'pull_request' || github.event.schedule == '0 4 * * *' || inputs.type == 'Test' }} force: ${{ inputs.type == 'Force update' }} + test_cases: | + - Start procmon + procmon + $sw = [System.Diagnostics.Stopwatch]::StartNew() + while ($sw.ElapsedMilliseconds -lt 30000) { + if (Get-Process procmon* | Where-Object MainWindowHandle -NE 0) { + return + } + Start-Sleep -Milliseconds 500 + } + throw "Process start timed out." + - Close procmon + Get-Process procmon* | Should -Not -BeNullOrEmpty + Get-Process procmon* | ForEach-Object CloseMainWindow | Out-Null + Wait-Process procmon* -Timeout 30 secrets: inherit diff --git a/.github/workflows/psinfo.yml b/.github/workflows/psinfo.yml index e0502038..622f9b45 100644 --- a/.github/workflows/psinfo.yml +++ b/.github/workflows/psinfo.yml @@ -32,4 +32,7 @@ jobs: with: test: ${{ github.event_name == 'pull_request' || github.event.schedule == '0 4 * * *' || inputs.type == 'Test' }} force: ${{ inputs.type == 'Force update' }} + test_cases: | + - Run psinfo + psinfo secrets: inherit diff --git a/.github/workflows/sabnzbd.yml b/.github/workflows/sabnzbd.yml index 7124fe8d..28f60d35 100644 --- a/.github/workflows/sabnzbd.yml +++ b/.github/workflows/sabnzbd.yml @@ -32,4 +32,9 @@ jobs: with: test: ${{ github.event_name == 'pull_request' || github.event.schedule == '0 4 * * *' || inputs.type == 'Test' }} force: ${{ inputs.type == 'Force update' }} + test_cases: | + - Check SABnzbd service + Get-Service SABnzbd | ForEach-Object Status | Should -Be "Running" + - Test web interface + Invoke-WebRequest "http://localhost:8080/" -UseBasicParsing secrets: inherit diff --git a/.github/workflows/serviio.yml b/.github/workflows/serviio.yml index 0c6f4236..98d615d7 100644 --- a/.github/workflows/serviio.yml +++ b/.github/workflows/serviio.yml @@ -32,4 +32,9 @@ jobs: with: test: ${{ github.event_name == 'pull_request' || github.event.schedule == '0 4 * * *' || inputs.type == 'Test' }} force: ${{ inputs.type == 'Force update' }} + test_cases: | + - Check Serviio service + Get-Service Serviio | ForEach-Object Status | Should -Be "Running" + - Test web interface + Invoke-WebRequest "http://localhost:23424/mediabrowser" -UseBasicParsing secrets: inherit diff --git a/.github/workflows/strawberryperl.yml b/.github/workflows/strawberryperl.yml index 4f711bab..b30d847e 100644 --- a/.github/workflows/strawberryperl.yml +++ b/.github/workflows/strawberryperl.yml @@ -32,4 +32,7 @@ jobs: with: test: ${{ github.event_name == 'pull_request' || github.event.schedule == '0 4 * * *' || inputs.type == 'Test' }} force: ${{ inputs.type == 'Force update' }} + test_cases: | + - Run perl --version + perl --version secrets: inherit diff --git a/.github/workflows/vscodium-insiders.yml b/.github/workflows/vscodium-insiders.yml index 07b73081..fbea7e45 100644 --- a/.github/workflows/vscodium-insiders.yml +++ b/.github/workflows/vscodium-insiders.yml @@ -34,4 +34,21 @@ jobs: packages: vscodium-insiders, vscodium-insiders.install, vscodium-insiders.portable test: ${{ github.event_name == 'pull_request' || github.event.schedule == '0 4 * * *' || inputs.type == 'Test' }} force: ${{ inputs.type == 'Force update' }} + test_cases: | + - Run codium-insiders --version + codium-insiders --version + - Start VSCodium + codium-insiders + $sw = [System.Diagnostics.Stopwatch]::StartNew() + while ($sw.ElapsedMilliseconds -lt 30000) { + if (Get-Process "VSCodium - Insiders" -ErrorAction SilentlyContinue | Where-Object MainWindowHandle -NE 0) { + return + } + Start-Sleep -Milliseconds 500 + } + throw "Process start timed out." + - Close VSCodium + Get-Process "VSCodium - Insiders" -ErrorAction SilentlyContinue | Should -Not -BeNullOrEmpty + Get-Process "VSCodium - Insiders" | ForEach-Object CloseMainWindow | Out-Null + Wait-Process "VSCodium - Insiders" -Timeout 30 secrets: inherit diff --git a/.github/workflows/vscodium.yml b/.github/workflows/vscodium.yml index b4cc405f..b5434890 100644 --- a/.github/workflows/vscodium.yml +++ b/.github/workflows/vscodium.yml @@ -34,4 +34,21 @@ jobs: packages: vscodium, vscodium.install, vscodium.portable test: ${{ github.event_name == 'pull_request' || github.event.schedule == '0 4 * * *' || inputs.type == 'Test' }} force: ${{ inputs.type == 'Force update' }} + test_cases: | + - Run codium --version + codium --version + - Start VSCodium + codium + $sw = [System.Diagnostics.Stopwatch]::StartNew() + while ($sw.ElapsedMilliseconds -lt 30000) { + if (Get-Process VSCodium -ErrorAction SilentlyContinue | Where-Object MainWindowHandle -NE 0) { + return + } + Start-Sleep -Milliseconds 500 + } + throw "Process start timed out." + - Close VSCodium + Get-Process VSCodium -ErrorAction SilentlyContinue | Should -Not -BeNullOrEmpty + Get-Process VSCodium | ForEach-Object CloseMainWindow | Out-Null + Wait-Process VSCodium -Timeout 30 secrets: inherit diff --git a/sabnzbd/tools/chocolateyBeforeModify.ps1 b/sabnzbd/tools/chocolateyBeforeModify.ps1 index df4e7290..4a90a408 100644 --- a/sabnzbd/tools/chocolateyBeforeModify.ps1 +++ b/sabnzbd/tools/chocolateyBeforeModify.ps1 @@ -12,7 +12,7 @@ $installPath = Get-InstallPath $packageName $softwareName if ($installPath) { Write-Host "Uninstalling service from $installPath..." - 'SABnzbd-console.exe', 'SABnzbd-service.exe', 'SABnzbd-helper.exe', 'SABnzbd.exe' ` + 'SABnzbd-console.exe', 'SABnzbd-service.exe', 'SABnzbd-helper.exe' ` | ForEach-Object { Join-Path $installPath $_ } ` | Where-Object { Test-Path $_ } ` | ForEach-Object { diff --git a/sabnzbd/tools/chocolateyInstall.ps1 b/sabnzbd/tools/chocolateyInstall.ps1 index 070129e2..2d3a6ec1 100644 --- a/sabnzbd/tools/chocolateyInstall.ps1 +++ b/sabnzbd/tools/chocolateyInstall.ps1 @@ -30,7 +30,7 @@ if ($installPath) { | Where-Object { !(Join-Path $installPath $_.Name | Test-Path) } ` | Copy-Item -Destination $installPath - $exePath = Join-Path $installPath 'SABnzbd.exe' + $exePath = Join-Path $installPath 'SABnzbd-console.exe' $iniPath = Join-Path $Env:LOCALAPPDATA 'sabnzbd\sabnzbd.ini' Start-ChocolateyProcessAsAdmin -WorkingDirectory $installPath -ExeToRun $exePath -Statements "-f `"$iniPath`" install" | Out-Null Set-Service 'SABnzbd' -StartupType Automatic