Skip to content

Commit b14815c

Browse files
committed
Added approval for non-Python files and removed continue-on-error
1 parent a48d192 commit b14815c

File tree

1 file changed

+28
-20
lines changed

1 file changed

+28
-20
lines changed

.github/workflows/lint_pr.yml

+28-20
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,6 @@ jobs:
88
with:
99
fetch-depth: 0 # To get all history for git diff commands
1010

11-
- uses: actions/setup-python@v4
12-
with:
13-
python-version: 3.12
14-
15-
- name: Install dependencies
16-
run: |
17-
python -m pip install --upgrade pip
18-
pip install -r requirements-dev.txt
19-
2011
- name: Get changed Python files
2112
id: changed-files
2213
run: |
@@ -28,42 +19,59 @@ jobs:
2819
CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.before }} ${{ github.event.after }} | grep '\.py$' || echo "")
2920
fi
3021
echo "files=$CHANGED_FILES" >> $GITHUB_OUTPUT
31-
echo "Changed Python files: $CHANGED_FILES"
22+
if [ -z "$CHANGED_FILES" ]; then
23+
echo "No Python files changed, PR will still require approval"
24+
echo "has_python_changes=false" >> $GITHUB_OUTPUT
25+
else
26+
echo "Changed Python files: $CHANGED_FILES"
27+
echo "has_python_changes=true" >> $GITHUB_OUTPUT
28+
fi
29+
30+
- name: PR information
31+
if: ${{ github.event_name == 'pull_request' && steps.changed-files.outputs.has_python_changes == 'false' }}
32+
run: echo "This PR contains no Python changes, but still requires manual approval."
33+
34+
- uses: actions/setup-python@v4
35+
if: ${{ steps.changed-files.outputs.has_python_changes == 'true' }}
36+
with:
37+
python-version: 3.12
38+
39+
- name: Install dependencies
40+
if: ${{ steps.changed-files.outputs.has_python_changes == 'true' }}
41+
run: |
42+
python -m pip install --upgrade pip
43+
pip install -r requirements-dev.txt
3244
3345
- name: Lint with flake8
34-
if: ${{ steps.changed-files.outputs.files != '' }}
46+
if: ${{ steps.changed-files.outputs.has_python_changes == 'true' }}
3547
run: |
3648
echo "Linting files: ${{ steps.changed-files.outputs.files }}"
3749
flake8 ${{ steps.changed-files.outputs.files }} --count --show-source --statistics
38-
continue-on-error: true
3950
4051
- name: Format check with isort and black
41-
if: ${{ steps.changed-files.outputs.files != '' }}
52+
if: ${{ steps.changed-files.outputs.has_python_changes == 'true' }}
4253
run: |
4354
echo "Checking format with isort for: ${{ steps.changed-files.outputs.files }}"
4455
isort --profile black --check ${{ steps.changed-files.outputs.files }}
4556
echo "Checking format with black for: ${{ steps.changed-files.outputs.files }}"
4657
black --check ${{ steps.changed-files.outputs.files }}
47-
continue-on-error: true
4858
4959
- name: Type check with mypy
50-
if: ${{ steps.changed-files.outputs.files != '' }}
60+
if: ${{ steps.changed-files.outputs.has_python_changes == 'true' }}
5161
run: |
5262
echo "Type checking: ${{ steps.changed-files.outputs.files }}"
5363
mypy --ignore-missing-imports ${{ steps.changed-files.outputs.files }}
54-
continue-on-error: true
5564
5665
- name: Run tests with pytest
66+
if: ${{ steps.changed-files.outputs.has_python_changes == 'true' }}
5767
run: |
5868
pytest ./patterns
5969
pytest --doctest-modules ./patterns || true
60-
continue-on-error: true
6170
6271
- name: Check Python version compatibility
63-
if: ${{ steps.changed-files.outputs.files != '' }}
72+
if: ${{ steps.changed-files.outputs.has_python_changes == 'true' }}
6473
run: pyupgrade --py312-plus ${{ steps.changed-files.outputs.files }}
65-
continue-on-error: true
6674

6775
- name: Run tox
76+
if: ${{ steps.changed-files.outputs.has_python_changes == 'true' }}
6877
run: tox
69-
continue-on-error: true

0 commit comments

Comments
 (0)