-
-
Notifications
You must be signed in to change notification settings - Fork 3
222 lines (193 loc) · 8.24 KB
/
test.yml
File metadata and controls
222 lines (193 loc) · 8.24 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
workflow_dispatch:
name: Tests
permissions:
contents: read
jobs:
windows-powershell:
name: Windows PowerShell 5.1
runs-on: windows-latest
env:
CI: true
POWERSHELL_EDITION: Desktop
PS_VERSION: 5.1
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
with:
egress-policy: audit
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install dependencies
shell: powershell
run: |
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
if (-not (Get-Module -ListAvailable -Name Pester)) {
Install-Module -Name Pester -MinimumVersion 5.4.0 -Force -SkipPublisherCheck
}
if (-not (Get-Module -ListAvailable -Name PSScriptAnalyzer)) {
Install-Module -Name PSScriptAnalyzer -Force -SkipPublisherCheck
}
- name: Run Pester tests with coverage
shell: powershell
run: |
npm run test:coverage -- -CI
- name: Upload test results
if: always()
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: test-results-windows-51
path: testResults.junit.xml
- name: Upload coverage results
if: always()
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: coverage-windows-51
path: coverage.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v5.1.2
with:
files: ./coverage.xml
flags: windows-powershell-51
name: windows-powershell-51
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./testResults.junit.xml
- name: Validate help topics
shell: powershell
run: |
Import-Module ./ColorScripts-Enhanced -Force
Get-Help Show-ColorScript
Get-Help about_ColorScripts-Enhanced
pwsh-cross-platform:
name: PowerShell 7.5 (${{ matrix.os }})
runs-on: ${{ matrix.os }}
env:
CI: true
POWERSHELL_EDITION: Core
PS_VERSION: 7.5
strategy:
fail-fast: false
matrix:
os:
- windows-latest
- ubuntu-latest
- macos-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
with:
egress-policy: audit
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Verify PowerShell version
shell: pwsh
run: |
$PSVersionTable.PSVersion
Write-Host "PowerShell $($PSVersionTable.PSVersion) detected"
- name: Install dependencies
shell: pwsh
run: |
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
if (-not (Get-Module -ListAvailable -Name Pester)) {
Install-Module -Name Pester -MinimumVersion 5.4.0 -Force -SkipPublisherCheck
}
if (-not (Get-Module -ListAvailable -Name PSScriptAnalyzer)) {
Install-Module -Name PSScriptAnalyzer -Force -SkipPublisherCheck
}
- name: Run Pester tests with coverage
shell: pwsh
run: |
npm run test:coverage -- -CI
- name: Upload test results
if: always()
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: test-results-${{ matrix.os }}-pwsh
path: testResults.junit.xml
- name: Upload coverage results
if: always()
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: test-coverage-${{ matrix.os }}-pwsh
path: coverage.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v5.1.2
with:
files: ./coverage.xml
flags: pwsh-${{ matrix.os }}
name: pwsh-${{ matrix.os }}
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./testResults.junit.xml
- name: Run script analyzer
shell: pwsh
run: |
Import-Module PSScriptAnalyzer
# Analyze module files (exclude Scripts folder with colorscripts)
$modulePath = './ColorScripts-Enhanced'
$files = Get-ChildItem -Path $modulePath -File -Recurse -Include *.ps1, *.psm1, *.psd1 |
Where-Object { $_.FullName -notlike '*Scripts*' }
$results = @()
foreach ($file in $files) {
$fileResults = Invoke-ScriptAnalyzer -Path $file.FullName -Settings './PSScriptAnalyzerSettings.psd1' -Severity 'Error','Warning'
if ($fileResults) { $results += $fileResults }
}
if ($results) {
$results | Format-Table -AutoSize
throw 'ScriptAnalyzer reported findings in module files.'
}
- name: Validate help topics
shell: pwsh
run: |
Import-Module ./ColorScripts-Enhanced -Force
Get-Help Show-ColorScript
Get-Help about_ColorScripts-Enhanced
pwsh-preview:
name: PowerShell 7.5 Preview (ubuntu)
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/powershell:preview
env:
CI: true
POWERSHELL_EDITION: Core
PS_VERSION: preview
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
with:
egress-policy: audit
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install PowerShell module dependencies
shell: pwsh
run: |
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
if (-not (Get-Module -ListAvailable -Name Pester)) {
Install-Module -Name Pester -MinimumVersion 5.4.0 -Force -SkipPublisherCheck
}
if (-not (Get-Module -ListAvailable -Name PSScriptAnalyzer)) {
Install-Module -Name PSScriptAnalyzer -Force -SkipPublisherCheck
}
- name: Run smoke tests on preview build
shell: pwsh
run: |
./scripts/Test-Module.ps1
- name: Import module on preview build
shell: pwsh
run: |
Import-Module ./ColorScripts-Enhanced -Force
Get-ColorScriptList -AsObject | Select-Object -First 1