Repository navigation
76 lines (66 loc) · 2.23 KB
/
Copy pathPullRequest.yml
File metadata and controls
76 lines (66 loc) · 2.23 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
name: Pull Request
on:
pull_request:
branches: [ main ]
workflow_dispatch:
defaults:
run:
shell: pwsh
jobs:
PesterTest:
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Pester 5
shell: pwsh
run: |
$ConfirmPreference = 'None'
if (-not (Get-Module -ListAvailable -Name Pester | Where-Object { $_.Version -ge [version]'5.5.0' })) {
Install-Module -Name Pester -MinimumVersion 5.5.0 -Force -SkipPublisherCheck -Scope CurrentUser
}
- name: Run Pester Tests
shell: pwsh
run: |
$ConfirmPreference = 'None'
Import-Module Pester -MinimumVersion 5.5.0
$config = New-PesterConfiguration
$config.Run.Path = './Modules.Tests'
$config.Run.Exit = $true
$config.TestResult.Enabled = $true
$config.TestResult.OutputFormat = 'NUnitXml'
$config.TestResult.OutputPath = "${{ github.workspace }}/Test-Pester.xml"
$config.Output.Verbosity = 'Detailed'
Invoke-Pester -Configuration $config
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: pester-results-${{ matrix.os }}
path: Test-Pester.xml
ScriptAnalyzer:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install PSScriptAnalyzer
shell: pwsh
run: |
if (-not (Get-Module -ListAvailable -Name PSScriptAnalyzer)) {
Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser
}
- name: Run PSScriptAnalyzer
shell: pwsh
run: |
Import-Module PSScriptAnalyzer
$results = Invoke-ScriptAnalyzer -Path ./Modules -Recurse -Settings ./PSScriptAnalyzerSettings.psd1
if ($results) {
$results | Format-Table -AutoSize | Out-String | Write-Host
$errors = @($results | Where-Object Severity -eq 'Error')
if ($errors.Count -gt 0) {
Write-Error "PSScriptAnalyzer found $($errors.Count) error(s)."
exit 1
}
}