Skip to content

Commit 0586256

Browse files
committed
refactor: arrange tools to execute in order
Run autoformatters first, then check the results with style checkers. Type check and lint after this.
1 parent 026078f commit 0586256

File tree

3 files changed

+79
-72
lines changed

3 files changed

+79
-72
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ This action may be used to execute the following applications:
1313
- [pycodestyle](https://pycodestyle.readthedocs.io)
1414
- [flake8](http://flake8.pycqa.org)
1515
- [mypy](http://mypy-lang.org/)
16+
- [docformatter](https://github.com/myint/docformatter)
17+
- [pydocstyle](https://github.com/PyCQA/pydocstyle/)
1618

1719
## Usage
1820

@@ -48,6 +50,8 @@ steps:
4850
extra-black-options: ""
4951
extra-mypy-options: ""
5052
extra-isort-options: ""
53+
extra-docformatter-options: ""
54+
extra-pydocstyle-options: ""
5155
```
5256
5357
Command build logic list:
@@ -65,9 +69,9 @@ mypy $(extra-mypy-options) $(python-root-list)
6569

6670
isort $(extra-isort-options) $(python-root-list) -c --diff
6771

68-
docformatter ${python-root-list}
72+
docformatter $(extra-docformatter-options) $(python-root-list)
6973

70-
pydocstyle ${python-root-list}
74+
pydocstyle $(extra-pydocstyle-options) $(python-root-list)
7175
```
7276

7377
## Versions used

action.yml

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,68 +5,68 @@ inputs:
55
description: "A list of all paths to test"
66
required: false
77
default: "."
8-
use-pylint:
9-
description: "Use Pylint"
8+
use-black:
9+
description: "Use Black"
1010
required: false
1111
default: true
12-
use-pycodestyle:
13-
description: "Use pycodestyle"
12+
use-isort:
13+
description: "Use isort"
1414
required: false
1515
default: true
16-
use-pydocstyle:
17-
description: "Use pydocstyle"
16+
use-docformatter:
17+
description: "Use docformatter"
1818
required: false
1919
default: true
20-
use-flake8:
21-
description: "Use Flake8"
20+
use-pycodestyle:
21+
description: "Use pycodestyle"
2222
required: false
2323
default: true
24-
use-black:
25-
description: "Use Black"
24+
use-pydocstyle:
25+
description: "Use pydocstyle"
2626
required: false
2727
default: true
2828
use-mypy:
2929
description: "Use mypy"
3030
required: false
3131
default: true
32-
use-docformatter:
33-
description: "Use docformatter"
32+
use-pylint:
33+
description: "Use Pylint"
3434
required: false
3535
default: true
36-
use-isort:
37-
description: "Use isort"
36+
use-flake8:
37+
description: "Use Flake8"
3838
required: false
3939
default: true
40-
extra-pylint-options:
41-
description: "Extra options: pylint $(extra-pylint-options) $(python-root-list)"
40+
extra-black-options:
41+
description: "Extra options: black --check $(extra-black-options) $(python-root-list)"
4242
required: false
4343
default: ""
44-
extra-pycodestyle-options:
45-
description: "Extra options: pycodestyle $(extra-pycodestyle-options) $(python-root-list)"
44+
extra-isort-options:
45+
description: "Extra options: isort -rc $(extra-isort-options) $(python-root-list) -c --diff "
4646
required: false
4747
default: ""
48-
extra-pydocstyle-options:
49-
description: "Extra options: pydocstyle $(extra-pydocstyle-options) $(python-root-list)"
48+
extra-docformatter-options:
49+
description: "Extra options: docformatter $(extra-docformatter-options) $(python-root-list)"
5050
required: false
5151
default: ""
52-
extra-flake8-options:
53-
description: "Extra options: flake8 $(extra-flake8-options) $(python-root-list)"
52+
extra-pycodestyle-options:
53+
description: "Extra options: pycodestyle $(extra-pycodestyle-options) $(python-root-list)"
5454
required: false
5555
default: ""
56-
extra-black-options:
57-
description: "Extra options: black --check $(extra-black-options) $(python-root-list)"
56+
extra-pydocstyle-options:
57+
description: "Extra options: pydocstyle $(extra-pydocstyle-options) $(python-root-list)"
5858
required: false
5959
default: ""
6060
extra-mypy-options:
6161
description: "Extra options: mypy $(extra-mypy-options) $(python-root-list)"
6262
required: false
6363
default: ""
64-
extra-docformatter-options:
65-
description: "Extra options: docformatter $(extra-docformatter-options) $(python-root-list)"
64+
extra-pylint-options:
65+
description: "Extra options: pylint $(extra-pylint-options) $(python-root-list)"
6666
required: false
6767
default: ""
68-
extra-isort-options:
69-
description: "Extra options: isort -rc $(extra-isort-options) $(python-root-list) -c --diff "
68+
extra-flake8-options:
69+
description: "Extra options: flake8 $(extra-flake8-options) $(python-root-list)"
7070
required: false
7171
default: ""
7272

entrypoint.sh

Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,55 @@
2020
# ${16} - extra-docformatter-options
2121
# ${17} - extra-pydocstyle-options
2222

23-
if [ "$8" = true ] ; then
23+
# Run the autoformatters first.
24+
if [ "$5" = true ] ; then
2425

25-
echo Running: docformatter ${16} $1
26+
echo Running: black --check ${13} $1
2627

27-
docformatter ${16} $1
28+
black --check ${13} $1
2829
exit_code=$?
2930

3031
if [ "$exit_code" = "0" ]; then
31-
echo "docformetter ok"
32+
echo "Black ok"
3233
else
33-
echo "docformatter error"
34-
echo $exit_code
34+
echo "Black error"
35+
exit $exit_code
3536
fi
37+
3638
fi
3739

38-
if [ "$2" = true ] ; then
40+
if [ "$7" = true ] ; then
3941

40-
echo Running: pylint ${10} $1
42+
echo Running: isort ${15} $1 -c --diff
4143

42-
pylint ${10} $1
44+
isort ${15} $1 -c --diff
4345
exit_code=$?
4446

4547
if [ "$exit_code" = "0" ]; then
46-
echo "Pylint ok"
48+
echo "isort ok"
4749
else
48-
echo "Pylint error"
50+
echo "isort error"
4951
exit $exit_code
5052
fi
5153

5254
fi
5355

56+
if [ "$8" = true ] ; then
57+
58+
echo Running: docformatter ${16} $1
59+
60+
docformatter ${16} $1
61+
exit_code=$?
62+
63+
if [ "$exit_code" = "0" ]; then
64+
echo "docformatter ok"
65+
else
66+
echo "docformatter error"
67+
echo $exit_code
68+
fi
69+
fi
5470

71+
# Then check the autoformatter results.
5572
if [ "$3" = true ] ; then
5673

5774
echo Running: pycodestyle ${11} $1
@@ -83,65 +100,51 @@ if [ "$9" = true ] ; then
83100
fi
84101
fi
85102

86-
if [ "$4" = true ] ; then
87-
88-
echo Running: flake8 ${12} $1
89-
90-
flake8 ${12} $1
91-
exit_code=$?
92-
93-
if [ "$exit_code" = "0" ]; then
94-
echo "Flake8 ok"
95-
else
96-
echo "Flake8 error"
97-
exit $exit_code
98-
fi
99-
100-
fi
101-
102-
if [ "$5" = true ] ; then
103+
# Next type check everything.
104+
if [ "$6" = true ] ; then
103105

104-
echo Running: black --check ${13} $1
106+
echo Running: mypy ${14} $1
105107

106-
black --check ${13} $1
108+
mypy ${14} $1
107109
exit_code=$?
108110

109111
if [ "$exit_code" = "0" ]; then
110-
echo "Black ok"
112+
echo "mypy ok"
111113
else
112-
echo "Black error"
114+
echo "mypy error"
113115
exit $exit_code
114116
fi
115117

116118
fi
117119

118-
if [ "$6" = true ] ; then
120+
# Finally, lint the code.
121+
if [ "$2" = true ] ; then
119122

120-
echo Running: mypy ${14} $1
123+
echo Running: pylint ${10} $1
121124

122-
mypy ${14} $1
125+
pylint ${10} $1
123126
exit_code=$?
124127

125128
if [ "$exit_code" = "0" ]; then
126-
echo "mypy ok"
129+
echo "Pylint ok"
127130
else
128-
echo "mypy error"
131+
echo "Pylint error"
129132
exit $exit_code
130133
fi
131134

132135
fi
133136

134-
if [ "$7" = true ] ; then
137+
if [ "$4" = true ] ; then
135138

136-
echo Running: isort ${15} $1 -c --diff
139+
echo Running: flake8 ${12} $1
137140

138-
isort ${15} $1 -c --diff
141+
flake8 ${12} $1
139142
exit_code=$?
140143

141144
if [ "$exit_code" = "0" ]; then
142-
echo "isort ok"
145+
echo "Flake8 ok"
143146
else
144-
echo "isort error"
147+
echo "Flake8 error"
145148
exit $exit_code
146149
fi
147150

0 commit comments

Comments
 (0)