Skip to content

Stop a non-elevated run from continuing past the admin guard #31

Stop a non-elevated run from continuing past the admin guard

Stop a non-elevated run from continuing past the admin guard #31

Workflow file for this run

name: Unit Tests
on:
pull_request:
branches: [master, dev]
push:
branches: [master, dev]
jobs:
pester-unit-tests:
name: Pester Unit Tests
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Install Pester
shell: pwsh
run: |
if (-not (Get-Module -ListAvailable -Name Pester | Where-Object { $_.Version -eq '5.7.1' })) {
Install-Module Pester -RequiredVersion 5.7.1 -Force -SkipPublisherCheck -Scope CurrentUser
}
Import-Module Pester -RequiredVersion 5.7.1
- name: Install PSScriptAnalyzer
shell: pwsh
run: |
if (-not (Get-Module -ListAvailable -Name PSScriptAnalyzer)) {
Install-Module PSScriptAnalyzer -Force -Scope CurrentUser
}
- name: Run static validation
shell: powershell
run: |
.\Tests\Invoke-StaticValidation.ps1 -RequirePSScriptAnalyzer
- name: Run Features.json unit tests
shell: pwsh
run: |
$result = Invoke-Pester -Path "Tests/Unit/Test-FeaturesJson.ps1" -Output Detailed -PassThru
if ($result.FailedCount -gt 0) {
Write-Error "$($result.FailedCount) test(s) failed in Test-FeaturesJson.ps1"
exit 1
}
- name: Run Apps.json unit tests
shell: pwsh
run: |
$result = Invoke-Pester -Path "Tests/Unit/Test-AppsJson.ps1" -Output Detailed -PassThru
if ($result.FailedCount -gt 0) {
Write-Error "$($result.FailedCount) test(s) failed in Test-AppsJson.ps1"
exit 1
}
- name: Run registry file unit tests
shell: pwsh
run: |
$result = Invoke-Pester -Path "Tests/Unit/Test-RegistryFiles.ps1" -Output Detailed -PassThru
if ($result.FailedCount -gt 0) {
Write-Error "$($result.FailedCount) test(s) failed in Test-RegistryFiles.ps1"
exit 1
}
- name: Run desired-state verification tests
shell: pwsh
run: |
$result = Invoke-Pester -Path "Tests/Unit/Test-DesiredStateVerification.ps1" -Output Detailed -PassThru
if ($result.FailedCount -gt 0) {
Write-Error "$($result.FailedCount) test(s) failed in Test-DesiredStateVerification.ps1"
exit 1
}
- name: Run custom feature and safety contract tests
shell: pwsh
run: |
$result = Invoke-Pester -Path @(
"Tests/Unit/Test-CustomFeatureContracts.ps1",
"Tests/Unit/Test-SafetyGuards.ps1"
) -Output Detailed -PassThru
if ($result.FailedCount -gt 0) {
Write-Error "$($result.FailedCount) custom feature or safety contract test(s) failed"
exit 1
}
- name: Build and parse standalone script
shell: powershell
run: |
$outputFile = Join-Path $env:RUNNER_TEMP 'WinSwift-Standalone.ps1'
.\build.ps1 -OutputFile $outputFile
$tokens = $null
$parseErrors = $null
[System.Management.Automation.Language.Parser]::ParseFile(
$outputFile,
[ref]$tokens,
[ref]$parseErrors
) | Out-Null
if ($parseErrors.Count -gt 0) {
$parseErrors | ForEach-Object { Write-Error $_.Message }
exit 1
}
- name: Report summary
if: always()
shell: pwsh
run: |
Write-Host "Unit test run complete."