mirror of
https://github.com/okieselbach/AutopilotMonitor.git
synced 2026-10-24 12:42:38 +00:00
acc95471a6
Refactor Install-AutopilotMonitor-dev.ps1 (v2.3-dev) into functions (Get-CloudPcModel, Get-RealUserProfilePaths, Get-RelaxDecision, Get-BootstrapDecision with reason codes) with an Invoke-Bootstrap main and a dot-source entry guard, so the Pester suite can load the logic without executing the bootstrap. Behaviour when run directly is unchanged. Fixes a refactoring leak found by smoke-run: Write-Log used Write-Output, which turned function return values into arrays and swallowed console output; now Write-Host, guarded by a dedicated logging-purity test. Add Install-AutopilotMonitor-dev.Tests.ps1 (25 tests: Cloud PC detection, relax scenarios incl. the W365 field case, guards 1-5, profile collection with WMI failure path) and .github/workflows/pester.yml running the suite under Windows PowerShell 5.1 (IME runtime) plus an ASCII guard over all bootstrap scripts. Tests pass 25/25 under PS 5.1 and pwsh 7. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
62 lines
2.0 KiB
YAML
62 lines
2.0 KiB
YAML
name: Pester (Bootstrap scripts)
|
|
|
|
# Runs the Pester suite for the Intune bootstrap scripts under Windows PowerShell 5.1
|
|
# (the runtime IME uses to execute platform scripts) so guard/relax logic changes are
|
|
# verified without resetting a device. Like ci.yml it reports rather than blocks.
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths: ['scripts/Bootstrap/**']
|
|
pull_request:
|
|
branches: [main]
|
|
paths: ['scripts/Bootstrap/**']
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: pester-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
pester:
|
|
name: Bootstrap guard tests (PS 5.1)
|
|
runs-on: windows-latest
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- name: Install Pester 5+
|
|
shell: powershell
|
|
run: |
|
|
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -Scope CurrentUser | Out-Null
|
|
Install-Module Pester -Scope CurrentUser -Force -SkipPublisherCheck -MinimumVersion 5.5.0
|
|
|
|
- name: Run Pester
|
|
shell: powershell
|
|
run: |
|
|
Import-Module Pester -MinimumVersion 5.5.0
|
|
$c = New-PesterConfiguration
|
|
$c.Run.Path = 'scripts/Bootstrap'
|
|
$c.Run.Exit = $true
|
|
$c.Output.Verbosity = 'Detailed'
|
|
Invoke-Pester -Configuration $c
|
|
|
|
- name: Guard scripts stay pure ASCII
|
|
shell: powershell
|
|
run: |
|
|
$failed = $false
|
|
Get-ChildItem 'scripts/Bootstrap' -Filter '*.ps1' | ForEach-Object {
|
|
$bytes = [System.IO.File]::ReadAllBytes($_.FullName)
|
|
for ($i = 0; $i -lt $bytes.Length; $i++) {
|
|
if ($bytes[$i] -gt 127) {
|
|
Write-Host "::error file=scripts/Bootstrap/$($_.Name)::Non-ASCII byte 0x$('{0:X2}' -f $bytes[$i]) at offset $i. PS 5.1 (IME) reads BOM-less files as ANSI and corrupts multi-byte chars."
|
|
$failed = $true
|
|
break
|
|
}
|
|
}
|
|
}
|
|
if ($failed) { exit 1 }
|
|
Write-Host 'All bootstrap scripts are pure ASCII.'
|