-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (55 loc) · 1.98 KB
/
test.yml
File metadata and controls
69 lines (55 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: Run Unit Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
test:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup PowerShell modules
shell: pwsh
run: |
Write-Host "Installing required modules..."
# Install Pester if needed
if (-not (Get-Module -ListAvailable -Name Pester)) {
Install-Module -Name Pester -Force -SkipPublisherCheck -Scope CurrentUser
}
# Import your GenXdev modules
$modulePath = "${{ github.workspace }}/Modules"
if (Test-Path $modulePath) {
$env:PSModulePath = "$modulePath;$env:PSModulePath"
Write-Host "Added modules path: $modulePath"
}
- name: Run unit tests
shell: pwsh
run: |
Write-Host "Running Assert-GenXdevTest..."
# Import the GenXdev.Coding module which contains Assert-GenXdevTest
Import-Module GenXdev.Coding -ErrorAction SilentlyContinue
# Run tests with error handling
try {
$result = Assert-GenXdevTest -Verbosity Detailed -TestFailedAction Stop -SkipModuleImports
if (-not $result.Success) {
Write-Error "Tests failed!"
# Display analyzer results if any
if ($result.AnalyzerResults) {
Write-Host "`nPSScriptAnalyzer Results:" -ForegroundColor Yellow
$result.AnalyzerResults | Format-Table -AutoSize
}
# Display failed test names if any
if ($result.TestResults.Failed) {
Write-Host "`nFailed Tests:" -ForegroundColor Red
$result.TestResults.Failed.Name | ForEach-Object { Write-Host " - $_" }
}
exit 1
}
Write-Host "`n✓ All tests passed!" -ForegroundColor Green
exit 0
} catch {
Write-Error "Error running tests: $($_.Exception.Message)"
exit 1
}