Skip to content

Commit 61f219e

Browse files
committed
workflows: Add static linter
Again, vibe generated using Cursor AI. :-) Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
1 parent 751ec60 commit 61f219e

File tree

1 file changed

+134
-0
lines changed

1 file changed

+134
-0
lines changed

.github/workflows/static-lint.yaml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: Static Lint
2+
3+
on:
4+
pull_request:
5+
types:
6+
- edited
7+
- opened
8+
- reopened
9+
- synchronize
10+
11+
jobs:
12+
yaml-lint:
13+
name: YAML Lint
14+
runs-on: ubuntu-22.04
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: '3.x'
23+
24+
- name: Install yamllint
25+
run: pip install yamllint
26+
27+
- name: Create yamllint config
28+
run: |
29+
cat > .yamllint.yaml << 'EOF'
30+
extends: default
31+
rules:
32+
line-length:
33+
max: 120
34+
level: warning
35+
comments:
36+
min-spaces-from-content: 1
37+
indentation:
38+
spaces: 2
39+
indent-sequences: true
40+
document-start: disable
41+
truthy:
42+
allowed-values: ['true', 'false', 'on', 'off']
43+
ignore: |
44+
node_modules/
45+
.github/
46+
charts/
47+
EOF
48+
49+
- name: Run yamllint
50+
id: yamllint
51+
continue-on-error: true
52+
run: |
53+
echo "🔍 Running yamllint..."
54+
yamllint . > /tmp/yamllint-output.txt 2>&1 || true
55+
56+
if [ -s /tmp/yamllint-output.txt ]; then
57+
echo "result=found_issues" >> $GITHUB_OUTPUT
58+
cat /tmp/yamllint-output.txt
59+
echo "::error::YAML lint issues found. See job output for details."
60+
else
61+
echo "✅ No YAML lint issues found"
62+
echo "result=success" >> $GITHUB_OUTPUT
63+
fi
64+
65+
- name: Show YAML lint summary
66+
if: always()
67+
run: |
68+
if [ "${{ steps.yamllint.outputs.result }}" = "found_issues" ]; then
69+
echo "## ⚠️ YAML Lint Issues Found" >> $GITHUB_STEP_SUMMARY
70+
echo "" >> $GITHUB_STEP_SUMMARY
71+
echo '```' >> $GITHUB_STEP_SUMMARY
72+
cat /tmp/yamllint-output.txt >> $GITHUB_STEP_SUMMARY
73+
echo '```' >> $GITHUB_STEP_SUMMARY
74+
echo "" >> $GITHUB_STEP_SUMMARY
75+
echo "### How to Fix:" >> $GITHUB_STEP_SUMMARY
76+
echo "1. Install yamllint: \`pip install yamllint\`" >> $GITHUB_STEP_SUMMARY
77+
echo "2. Run \`yamllint .\` to see all issues" >> $GITHUB_STEP_SUMMARY
78+
echo "3. Common issues:" >> $GITHUB_STEP_SUMMARY
79+
echo " - Indentation errors (use 2 spaces)" >> $GITHUB_STEP_SUMMARY
80+
echo " - Line too long (max 120 characters)" >> $GITHUB_STEP_SUMMARY
81+
echo " - Trailing spaces" >> $GITHUB_STEP_SUMMARY
82+
echo " - Missing spaces after colons" >> $GITHUB_STEP_SUMMARY
83+
echo "4. Modify .yamllint.yaml to adjust rules if needed" >> $GITHUB_STEP_SUMMARY
84+
else
85+
echo "## ✅ YAML Lint Passed" >> $GITHUB_STEP_SUMMARY
86+
fi
87+
88+
- name: Fail if YAML lint found issues
89+
if: steps.yamllint.outputs.result == 'found_issues'
90+
run: exit 1
91+
92+
action-lint:
93+
name: GitHub Actions Lint
94+
runs-on: ubuntu-22.04
95+
steps:
96+
- name: Checkout code
97+
uses: actions/checkout@v4
98+
99+
- name: Run actionlint
100+
uses: reviewdog/action-actionlint@v1
101+
with:
102+
fail_on_error: false
103+
reporter: github-check
104+
continue-on-error: true
105+
id: actionlint
106+
107+
- name: Show GitHub Actions lint summary
108+
if: always()
109+
run: |
110+
if [ "${{ steps.actionlint.outcome }}" = "failure" ]; then
111+
echo "## ⚠️ GitHub Actions Workflow Issues Found" >> $GITHUB_STEP_SUMMARY
112+
echo "" >> $GITHUB_STEP_SUMMARY
113+
echo "### How to Fix:" >> $GITHUB_STEP_SUMMARY
114+
echo "1. Install actionlint:" >> $GITHUB_STEP_SUMMARY
115+
echo " \`\`\`bash" >> $GITHUB_STEP_SUMMARY
116+
echo " go install github.com/rhysd/actionlint/cmd/actionlint@latest" >> $GITHUB_STEP_SUMMARY
117+
echo " # or" >> $GITHUB_STEP_SUMMARY
118+
echo " brew install actionlint" >> $GITHUB_STEP_SUMMARY
119+
echo " \`\`\`" >> $GITHUB_STEP_SUMMARY
120+
echo "2. Run \`actionlint\` in your repo root" >> $GITHUB_STEP_SUMMARY
121+
echo "3. Common issues:" >> $GITHUB_STEP_SUMMARY
122+
echo " - Invalid workflow syntax" >> $GITHUB_STEP_SUMMARY
123+
echo " - Undefined environment variables" >> $GITHUB_STEP_SUMMARY
124+
echo " - Deprecated actions or syntax" >> $GITHUB_STEP_SUMMARY
125+
echo " - Invalid shell commands in run steps" >> $GITHUB_STEP_SUMMARY
126+
echo "4. See https://github.com/rhysd/actionlint for details" >> $GITHUB_STEP_SUMMARY
127+
else
128+
echo "## ✅ GitHub Actions Lint Passed" >> $GITHUB_STEP_SUMMARY
129+
fi
130+
131+
- name: Fail if actionlint found issues
132+
if: steps.actionlint.outcome == 'failure'
133+
run: exit 1
134+

0 commit comments

Comments
 (0)