-
Notifications
You must be signed in to change notification settings - Fork 1
106 lines (91 loc) · 3.12 KB
/
Copy pathtests.yml
File metadata and controls
106 lines (91 loc) · 3.12 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: Tests
on:
push:
branches: [main]
paths-ignore:
- '**.md'
- 'docs/**'
- '.plan/**'
pull_request:
branches: [main]
paths-ignore:
- '**.md'
- 'docs/**'
- '.plan/**'
jobs:
test:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Display PowerShell version
shell: pwsh
run: |
$PSVersionTable
Write-Host "PowerShell $($PSVersionTable.PSVersion) on $($PSVersionTable.OS)"
- name: Cache PowerShell modules
uses: actions/cache@v5
with:
path: |
~/.local/share/powershell/Modules
~/Documents/PowerShell/Modules
key: ${{ runner.os }}-psmodules-${{ hashFiles('**/Install-*.ps1') }}
restore-keys: |
${{ runner.os }}-psmodules-
- name: Install test dependencies
shell: pwsh
run: |
Write-Host "Installing Pester..." -ForegroundColor Cyan
./scripts/Install-TestDeps.ps1
- name: Install PSScriptAnalyzer
shell: pwsh
run: |
Write-Host "Installing PSScriptAnalyzer..." -ForegroundColor Cyan
./scripts/Install-PSScriptAnalyzer.ps1
- name: Run linter
shell: pwsh
run: |
Write-Host "Running PSScriptAnalyzer..." -ForegroundColor Cyan
./scripts/Invoke-Linter.ps1
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- name: Run tests with coverage
shell: pwsh
run: |
Write-Host "Running tests with coverage..." -ForegroundColor Cyan
$ErrorActionPreference = 'Continue'
./scripts/Invoke-Tests.ps1 -Coverage
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- name: Display coverage report
shell: pwsh
run: |
Write-Host "Coverage Report:" -ForegroundColor Cyan
./scripts/Show-Coverage.ps1
- name: Upload coverage artifact
uses: actions/upload-artifact@v5
with:
name: coverage-${{ matrix.os }}
path: tests/Coverage/coverage.xml
retention-days: 30
- name: Check coverage threshold
shell: pwsh
run: |
$coverageFile = "tests/Coverage/coverage.xml"
if (Test-Path $coverageFile) {
[xml]$coverage = Get-Content $coverageFile
$lineCoverage = $coverage.report.counter | Where-Object { $_.type -eq 'LINE' }
$covered = [int]$lineCoverage.covered
$missed = [int]$lineCoverage.missed
$total = $covered + $missed
$percent = [math]::Round(($covered / $total) * 100, 2)
Write-Host "Coverage: $percent% ($covered/$total lines)" -ForegroundColor $(if ($percent -ge 75) { 'Green' } else { 'Yellow' })
# Fail if coverage is below 30% (critical threshold)
if ($percent -lt 30) {
Write-Error "Coverage $percent% is below critical threshold of 30%"
exit 1
}
}