Repository navigation
64 lines (58 loc) · 1.7 KB
/
Copy pathscript-lint.yml
File metadata and controls
64 lines (58 loc) · 1.7 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
name: Lint Install Scripts
on:
push:
branches: [ main ]
paths:
- 'install.sh'
- 'install.ps1'
- 'uninstall.sh'
- 'uninstall.ps1'
- '.github/workflows/script-lint.yml'
pull_request:
branches: [ main ]
paths:
- 'install.sh'
- 'install.ps1'
- 'uninstall.sh'
- 'uninstall.ps1'
- '.github/workflows/script-lint.yml'
permissions:
contents: read
jobs:
shellcheck:
name: Lint install.sh and uninstall.sh
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
with:
scandir: '.'
additional_files: 'install.sh uninstall.sh'
psscriptanalyzer:
name: Lint install.ps1 and uninstall.ps1
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run PSScriptAnalyzer
shell: pwsh
run: |
Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser
$failed = $false
foreach ($script in './install.ps1', './uninstall.ps1') {
# Exclude PSAvoidUsingWriteHost - Write-Host is intentional for colored installer output
$results = Invoke-ScriptAnalyzer -Path $script -Severity Error,Warning -ExcludeRule PSAvoidUsingWriteHost,PSUseBOMForUnicodeEncodedFile
if ($results) {
Write-Host "Issues in ${script}:"
$results | Format-Table -AutoSize
$failed = $true
}
else {
Write-Host "✅ No issues found in $script"
}
}
if ($failed) {
exit 1
}