Skip to content

Commit d91ccae

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

File tree

1 file changed

+125
-0
lines changed

1 file changed

+125
-0
lines changed

.github/workflows/static-lint.yaml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: Static Lint
2+
3+
on:
4+
pull_request:
5+
types:
6+
- edited
7+
- opened
8+
- reopened
9+
- syncrhonize
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+
else
60+
echo "✅ No YAML lint issues found"
61+
echo "result=success" >> $GITHUB_OUTPUT
62+
fi
63+
64+
- name: Show YAML lint summary
65+
if: always()
66+
run: |
67+
if [ "${{ steps.yamllint.outputs.result }}" = "found_issues" ]; then
68+
echo "## ⚠️ YAML Lint Issues Found" >> $GITHUB_STEP_SUMMARY
69+
echo "" >> $GITHUB_STEP_SUMMARY
70+
echo '```' >> $GITHUB_STEP_SUMMARY
71+
cat /tmp/yamllint-output.txt >> $GITHUB_STEP_SUMMARY
72+
echo '```' >> $GITHUB_STEP_SUMMARY
73+
echo "" >> $GITHUB_STEP_SUMMARY
74+
echo "### How to Fix:" >> $GITHUB_STEP_SUMMARY
75+
echo "1. Install yamllint: \`pip install yamllint\`" >> $GITHUB_STEP_SUMMARY
76+
echo "2. Run \`yamllint .\` to see all issues" >> $GITHUB_STEP_SUMMARY
77+
echo "3. Common issues:" >> $GITHUB_STEP_SUMMARY
78+
echo " - Indentation errors (use 2 spaces)" >> $GITHUB_STEP_SUMMARY
79+
echo " - Line too long (max 120 characters)" >> $GITHUB_STEP_SUMMARY
80+
echo " - Trailing spaces" >> $GITHUB_STEP_SUMMARY
81+
echo " - Missing spaces after colons" >> $GITHUB_STEP_SUMMARY
82+
echo "4. Modify .yamllint.yaml to adjust rules if needed" >> $GITHUB_STEP_SUMMARY
83+
else
84+
echo "## ✅ YAML Lint Passed" >> $GITHUB_STEP_SUMMARY
85+
fi
86+
87+
action-lint:
88+
name: GitHub Actions Lint
89+
runs-on: ubuntu-22.04
90+
steps:
91+
- name: Checkout code
92+
uses: actions/checkout@v4
93+
94+
- name: Run actionlint
95+
uses: reviewdog/action-actionlint@v1
96+
with:
97+
fail_on_error: false
98+
reporter: github-check
99+
continue-on-error: true
100+
id: actionlint
101+
102+
- name: Show GitHub Actions lint summary
103+
if: always()
104+
run: |
105+
if [ "${{ steps.actionlint.outcome }}" = "failure" ]; then
106+
echo "## ⚠️ GitHub Actions Workflow Issues Found" >> $GITHUB_STEP_SUMMARY
107+
echo "" >> $GITHUB_STEP_SUMMARY
108+
echo "### How to Fix:" >> $GITHUB_STEP_SUMMARY
109+
echo "1. Install actionlint:" >> $GITHUB_STEP_SUMMARY
110+
echo " \`\`\`bash" >> $GITHUB_STEP_SUMMARY
111+
echo " go install github.com/rhysd/actionlint/cmd/actionlint@latest" >> $GITHUB_STEP_SUMMARY
112+
echo " # or" >> $GITHUB_STEP_SUMMARY
113+
echo " brew install actionlint" >> $GITHUB_STEP_SUMMARY
114+
echo " \`\`\`" >> $GITHUB_STEP_SUMMARY
115+
echo "2. Run \`actionlint\` in your repo root" >> $GITHUB_STEP_SUMMARY
116+
echo "3. Common issues:" >> $GITHUB_STEP_SUMMARY
117+
echo " - Invalid workflow syntax" >> $GITHUB_STEP_SUMMARY
118+
echo " - Undefined environment variables" >> $GITHUB_STEP_SUMMARY
119+
echo " - Deprecated actions or syntax" >> $GITHUB_STEP_SUMMARY
120+
echo " - Invalid shell commands in run steps" >> $GITHUB_STEP_SUMMARY
121+
echo "4. See https://github.com/rhysd/actionlint for details" >> $GITHUB_STEP_SUMMARY
122+
else
123+
echo "## ✅ GitHub Actions Lint Passed" >> $GITHUB_STEP_SUMMARY
124+
fi
125+

0 commit comments

Comments
 (0)