diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index abcbde1..4ed86f8 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -65,13 +65,13 @@ The automated tests use Pester 5 and are found in the `Tests` directory. They co The bootstrap option can be used to automatically install Pester on your machine and run the full suite of tests: ```powershell -.\Scripts\Run-Tests.ps1 -Bootstrap +.\Tools\Run-Tests.ps1 -Bootstrap ``` After the initial setup, you can simply run the full suite with: ```powershell -.\Scripts\Run-Tests.ps1 +.\Tools\Run-Tests.ps1 ``` For a focused test run during development, you can also call Pester directly: @@ -124,7 +124,6 @@ Win11Debloat/ ├── Run.bat # Local launcher ├── Scripts/ # Additional PowerShell scripts and functions │ ├── Get.ps1 # Download-and-launch script -│ ├── Run-Tests.ps1 # Pester test runner (optionally bootstraps Pester) │ ├── AppRemoval/ # App package removal logic │ ├── CLI/ # Command-line interface helpers │ ├── Features/ # Feature apply, undo, backup, and restore logic @@ -143,6 +142,9 @@ Win11Debloat/ │ └── Sysprep/ # Registry files for Sysprep mode ├── Schemas/ # XAML views and shared GUI resources ├── Assets/ # Static assets (icons, start menu templates) +├── Tools/ # Development scripts (excluded from release packages) +│ ├── Build-Release.ps1 # Runtime release packaging +│ └── Run-Tests.ps1 # Pester test runner (optionally bootstraps Pester) ├── Tests/ # Pester tests for script and XAML contracts ├── Backups/ # Registry backups (generated during use) └── Logs/ # Script logs (generated during use) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4a84c5e..8a0de92 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -54,7 +54,7 @@ jobs: shell: powershell run: | $global:LASTEXITCODE = 0 - ./Scripts/Run-Tests.ps1 -Bootstrap + ./Tools/Run-Tests.ps1 -Bootstrap if ($LASTEXITCODE -ne 0) { throw 'Release tests failed.' } - name: Commit version and create release tag @@ -90,7 +90,7 @@ jobs: shell: powershell run: | $source = @(Get-ChildItem release-source -Directory)[0].FullName - & (Join-Path $source 'Scripts/Build-Release.ps1') -SourcePath $source -Version $env:RELEASE_TAG -OutputDirectory release-assets + & (Join-Path $source 'Tools/Build-Release.ps1') -SourcePath $source -Version $env:RELEASE_TAG -OutputDirectory release-assets - name: Create draft release shell: powershell diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7f07649..fc7711b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,7 +23,7 @@ jobs: - name: Run tests shell: powershell - run: ./Scripts/Run-Tests.ps1 -Bootstrap + run: ./Tools/Run-Tests.ps1 -Bootstrap psscriptanalyzer: name: PSScriptAnalyzer (Error severity) diff --git a/Tests/Build-Release.Tests.ps1 b/Tests/Build-Release.Tests.ps1 index faab72e..c99e164 100644 --- a/Tests/Build-Release.Tests.ps1 +++ b/Tests/Build-Release.Tests.ps1 @@ -1,11 +1,11 @@ BeforeAll { $repositoryRoot = Split-Path -Parent $PSScriptRoot - $buildScript = Join-Path $repositoryRoot 'Scripts/Build-Release.ps1' + $buildScript = Join-Path $repositoryRoot 'Tools/Build-Release.ps1' $releasePath = Join-Path $TestDrive 'release' $version = '2026.10.22-r2' $originalScript = [IO.File]::ReadAllText((Join-Path $repositoryRoot 'Win11Debloat.ps1')) Push-Location $TestDrive - try { & $buildScript -SourcePath $repositoryRoot -Version $version -OutputDirectory 'release' } + try { & $buildScript -Version $version -OutputDirectory 'release' } finally { Pop-Location } $unpackedPath = Join-Path $TestDrive 'unpacked' Expand-Archive -LiteralPath (Join-Path $releasePath 'Win11Debloat.zip') -DestinationPath $unpackedPath @@ -29,7 +29,7 @@ Describe 'Release packaging' { } It 'excludes development files and existing user data' { - foreach ($path in 'Tests', '.github', '.git', '.gitignore', 'Logs', 'Backups', 'Scripts/Run-Tests.ps1', 'Scripts/Build-Release.ps1', 'LastUsedSettings.json', 'Config/LastUsedSettings.json') { + foreach ($path in 'Tests', 'Tools', '.github', '.git', '.gitignore', 'Logs', 'Backups', 'LastUsedSettings.json', 'Config/LastUsedSettings.json') { Test-Path -LiteralPath (Join-Path $packagePath $path) | Should -BeFalse } } @@ -43,12 +43,12 @@ Describe 'Release packaging' { It 'includes new files automatically and prunes exclusions and nested output' { $source = Join-Path $TestDrive 'source-fixture' - foreach ($directory in 'NewRuntime', 'Scripts', 'Tests', '.git', '.github', 'Logs', 'Backups', 'Config') { + foreach ($directory in 'NewRuntime', 'Scripts', 'Tools', 'Tests', '.git', '.github', 'Logs', 'Backups', 'Config') { New-Item -ItemType Directory -Path (Join-Path $source $directory) -Force | Out-Null } Copy-Item -LiteralPath (Join-Path $repositoryRoot 'Win11Debloat.ps1') -Destination $source Copy-Item -LiteralPath (Join-Path $repositoryRoot 'Scripts/Get.ps1') -Destination (Join-Path $source 'Scripts/Get.ps1') - foreach ($path in 'extra.txt', 'NewRuntime/data.txt', 'Scripts/NewHelper.ps1', 'Tests/test.txt', '.git/config', '.github/workflow.yml', '.gitignore', 'Logs/log.txt', 'Backups/backup.json', 'Scripts/Build-Release.ps1', 'Scripts/Run-Tests.ps1', 'LastUsedSettings.json', 'Config/LastUsedSettings.json') { + foreach ($path in 'extra.txt', 'NewRuntime/data.txt', 'Scripts/NewHelper.ps1', 'Tools/NewBuildHelper.ps1', 'Tests/test.txt', '.git/config', '.github/workflow.yml', '.gitignore', 'Logs/log.txt', 'Backups/backup.json', 'LastUsedSettings.json', 'Config/LastUsedSettings.json') { Set-Content -LiteralPath (Join-Path $source $path) -Value 'fixture' } $output = Join-Path $source 'output' @@ -59,7 +59,7 @@ Describe 'Release packaging' { foreach ($path in 'extra.txt', 'NewRuntime/data.txt', 'Scripts/NewHelper.ps1', 'Scripts/Get.ps1') { Test-Path -LiteralPath (Join-Path $root $path) | Should -BeTrue } - foreach ($path in 'Tests', '.git', '.github', '.gitignore', 'Logs', 'Backups', 'Scripts/Build-Release.ps1', 'Scripts/Run-Tests.ps1', 'LastUsedSettings.json', 'Config/LastUsedSettings.json', 'output') { + foreach ($path in 'Tests', 'Tools', '.git', '.github', '.gitignore', 'Logs', 'Backups', 'LastUsedSettings.json', 'Config/LastUsedSettings.json', 'output') { Test-Path -LiteralPath (Join-Path $root $path) | Should -BeFalse } } diff --git a/Tests/ReleaseWorkflow.Tests.ps1 b/Tests/ReleaseWorkflow.Tests.ps1 index 50be6ea..69762e5 100644 --- a/Tests/ReleaseWorkflow.Tests.ps1 +++ b/Tests/ReleaseWorkflow.Tests.ps1 @@ -59,7 +59,9 @@ Describe 'Release workflow version commit' { $testRoot = Join-Path $TestDrive ([guid]::NewGuid().ToString('N')) $checkoutPath = Join-Path $testRoot 'checkout' $remotePath = Join-Path $testRoot 'origin.git' - New-Item -ItemType Directory -Path (Join-Path $checkoutPath 'Scripts') -Force | Out-Null + foreach ($directory in 'Scripts', 'Tools') { + New-Item -ItemType Directory -Path (Join-Path $checkoutPath $directory) -Force | Out-Null + } git init --bare --quiet $remotePath git init --quiet --initial-branch master $checkoutPath git -C $checkoutPath config user.name 'Release test' @@ -68,10 +70,10 @@ Describe 'Release workflow version commit' { git -C $checkoutPath config tag.gpgsign false git -C $checkoutPath config core.autocrlf false [IO.File]::WriteAllText((Join-Path $checkoutPath 'Win11Debloat.ps1'), '$script:Version = "2026.08.24"') - foreach ($name in 'Build-Release.ps1', 'Get.ps1') { - Copy-Item -LiteralPath (Join-Path $repositoryRoot "Scripts/$name") -Destination (Join-Path $checkoutPath "Scripts/$name") + foreach ($name in 'Tools/Build-Release.ps1', 'Scripts/Get.ps1') { + Copy-Item -LiteralPath (Join-Path $repositoryRoot $name) -Destination (Join-Path $checkoutPath $name) } - [IO.File]::WriteAllText((Join-Path $checkoutPath 'Scripts/Run-Tests.ps1'), @' + [IO.File]::WriteAllText((Join-Path $checkoutPath 'Tools/Run-Tests.ps1'), @' param([switch]$Bootstrap) $text = [IO.File]::ReadAllText((Join-Path $PSScriptRoot '../Win11Debloat.ps1')) if ($text -notmatch [regex]::Escape($env:RELEASE_TAG)) { throw 'Tests did not see the updated version.' } @@ -158,7 +160,7 @@ if ($text -notmatch [regex]::Escape($env:RELEASE_TAG)) { throw 'Tests did not se } It 'does not commit or push a release when tests fail' { - [IO.File]::WriteAllText((Join-Path $checkoutPath 'Scripts/Run-Tests.ps1'), 'exit 1') + [IO.File]::WriteAllText((Join-Path $checkoutPath 'Tools/Run-Tests.ps1'), 'exit 1') { foreach ($block in $workflowBlocks) { & $block } } | Should -Throw '*Release tests failed*' (git --git-dir $remotePath rev-parse refs/heads/master) | Should -Be $initialCommit (git ls-remote --tags origin "refs/tags/$env:RELEASE_TAG") | Should -BeNullOrEmpty diff --git a/Scripts/Build-Release.ps1 b/Tools/Build-Release.ps1 similarity index 96% rename from Scripts/Build-Release.ps1 rename to Tools/Build-Release.ps1 index e6c3cb0..1e3b08a 100644 --- a/Scripts/Build-Release.ps1 +++ b/Tools/Build-Release.ps1 @@ -27,8 +27,7 @@ $packageName = "Win11Debloat-$Version" $packagePath = Join-Path $workPath $packageName $archivePath = Join-Path $outputPath 'Win11Debloat.zip' $excludedPaths = @( - '.git', '.github', '.gitignore', 'Tests', 'Logs', 'Backups', - 'Scripts/Build-Release.ps1', 'Scripts/Run-Tests.ps1', + '.git', '.github', '.gitignore', 'Tests', 'Tools', 'Logs', 'Backups', 'LastUsedSettings.json', 'Config/LastUsedSettings.json' ) diff --git a/Scripts/Run-Tests.ps1 b/Tools/Run-Tests.ps1 similarity index 94% rename from Scripts/Run-Tests.ps1 rename to Tools/Run-Tests.ps1 index fd0c5e8..f450d3b 100644 --- a/Scripts/Run-Tests.ps1 +++ b/Tools/Run-Tests.ps1 @@ -17,7 +17,7 @@ $testPath = Join-Path $repositoryRoot 'Tests' if (-not (Get-Module -ListAvailable -Name Pester | Where-Object { $_.Version.Major -eq 5 })) { if (-not $Bootstrap) { - Write-Error 'Pester 5 is required. Install it with: .\Scripts\Run-Tests.ps1 -Bootstrap' + Write-Error 'Pester 5 is required. Install it with: .\Tools\Run-Tests.ps1 -Bootstrap' exit 1 }