-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
206 lines (173 loc) · 6.16 KB
/
lint.yml
File metadata and controls
206 lines (173 loc) · 6.16 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
---
name: Lint
'on':
push:
branches: [main, master]
pull_request:
permissions:
contents: read
jobs:
ansible-lint:
name: Ansible linting
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@900f2210b1d28bbbd0bd22d17926b9e224e8f231 # v5.0.1
with:
persist-credentials: false
- name: Setup Algo environment
uses: ./.github/actions/setup-algo
with:
install-ansible-collections: 'true'
- name: Run ansible-lint
run: |
uv run --with ansible-lint ansible-lint .
- name: Run playbook dry-run check (catch runtime issues)
run: |
# Test main playbook logic without making changes
# This catches filter warnings, collection issues, and runtime errors
uv run ansible-playbook main.yml --check --connection=local \
-e "server_ip=test" \
-e "server_name=ci-test" \
-e "IP_subject_alt_name=192.168.1.1" \
|| echo "Dry-run check completed with issues - review output above"
yaml-lint:
name: YAML linting
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@900f2210b1d28bbbd0bd22d17926b9e224e8f231 # v5.0.1
with:
persist-credentials: false
- name: Setup uv environment
uses: ./.github/actions/setup-uv
- name: Run yamllint
run: uv run --with yamllint yamllint -c .yamllint .
jinja2-lint:
name: Jinja2 template linting
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@900f2210b1d28bbbd0bd22d17926b9e224e8f231 # v5.0.1
with:
persist-credentials: false
- name: Setup uv environment
uses: ./.github/actions/setup-uv
- name: Run j2lint
run: |
# Lint Jinja2 templates for syntax and style issues
# Ignored rules (incompatible with Ansible config-file templates):
# S3: indentation (dictated by output format, not Jinja style)
# S5: tabs (some config formats require them)
# S6: whitespace-control delimiters ({%- -%} are standard Ansible)
# S7: single-statement-per-line (inline Jinja in config output)
# V1: lowercase variables (existing names like IP_subject_alt_name)
uv run --with j2lint j2lint roles/ --ignore S3 S5 S6 S7 V1
python-lint:
name: Python linting
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@900f2210b1d28bbbd0bd22d17926b9e224e8f231 # v5.0.1
with:
persist-credentials: false
- name: Setup Algo environment
uses: ./.github/actions/setup-algo
- name: Run ruff check
run: |
# Fast Python linter
uv run --with ruff ruff check .
- name: Run ruff format check
run: |
# Verify consistent Python formatting
uv run --with ruff ruff format --check .
python-types:
name: Python type checking
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@900f2210b1d28bbbd0bd22d17926b9e224e8f231 # v5.0.1
with:
persist-credentials: false
- name: Setup Algo environment
uses: ./.github/actions/setup-algo
- name: Run ty check
run: |
# Type checking with ty
uv run --with ty ty check
shellcheck:
name: Shell script linting
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@900f2210b1d28bbbd0bd22d17926b9e224e8f231 # v5.0.1
with:
persist-credentials: false
- name: Setup Algo environment
uses: ./.github/actions/setup-algo
with:
install-shellcheck: 'true'
- name: Run shellcheck
run: |
# Check all shell scripts, not just algo and install.sh
find . -type f -name "*.sh" -not -path "./.git/*" -exec shellcheck {} \;
powershell-lint:
name: PowerShell script linting
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@900f2210b1d28bbbd0bd22d17926b9e224e8f231 # v5.0.1
with:
persist-credentials: false
- name: Install PowerShell
run: |
# Install PowerShell Core
wget -q https://github.com/PowerShell/PowerShell/releases/download/v7.4.0/powershell_7.4.0-1.deb_amd64.deb
sudo dpkg -i powershell_7.4.0-1.deb_amd64.deb
sudo apt-get install -f
- name: Install PSScriptAnalyzer
run: |
pwsh -Command "Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser"
- name: Run PowerShell syntax check
run: |
# Check syntax by parsing the script
pwsh -NoProfile -NonInteractive -Command "
try {
\$null = [System.Management.Automation.PSParser]::Tokenize((Get-Content -Path './algo.ps1' -Raw), [ref]\$null)
Write-Host '✓ PowerShell syntax check passed'
} catch {
Write-Error 'PowerShell syntax error: ' + \$_.Exception.Message
exit 1
}
"
- name: Run PSScriptAnalyzer
run: |
pwsh -Command "
\$results = Invoke-ScriptAnalyzer -Path './algo.ps1' -Severity Warning,Error
if (\$results.Count -gt 0) {
\$results | Format-Table -AutoSize
exit 1
} else {
Write-Host '✓ PSScriptAnalyzer check passed'
}
"
actionlint:
name: GitHub Actions linting
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@900f2210b1d28bbbd0bd22d17926b9e224e8f231 # v5.0.1
with:
persist-credentials: false
- name: Install actionlint
run: |
bash <(curl -sL https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
sudo mv actionlint /usr/local/bin/
- name: Run actionlint
run: |
actionlint .github/workflows/*.yml
zizmor:
name: GitHub Actions security audit
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@900f2210b1d28bbbd0bd22d17926b9e224e8f231 # v5.0.1
with:
persist-credentials: false
- name: Install zizmor
run: |
pip install zizmor
- name: Run zizmor
run: |
zizmor .github/workflows/