Skip to content

Commit 8a50a6a

Browse files
committed
workflows: lint: Add python lint
Now that we've scripts written in python, let's make we lint them for errors. Again, vibe generated using Cursor AI. Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
1 parent ea84009 commit 8a50a6a

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

.github/workflows/static-lint.yaml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,69 @@ jobs:
8484
echo "## ✅ YAML Lint Passed" >> $GITHUB_STEP_SUMMARY
8585
fi
8686
87+
python-lint:
88+
name: Python Lint
89+
runs-on: ubuntu-22.04
90+
steps:
91+
- name: Checkout code
92+
uses: actions/checkout@v4
93+
94+
- name: Set up Python
95+
uses: actions/setup-python@v5
96+
with:
97+
python-version: '3.x'
98+
99+
- name: Install linting tools
100+
run: |
101+
pip install flake8 pylint
102+
103+
- name: Run flake8
104+
id: flake8
105+
continue-on-error: true
106+
run: |
107+
echo "🔍 Running flake8..."
108+
if find . -name "*.py" -not -path "./node_modules/*" | grep -q .; then
109+
flake8 --max-line-length=120 --ignore=E501,W503 \
110+
--exclude=node_modules,.git,__pycache__ \
111+
. > /tmp/flake8-output.txt 2>&1 || true
112+
113+
if [ -s /tmp/flake8-output.txt ]; then
114+
echo "result=found_issues" >> $GITHUB_OUTPUT
115+
cat /tmp/flake8-output.txt
116+
else
117+
echo "✅ No Python lint issues found"
118+
echo "result=success" >> $GITHUB_OUTPUT
119+
fi
120+
else
121+
echo "ℹ️ No Python files found to lint"
122+
echo "result=no_files" >> $GITHUB_OUTPUT
123+
fi
124+
125+
- name: Show Python lint summary
126+
if: always()
127+
run: |
128+
if [ "${{ steps.flake8.outputs.result }}" = "found_issues" ]; then
129+
echo "## ⚠️ Python Lint Issues Found" >> $GITHUB_STEP_SUMMARY
130+
echo "" >> $GITHUB_STEP_SUMMARY
131+
echo '```' >> $GITHUB_STEP_SUMMARY
132+
cat /tmp/flake8-output.txt >> $GITHUB_STEP_SUMMARY
133+
echo '```' >> $GITHUB_STEP_SUMMARY
134+
echo "" >> $GITHUB_STEP_SUMMARY
135+
echo "### How to Fix:" >> $GITHUB_STEP_SUMMARY
136+
echo "1. Install flake8: \`pip install flake8\`" >> $GITHUB_STEP_SUMMARY
137+
echo "2. Run \`flake8 .\` to see all issues" >> $GITHUB_STEP_SUMMARY
138+
echo "3. Common issues:" >> $GITHUB_STEP_SUMMARY
139+
echo " - Indentation errors (use 4 spaces for Python)" >> $GITHUB_STEP_SUMMARY
140+
echo " - Unused imports" >> $GITHUB_STEP_SUMMARY
141+
echo " - Undefined variables" >> $GITHUB_STEP_SUMMARY
142+
echo " - PEP 8 style violations" >> $GITHUB_STEP_SUMMARY
143+
echo "4. Use \`autopep8\` or \`black\` for automatic formatting" >> $GITHUB_STEP_SUMMARY
144+
elif [ "${{ steps.flake8.outputs.result }}" = "success" ]; then
145+
echo "## ✅ Python Lint Passed" >> $GITHUB_STEP_SUMMARY
146+
else
147+
echo "## ℹ️ No Python Files Found" >> $GITHUB_STEP_SUMMARY
148+
fi
149+
87150
action-lint:
88151
name: GitHub Actions Lint
89152
runs-on: ubuntu-22.04

0 commit comments

Comments
 (0)