-
-
Notifications
You must be signed in to change notification settings - Fork 634
88 lines (77 loc) · 2.43 KB
/
Lint.yml
File metadata and controls
88 lines (77 loc) · 2.43 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
name: Lint
on:
workflow_dispatch:
push:
branches:
- main
# tags:
# - '*.*.*'
pull_request:
branches:
- main
jobs:
patch:
runs-on: windows-latest
timeout-minutes: 5
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@main
- name: Run Lint
run: |
# Check module for errors
$Results = @(Get-ChildItem -Path src -File -Recurse -Include *.ps1, *.psm1 | Invoke-ScriptAnalyzer)
if ($Results | Where-Object -FilterScript {($_.Severity -eq "Error") -or ($_.Severity -eq "ParseError")})
{
Write-Verbose -Message "Found script issue" -Verbose
$Results | Where-Object -FilterScript {($_.Severity -eq "Error") -or ($_.Severity -eq "ParseError")} | ForEach-Object -Process {
[PSCustomObject]@{
Line = $_.Line
Message = $_.Message
Path = $_.ScriptPath
}
} | Format-Table -AutoSize -Wrap
# Exit with a non-zero status to fail the job
exit 1
}
- name: Check JSONs validity
run: |
# Check JSONs for errors
$JSONs = [Array]::TrueForAll((@(Get-ChildItem -Path Wrapper -File -Recurse -Filter *.json).FullName),
[Predicate[string]]{
param($JSON)
Test-Json -Path $JSON -ErrorAction Ignore
})
if (-not $JSONs)
{
Write-Verbose -Message "Found JSON issue" -Verbose
# Exit with a non-zero status to fail the job
exit 1
}
- name: Check module localizations
run: |
function Parse-PSD1
{
[CmdletBinding()]
param
(
[Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformation()]
[hashtable]
$Path
)
return $Path
}
Get-ChildItem -Path src -File -Filter *.psd1 -Recurse | ForEach-Object -Process {
$File = $_.FullName
try
{
Parse-PSD1 -Path $_.FullName -ErrorAction Stop | Out-Null
}
catch
{
Write-Verbose -Message $File -Verbose
# Exit with a non-zero status to fail the job
exit 1
}
}