Skip to content

Commit 7499989

Browse files
committed
Only lint changed files on PR
1 parent f6dccd0 commit 7499989

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

.github/scripts/lint.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,9 @@ set -e
1818
export LC_ALL=C.UTF-8
1919
export LANG=C.UTF-8
2020

21-
find . -iname "*.py" | xargs pylint
21+
if [ -f "${HOME}/changed_files.txt" ]; then
22+
# TODO - Check for .pylintrc changes
23+
cat "${HOME}/changed_files.txt" | grep ".py$" | xargs pylint
24+
else
25+
find . -iname "*.py" | xargs pylint
26+
fi

.github/workflows/ci.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v2
14+
- name: Fetch and Diff PR with base from which it was cloned
15+
if: ${{ github.event.pull_request.base.sha }}
16+
run: |
17+
git fetch origin main ${{ github.event.pull_request.base.sha }}
18+
git diff --diff-filter=ACM --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} > $HOME/changed_files.txt
1419
- name: Set up Python ${{ matrix.python-version }}
1520
uses: actions/setup-python@v2
1621
with:
@@ -29,6 +34,11 @@ jobs:
2934
python-version: [3.6]
3035
steps:
3136
- uses: actions/checkout@v2
37+
- name: Fetch and Diff PR with base from which it was cloned
38+
if: ${{ github.event.pull_request.base.sha }}
39+
run: |
40+
git fetch origin main ${{ github.event.pull_request.base.sha }}
41+
git diff --diff-filter=ACM --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} > $HOME/changed_files.txt
3242
- name: Set up Python ${{ matrix.python-version }}
3343
uses: actions/setup-python@v2
3444
with:

0 commit comments

Comments
 (0)