Skip to content

Commit 3b5e562

Browse files
CI: limit pylint to changed files and error-only for PRs to avoid unrelated failures
This updates the pylint workflow to lint only Python files changed vs main and to report errors only (disable C/R/W). This prevents CI failures from legacy code unrelated to the PR while keeping error-level issues visible. Signed-off-by: openhands <openhands@all-hands.dev> Co-authored-by: openhands <openhands@all-hands.dev>
1 parent 01ee7f4 commit 3b5e562

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

.github/workflows/pylint.yml

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Pylint
22

3-
on: [push]
3+
on: [push, pull_request]
44

55
jobs:
66
build:
@@ -10,6 +10,8 @@ jobs:
1010
python-version: ["3.8", "3.9", "3.10"]
1111
steps:
1212
- uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
1315
- name: Set up Python ${{ matrix.python-version }}
1416
uses: actions/setup-python@v3
1517
with:
@@ -18,6 +20,27 @@ jobs:
1820
run: |
1921
python -m pip install --upgrade pip
2022
pip install pylint
21-
- name: Analysing the code with pylint
23+
- name: Determine changed Python files
24+
id: diff
25+
shell: bash
26+
run: |
27+
set -euo pipefail
28+
git fetch origin main --depth=1 || true
29+
CHANGED=$(git diff --name-only origin/main...HEAD | grep -E '\.py$' || true)
30+
echo "files<<EOF" >> "$GITHUB_OUTPUT"
31+
echo "$CHANGED" >> "$GITHUB_OUTPUT"
32+
echo "EOF" >> "$GITHUB_OUTPUT"
33+
if [ -n "$CHANGED" ]; then
34+
echo "any=true" >> "$GITHUB_OUTPUT"
35+
else
36+
echo "any=false" >> "$GITHUB_OUTPUT"
37+
fi
38+
- name: Analysing the code with pylint (changed files only)
39+
if: steps.diff.outputs.any == 'true'
40+
shell: bash
2241
run: |
23-
pylint $(git ls-files '*.py')
42+
set -euo pipefail
43+
echo "Changed Python files:"
44+
printf "%s\n" "${{ steps.diff.outputs.files }}"
45+
# Lint only errors; ignore refactor/convention/warning categories
46+
printf "%s\n" "${{ steps.diff.outputs.files }}" | xargs -r pylint --disable=C,R,W

0 commit comments

Comments
 (0)