diff --git a/.github/workflows/release-zip.yml b/.github/workflows/release-zip.yml new file mode 100644 index 0000000..d672b33 --- /dev/null +++ b/.github/workflows/release-zip.yml @@ -0,0 +1,34 @@ +name: Release zip + +# Attaches the install zip (the main script plus Modules\, nothing else) to a +# release when it is published. Re-run by hand for an existing tag if needed. +on: + release: + types: [published] + workflow_dispatch: + inputs: + tag: + description: Existing release tag to build the zip for (e.g. v1.1) + required: true + +permissions: + contents: write + +jobs: + zip: + name: Build and attach install zip + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.release.tag_name || inputs.tag }} + + - name: Build and upload + env: + GH_TOKEN: ${{ github.token }} + TAG: ${{ github.event.release.tag_name || inputs.tag }} + run: | + zip="Manga-Conversion-Script-${TAG}.zip" + git archive --format=zip --prefix="Manga Conversion Script/" -o "$zip" HEAD "Conversion Script Main.ps1" Modules + unzip -l "$zip" + gh release upload "$TAG" "$zip" --clobber diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..eb0f620 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,42 @@ +name: Tests + +on: + pull_request: + push: + branches: [main] + workflow_dispatch: + +permissions: + contents: read + +jobs: + harnesses: + name: Harnesses + runs-on: windows-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + + # Windows PowerShell 5.1 (shell: powershell), the version the script targets. + # The harnesses build their own stand-in cjxl/magick, so no real tools are needed. + - name: Run every harness + shell: powershell + run: | + $failed = @() + foreach ($harness in Get-ChildItem -Path .\_Harness -Filter *.Harness.ps1 | Sort-Object Name) { + Write-Host ("::group::" + $harness.BaseName) + & powershell.exe -NoProfile -ExecutionPolicy Bypass -File $harness.FullName + $code = $LASTEXITCODE + Write-Host "::endgroup::" + if ($code -eq 0) { + Write-Host ("PASS " + $harness.BaseName) + } else { + Write-Host ("::error title=" + $harness.BaseName + "::exited with code " + $code) + $failed += $harness.BaseName + } + } + if ($failed.Count -gt 0) { + Write-Host ("Failed: " + ($failed -join ", ")) + exit 1 + } + Write-Host "All harnesses passed." diff --git a/_Harness/FileDeletion.Harness.ps1 b/_Harness/FileDeletion.Harness.ps1 index 33ccd37..8e38c34 100644 --- a/_Harness/FileDeletion.Harness.ps1 +++ b/_Harness/FileDeletion.Harness.ps1 @@ -154,8 +154,15 @@ Write-Host "=== Scenario G: Move-ToRecycleBin target actually lands in the Recyc $uniqueNameG = "filedeletion-harness-" + [guid]::NewGuid().ToString("N") + ".txt" $fileG = New-ScratchFile -Name $uniqueNameG $null = Move-ToRecycleBin -ItemPath $fileG -$foundInBinG = Test-ItemInRecycleBin -FileName $uniqueNameG -Test-Assert $foundInBinG "Move-ToRecycleBin's target is found in the real Windows Recycle Bin (genuinely recoverable, not just deleted)" +if ($env:GITHUB_ACTIONS -eq 'true') { + # GitHub's Windows runners run as a service with no interactive shell, so + # the Recycle Bin can't be browsed there. Check only that the file left. + Test-Assert (-not (Test-Path -LiteralPath $fileG)) "Move-ToRecycleBin's target is gone from its original location" + Write-Host " [SKIP] Recycle Bin lookup - not available on GitHub Actions runners" -ForegroundColor Yellow +} else { + $foundInBinG = Test-ItemInRecycleBin -FileName $uniqueNameG + Test-Assert $foundInBinG "Move-ToRecycleBin's target is found in the real Windows Recycle Bin (genuinely recoverable, not just deleted)" +} Write-Host "" # ==============================================================================