Skip to content

Commit 823b07f

Browse files
committed
Release 1.290.2025
1 parent 9ed02d2 commit 823b07f

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

.github/workflows/test.yml

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

0 commit comments

Comments
 (0)