8
8
with :
9
9
fetch-depth : 0 # To get all history for git diff commands
10
10
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
-
20
11
- name : Get changed Python files
21
12
id : changed-files
22
13
run : |
@@ -28,42 +19,59 @@ jobs:
28
19
CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.before }} ${{ github.event.after }} | grep '\.py$' || echo "")
29
20
fi
30
21
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
32
44
33
45
- name : Lint with flake8
34
- if : ${{ steps.changed-files.outputs.files != ' ' }}
46
+ if : ${{ steps.changed-files.outputs.has_python_changes == 'true ' }}
35
47
run : |
36
48
echo "Linting files: ${{ steps.changed-files.outputs.files }}"
37
49
flake8 ${{ steps.changed-files.outputs.files }} --count --show-source --statistics
38
- continue-on-error : true
39
50
40
51
- name : Format check with isort and black
41
- if : ${{ steps.changed-files.outputs.files != ' ' }}
52
+ if : ${{ steps.changed-files.outputs.has_python_changes == 'true ' }}
42
53
run : |
43
54
echo "Checking format with isort for: ${{ steps.changed-files.outputs.files }}"
44
55
isort --profile black --check ${{ steps.changed-files.outputs.files }}
45
56
echo "Checking format with black for: ${{ steps.changed-files.outputs.files }}"
46
57
black --check ${{ steps.changed-files.outputs.files }}
47
- continue-on-error : true
48
58
49
59
- name : Type check with mypy
50
- if : ${{ steps.changed-files.outputs.files != ' ' }}
60
+ if : ${{ steps.changed-files.outputs.has_python_changes == 'true ' }}
51
61
run : |
52
62
echo "Type checking: ${{ steps.changed-files.outputs.files }}"
53
63
mypy --ignore-missing-imports ${{ steps.changed-files.outputs.files }}
54
- continue-on-error : true
55
64
56
65
- name : Run tests with pytest
66
+ if : ${{ steps.changed-files.outputs.has_python_changes == 'true' }}
57
67
run : |
58
68
pytest ./patterns
59
69
pytest --doctest-modules ./patterns || true
60
- continue-on-error : true
61
70
62
71
- name : Check Python version compatibility
63
- if : ${{ steps.changed-files.outputs.files != ' ' }}
72
+ if : ${{ steps.changed-files.outputs.has_python_changes == 'true ' }}
64
73
run : pyupgrade --py312-plus ${{ steps.changed-files.outputs.files }}
65
- continue-on-error : true
66
74
67
75
- name : Run tox
76
+ if : ${{ steps.changed-files.outputs.has_python_changes == 'true' }}
68
77
run : tox
69
- continue-on-error : true
0 commit comments