-
-
Notifications
You must be signed in to change notification settings - Fork 3
152 lines (136 loc) · 4.89 KB
/
test.yml
File metadata and controls
152 lines (136 loc) · 4.89 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
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
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
with:
egress-policy: audit
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- 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
shell: powershell
run: |
Import-Module Pester
$configuration = New-PesterConfiguration
$configuration.Run.Path = './Tests'
$configuration.Output.Verbosity = 'Detailed'
$configuration.TestResult.Enabled = $true
$configuration.TestResult.OutputPath = 'test-results.xml'
Invoke-Pester -Configuration $configuration
- name: Upload test results
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: test-results-windows-51
path: test-results.xml
- name: Run script analyzer
shell: powershell
run: |
Import-Module PSScriptAnalyzer
$params = @{
Path = './ColorScripts-Enhanced'
Settings = './PSScriptAnalyzerSettings.psd1'
Recurse = $true
ReportSummary = $true
}
$params.Severity = @('Error','Warning')
$results = Invoke-ScriptAnalyzer @params
if ($results) {
$results | Format-Table -AutoSize
throw 'ScriptAnalyzer reported findings.'
}
- 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.4 (${{ matrix.os }})
runs-on: ${{ matrix.os }}
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@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
with:
egress-policy: audit
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- 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
shell: pwsh
run: |
Import-Module Pester
$configuration = New-PesterConfiguration
$configuration.Run.Path = './Tests'
$configuration.Output.Verbosity = 'Detailed'
$configuration.TestResult.Enabled = $true
$configuration.TestResult.OutputPath = 'test-results.xml'
Invoke-Pester -Configuration $configuration
- name: Upload test results
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: test-results-${{ matrix.os }}-pwsh
path: test-results.xml
- name: Run script analyzer
shell: pwsh
run: |
Import-Module PSScriptAnalyzer
$params = @{
Path = './ColorScripts-Enhanced'
Settings = './PSScriptAnalyzerSettings.psd1'
Recurse = $true
ReportSummary = $true
}
$params.Severity = @('Error','Warning')
$results = Invoke-ScriptAnalyzer @params
if ($results) {
$results | Format-Table -AutoSize
throw 'ScriptAnalyzer reported findings.'
}
- name: Validate help topics
shell: pwsh
run: |
Import-Module ./ColorScripts-Enhanced -Force
Get-Help Show-ColorScript
Get-Help about_ColorScripts-Enhanced