File tree Expand file tree Collapse file tree 6 files changed +102
-4
lines changed
Expand file tree Collapse file tree 6 files changed +102
-4
lines changed Original file line number Diff line number Diff line change 5858 with :
5959 path : example_valid_py39
6060
61+ run_action_with_plugin :
62+ name : Test run action (plugins)
63+ runs-on : ubuntu-latest
64+ steps :
65+ - uses : actions/checkout@v2
66+ - uses : ./
67+ with :
68+ plugins : flake8-bugbear
69+ path : example_bugbear
70+ only_warn : 1
71+
72+ run_action_with_classes :
73+ name : Test run action (classes)
74+ runs-on : ubuntu-latest
75+ steps :
76+ - uses : actions/checkout@v2
77+ - uses : ./
78+ with :
79+ plugins : flake8-bugbear
80+ path : example_bugbear
81+ warning_classes : E,F
82+ error_classes : W,B
83+ only_warn : 1
84+
6185 codespell :
6286 name : Check for spelling errors
6387 runs-on : ubuntu-latest
Original file line number Diff line number Diff line change 1515- uses: TrueBrain/actions-flake8@v2
1616```
1717
18- By default it uses the default Python version as installed on the GitHub Runner.
18+ By default, it uses the default Python version as installed on the GitHub Runner.
1919
2020### Different Python version
2121
@@ -115,3 +115,45 @@ steps:
115115 with:
116116 only_warn: 1
117117```
118+
119+ ### Parameter: plugins
120+
121+ List of plugins to install before running, This is passed directly to ` pip install ` .
122+
123+ This parameter is optional; setting this to any value will enable it.
124+
125+ ```
126+ steps:
127+ - uses: actions/checkout@v2
128+ - uses: TrueBrain/actions-flake8@v2
129+ with:
130+ plugins: flake8-bugbear cohesion==0.9.1
131+ ```
132+
133+ ### Parameter: error_classes
134+
135+ List of flake8 [ error classes] ( https://flake8.pycqa.org/en/latest/glossary.html#term-error-class ) to classify as Error.
136+
137+ This parameter is optional; by default ` E ` and ` F ` classes will be considered errors.
138+
139+ ```
140+ steps:
141+ - uses: actions/checkout@v2
142+ - uses: TrueBrain/actions-flake8@v2
143+ with:
144+ error_classes: E,H
145+ ```
146+
147+ ### Parameter: warning_classes
148+
149+ List of flake8 [ error classes] ( https://flake8.pycqa.org/en/latest/glossary.html#term-error-class ) to classify as Warning.
150+
151+ This parameter is optional; by default all classes not contained in ` error_classes ` will be considered a warning.
152+
153+ ```
154+ steps:
155+ - uses: actions/checkout@v2
156+ - uses: TrueBrain/actions-flake8@v2
157+ with:
158+ warning_classes: W,B,D
159+ ```
Original file line number Diff line number Diff line change @@ -22,6 +22,18 @@ inputs:
2222 description : ' What flake8 version to use, if none is installed (default is latest)'
2323 required : false
2424 default : ' '
25+ plugins :
26+ description : ' List of plugins to install before running, this is passed directly to pip install'
27+ required : false
28+ default : ' '
29+ error_classes :
30+ description : ' List of flake8 error classes to classify as Error'
31+ required : false
32+ default : ' E,F'
33+ warning_classes :
34+ description : ' List of flake8 error classes to classify as Warning'
35+ required : false
36+ default : ' '
2537runs :
2638 using : ' composite'
2739 steps :
3143 else
3244 flake8_version="==${{ inputs.flake8_version }}"
3345 fi
34- pip install flake8${flake8_version}
46+ plugins=
47+ if [ -n "${{ inputs.plugins }}" ]; then
48+ plugins="${{ inputs.plugins }}"
49+ fi
50+ pip install flake8${flake8_version} ${plugins}
3551 shell: bash
3652 - run : ${{ github.action_path }}/action/entrypoint.sh
3753 shell : bash
4157 INPUT_MAX_LINE_LENGTH : ${{ inputs.max_line_length }}
4258 INPUT_ONLY_WARN : ${{ inputs.only_warn }}
4359 INPUT_FLAKE8_VERSION : ${{ inputs.flake8_version }}
60+ INPUT_PLUGINS : ${{ inputs.plugins }}
61+ INPUT_ERROR_CLASSES : ${{ inputs.error_classes }}
62+ INPUT_WARNING_CLASSES : ${{ inputs.warning_classes }}
4463branding :
4564 icon : ' code'
4665 color : ' blue'
Original file line number Diff line number Diff line change 22
33# Enable the matcher.
44ACTION_FOLDER=$( dirname ${0} )
5+ echo " - error_classes: '${INPUT_ERROR_CLASSES} '"
6+ error_classes=$( echo " ${INPUT_ERROR_CLASSES} " | sed " s/,//g" )
7+ sed -i " s/{{error_classes}}/${error_classes} /g" " ${ACTION_FOLDER} /flake8-matcher.json"
8+
9+ echo " - warning_classes: '${INPUT_WARNING_CLASSES} '"
10+ if [ -n " ${INPUT_WARNING_CLASSES} " ]; then
11+ warning_classes=$( echo " ${INPUT_WARNING_CLASSES} " | sed " s/,//g" )
12+ sed -i " s/{{warning_classes}}/${warning_classes} /g" " ${ACTION_FOLDER} /flake8-matcher.json"
13+ else
14+ sed -i " s/{{warning_classes}}/^${error_classes} /g" " ${ACTION_FOLDER} /flake8-matcher.json"
15+ fi
516echo " ::add-matcher::${ACTION_FOLDER} /flake8-matcher.json"
617
718# Create the flake8 arguments.
Original file line number Diff line number Diff line change 55 "severity" : " error" ,
66 "pattern" : [
77 {
8- "regexp" : " ^([^:]*):(\\ d+):(\\ d+): ([EF ]\\ d\\ d\\ d) (.*)$" ,
8+ "regexp" : " ^([^:]*):(\\ d+):(\\ d+): ([{{error_classes}} ]\\ d\\ d\\ d) (.*)$" ,
99 "file" : 1 ,
1010 "line" : 2 ,
1111 "column" : 3 ,
1919 "severity" : " warning" ,
2020 "pattern" : [
2121 {
22- "regexp" : " ^([^:]*):(\\ d+):(\\ d+): ([W ]\\ d\\ d\\ d) (.*)$" ,
22+ "regexp" : " ^([^:]*):(\\ d+):(\\ d+): ([{{warning_classes}} ]\\ d\\ d\\ d) (.*)$" ,
2323 "file" : 1 ,
2424 "line" : 2 ,
2525 "column" : 3 ,
Original file line number Diff line number Diff line change 1+ def good_buggy_code (mutable = []):
2+ pass
You can’t perform that action at this time.
0 commit comments