noid-privacy/.github/workflows/pester-tests.yml
NexusOne23 745d808771 Fix: Skip execution tests on CI - require admin/Defender
- All DryRun tests now skip on GitHub Actions (no admin rights)
- Fixed AntiAI compliance script path (Private folder)
- Removed continue-on-error - tests are real quality gates again
- Structure tests still run on CI (manifest, exports, JSON validation)
2025-12-09 05:50:52 +01:00

77 lines
2.2 KiB
YAML

name: Pester Tests
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
workflow_dispatch:
# Security: Explicit permissions (Principle of Least Privilege)
permissions:
contents: read # Required for checkout
checks: write # Required for publish-unit-test-result-action
pull-requests: write # Required for PR comments by test action
jobs:
test:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Pester
shell: pwsh
run: |
Install-Module -Name Pester -Force -SkipPublisherCheck -Scope CurrentUser
Import-Module Pester
- name: Run Unit Tests
shell: pwsh
run: |
$config = New-PesterConfiguration
$config.Run.Path = "Tests/Unit"
$config.Run.PassThru = $true
$config.Output.Verbosity = 'Detailed'
$config.TestResult.Enabled = $true
$config.TestResult.OutputPath = "TestResults-Unit.xml"
$config.TestResult.OutputFormat = 'NUnitXml'
$results = Invoke-Pester -Configuration $config
if ($results.FailedCount -gt 0) {
Write-Error "Unit tests failed: $($results.FailedCount) failures"
exit 1
}
- name: Run Integration Tests (DryRun only)
shell: pwsh
run: |
$config = New-PesterConfiguration
$config.Run.Path = "Tests/Integration"
$config.Run.PassThru = $true
$config.Output.Verbosity = 'Detailed'
$config.TestResult.Enabled = $true
$config.TestResult.OutputPath = "TestResults-Integration.xml"
$config.TestResult.OutputFormat = 'NUnitXml'
$results = Invoke-Pester -Configuration $config
if ($results.FailedCount -gt 0) {
Write-Error "Integration tests failed: $($results.FailedCount) failures"
exit 1
}
- name: Upload Test Results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: TestResults-*.xml
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/windows@v2
if: always()
with:
files: TestResults-*.xml