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
+6 -6
View File
@@ -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
}
}
+7 -5
View File
@@ -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