-
Notifications
You must be signed in to change notification settings - Fork 14
85 lines (76 loc) · 2.61 KB
/
Copy pathlint.yml
File metadata and controls
85 lines (76 loc) · 2.61 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
name: CI
on:
push:
branches: [main]
paths: ['**.ps1', '**.psm1', '**.psd1', 'config/**', 'tests/**']
pull_request:
branches: [main]
paths: ['**.ps1', '**.psm1', '**.psd1', 'config/**', 'tests/**']
jobs:
lint:
name: Lint PowerShell
runs-on: windows-latest
steps:
- uses: actions/checkout@v7
- name: Install PSScriptAnalyzer
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser
- name: Run PSScriptAnalyzer
shell: pwsh
run: |
$results = Invoke-ScriptAnalyzer -Path . -Recurse -Settings @{
Rules = @{
PSAvoidUsingCmdletAliases = @{ Enable = $true }
PSAvoidUsingWriteHost = @{ Enable = $false }
}
ExcludeRules = @(
'PSAvoidUsingWriteHost',
'PSAvoidUsingInvokeExpression',
'PSUseShouldProcessForStateChangingFunctions',
'PSUseSingularNouns',
'PSUseDeclaredVarsMoreThanAssignments',
'PSAvoidUsingPositionalParameters',
'PSAvoidOverwritingBuiltInCmdlets',
'PSUseBOMForUnicodeEncodedFile',
'PSAvoidUsingEmptyCatchBlock',
'PSUseApprovedVerbs',
'PSUseUsingScopeModifierInNewRunspaces',
'PSReviewUnusedParameter'
)
}
if ($results) {
$results | Format-Table -AutoSize
Write-Error "PSScriptAnalyzer found $($results.Count) issue(s)."
exit 1
} else {
Write-Host "No issues found." -ForegroundColor Green
}
test:
name: Run Pester Tests
runs-on: windows-latest
steps:
- uses: actions/checkout@v7
- name: Install Pester
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module -Name Pester -Force -Scope CurrentUser -MinimumVersion 5.5.0
- name: Run Pester Tests
shell: pwsh
run: |
$config = New-PesterConfiguration
$config.Run.Path = './tests'
$config.Run.Exit = $true
$config.Output.Verbosity = 'Detailed'
$config.TestResult.Enabled = $true
$config.TestResult.OutputFormat = 'NUnitXml'
$config.TestResult.OutputPath = './testresults.xml'
Invoke-Pester -Configuration $config
- name: Upload Test Results
uses: actions/upload-artifact@v7
if: always()
with:
name: test-results
path: ./testresults.xml