refactor: move development scripts from Scripts to Tools directory (#881)

This commit is contained in:
Jeffrey
2026-11-08 03:40:35 +01:00
committed by GitHub
parent 5d88bfe9ef
commit 156e2517d4
7 changed files with 23 additions and 20 deletions
+5 -3
View File
@@ -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: The bootstrap option can be used to automatically install Pester on your machine and run the full suite of tests:
```powershell ```powershell
.\Scripts\Run-Tests.ps1 -Bootstrap .\Tools\Run-Tests.ps1 -Bootstrap
``` ```
After the initial setup, you can simply run the full suite with: After the initial setup, you can simply run the full suite with:
```powershell ```powershell
.\Scripts\Run-Tests.ps1 .\Tools\Run-Tests.ps1
``` ```
For a focused test run during development, you can also call Pester directly: For a focused test run during development, you can also call Pester directly:
@@ -124,7 +124,6 @@ Win11Debloat/
├── Run.bat # Local launcher ├── Run.bat # Local launcher
├── Scripts/ # Additional PowerShell scripts and functions ├── Scripts/ # Additional PowerShell scripts and functions
│ ├── Get.ps1 # Download-and-launch script │ ├── Get.ps1 # Download-and-launch script
│ ├── Run-Tests.ps1 # Pester test runner (optionally bootstraps Pester)
│ ├── AppRemoval/ # App package removal logic │ ├── AppRemoval/ # App package removal logic
│ ├── CLI/ # Command-line interface helpers │ ├── CLI/ # Command-line interface helpers
│ ├── Features/ # Feature apply, undo, backup, and restore logic │ ├── Features/ # Feature apply, undo, backup, and restore logic
@@ -143,6 +142,9 @@ Win11Debloat/
│ └── Sysprep/ # Registry files for Sysprep mode │ └── Sysprep/ # Registry files for Sysprep mode
├── Schemas/ # XAML views and shared GUI resources ├── Schemas/ # XAML views and shared GUI resources
├── Assets/ # Static assets (icons, start menu templates) ├── 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 ├── Tests/ # Pester tests for script and XAML contracts
├── Backups/ # Registry backups (generated during use) ├── Backups/ # Registry backups (generated during use)
└── Logs/ # Script logs (generated during use) └── Logs/ # Script logs (generated during use)
+2 -2
View File
@@ -54,7 +54,7 @@ jobs:
shell: powershell shell: powershell
run: | run: |
$global:LASTEXITCODE = 0 $global:LASTEXITCODE = 0
./Scripts/Run-Tests.ps1 -Bootstrap ./Tools/Run-Tests.ps1 -Bootstrap
if ($LASTEXITCODE -ne 0) { throw 'Release tests failed.' } if ($LASTEXITCODE -ne 0) { throw 'Release tests failed.' }
- name: Commit version and create release tag - name: Commit version and create release tag
@@ -90,7 +90,7 @@ jobs:
shell: powershell shell: powershell
run: | run: |
$source = @(Get-ChildItem release-source -Directory)[0].FullName $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 - name: Create draft release
shell: powershell shell: powershell
+1 -1
View File
@@ -23,7 +23,7 @@ jobs:
- name: Run tests - name: Run tests
shell: powershell shell: powershell
run: ./Scripts/Run-Tests.ps1 -Bootstrap run: ./Tools/Run-Tests.ps1 -Bootstrap
psscriptanalyzer: psscriptanalyzer:
name: PSScriptAnalyzer (Error severity) name: PSScriptAnalyzer (Error severity)
+6 -6
View File
@@ -1,11 +1,11 @@
BeforeAll { BeforeAll {
$repositoryRoot = Split-Path -Parent $PSScriptRoot $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' $releasePath = Join-Path $TestDrive 'release'
$version = '2026.10.22-r2' $version = '2026.10.22-r2'
$originalScript = [IO.File]::ReadAllText((Join-Path $repositoryRoot 'Win11Debloat.ps1')) $originalScript = [IO.File]::ReadAllText((Join-Path $repositoryRoot 'Win11Debloat.ps1'))
Push-Location $TestDrive Push-Location $TestDrive
try { & $buildScript -SourcePath $repositoryRoot -Version $version -OutputDirectory 'release' } try { & $buildScript -Version $version -OutputDirectory 'release' }
finally { Pop-Location } finally { Pop-Location }
$unpackedPath = Join-Path $TestDrive 'unpacked' $unpackedPath = Join-Path $TestDrive 'unpacked'
Expand-Archive -LiteralPath (Join-Path $releasePath 'Win11Debloat.zip') -DestinationPath $unpackedPath 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' { 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 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' { It 'includes new files automatically and prunes exclusions and nested output' {
$source = Join-Path $TestDrive 'source-fixture' $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 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 'Win11Debloat.ps1') -Destination $source
Copy-Item -LiteralPath (Join-Path $repositoryRoot 'Scripts/Get.ps1') -Destination (Join-Path $source 'Scripts/Get.ps1') 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' Set-Content -LiteralPath (Join-Path $source $path) -Value 'fixture'
} }
$output = Join-Path $source 'output' $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') { foreach ($path in 'extra.txt', 'NewRuntime/data.txt', 'Scripts/NewHelper.ps1', 'Scripts/Get.ps1') {
Test-Path -LiteralPath (Join-Path $root $path) | Should -BeTrue 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 Test-Path -LiteralPath (Join-Path $root $path) | Should -BeFalse
} }
} }
+7 -5
View File
@@ -59,7 +59,9 @@ Describe 'Release workflow version commit' {
$testRoot = Join-Path $TestDrive ([guid]::NewGuid().ToString('N')) $testRoot = Join-Path $TestDrive ([guid]::NewGuid().ToString('N'))
$checkoutPath = Join-Path $testRoot 'checkout' $checkoutPath = Join-Path $testRoot 'checkout'
$remotePath = Join-Path $testRoot 'origin.git' $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 --bare --quiet $remotePath
git init --quiet --initial-branch master $checkoutPath git init --quiet --initial-branch master $checkoutPath
git -C $checkoutPath config user.name 'Release test' 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 tag.gpgsign false
git -C $checkoutPath config core.autocrlf false git -C $checkoutPath config core.autocrlf false
[IO.File]::WriteAllText((Join-Path $checkoutPath 'Win11Debloat.ps1'), '$script:Version = "2026.08.24"') [IO.File]::WriteAllText((Join-Path $checkoutPath 'Win11Debloat.ps1'), '$script:Version = "2026.08.24"')
foreach ($name in 'Build-Release.ps1', 'Get.ps1') { foreach ($name in 'Tools/Build-Release.ps1', 'Scripts/Get.ps1') {
Copy-Item -LiteralPath (Join-Path $repositoryRoot "Scripts/$name") -Destination (Join-Path $checkoutPath "Scripts/$name") 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) param([switch]$Bootstrap)
$text = [IO.File]::ReadAllText((Join-Path $PSScriptRoot '../Win11Debloat.ps1')) $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.' } 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' { 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*' { foreach ($block in $workflowBlocks) { & $block } } | Should -Throw '*Release tests failed*'
(git --git-dir $remotePath rev-parse refs/heads/master) | Should -Be $initialCommit (git --git-dir $remotePath rev-parse refs/heads/master) | Should -Be $initialCommit
(git ls-remote --tags origin "refs/tags/$env:RELEASE_TAG") | Should -BeNullOrEmpty (git ls-remote --tags origin "refs/tags/$env:RELEASE_TAG") | Should -BeNullOrEmpty
@@ -27,8 +27,7 @@ $packageName = "Win11Debloat-$Version"
$packagePath = Join-Path $workPath $packageName $packagePath = Join-Path $workPath $packageName
$archivePath = Join-Path $outputPath 'Win11Debloat.zip' $archivePath = Join-Path $outputPath 'Win11Debloat.zip'
$excludedPaths = @( $excludedPaths = @(
'.git', '.github', '.gitignore', 'Tests', 'Logs', 'Backups', '.git', '.github', '.gitignore', 'Tests', 'Tools', 'Logs', 'Backups',
'Scripts/Build-Release.ps1', 'Scripts/Run-Tests.ps1',
'LastUsedSettings.json', 'Config/LastUsedSettings.json' 'LastUsedSettings.json', 'Config/LastUsedSettings.json'
) )
@@ -17,7 +17,7 @@ $testPath = Join-Path $repositoryRoot 'Tests'
if (-not (Get-Module -ListAvailable -Name Pester | Where-Object { $_.Version.Major -eq 5 })) { if (-not (Get-Module -ListAvailable -Name Pester | Where-Object { $_.Version.Major -eq 5 })) {
if (-not $Bootstrap) { 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 exit 1
} }