Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SABnzbd service + add tests #70

Merged
merged 8 commits into from
Oct 28, 2023
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
86 changes: 85 additions & 1 deletion .github/workflows/.common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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" }
Expand All @@ -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'
Expand All @@ -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: |
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/diskmon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 15 additions & 0 deletions .github/workflows/ilspy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions .github/workflows/imdisk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 15 additions & 0 deletions .github/workflows/procexp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 15 additions & 0 deletions .github/workflows/procmon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions .github/workflows/psinfo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions .github/workflows/sabnzbd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions .github/workflows/serviio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions .github/workflows/strawberryperl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 17 additions & 0 deletions .github/workflows/vscodium-insiders.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 17 additions & 0 deletions .github/workflows/vscodium.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion sabnzbd/tools/chocolateyBeforeModify.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion sabnzbd/tools/chocolateyInstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down