Skip to content

Commit c120815

Browse files
authored
Feature: setting to give flake8 extra arguments (#41)
Alternatively, we add support for each argument; but with all the plugins this becomes an impossible goal to reach. So instead, allow users to customize this action how-ever they like. Arguments that are more commonly used will still get their own setting.
1 parent c2deca2 commit c120815

File tree

5 files changed

+42
-1
lines changed

5 files changed

+42
-1
lines changed

.github/workflows/testing.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ jobs:
8282
error_classes: W,B
8383
only_warn: 1
8484

85+
run_action_with_extra_arguments:
86+
name: Test run action (extra arguments)
87+
runs-on: ubuntu-latest
88+
steps:
89+
- uses: actions/checkout@v2
90+
- uses: ./
91+
with:
92+
path: example_length
93+
extra_arguments: "--max-line-length 90"
94+
8595
codespell:
8696
name: Check for spelling errors
8797
runs-on: ubuntu-latest

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ steps:
9999
max_line_length: 90
100100
```
101101

102-
103102
### Parameter: only_warn
104103

105104
Only warn about problems.
@@ -157,3 +156,18 @@ steps:
157156
with:
158157
warning_classes: W,B,D
159158
```
159+
160+
### Parameter: extra_arguments
161+
162+
Extra arguments to give to flake8.
163+
Useful when you need to give an argument this action otherwise doesn't supply (like `--max-complexity`, `--hang-closing`, ...).
164+
165+
This parameter is optional; by default it is empty.
166+
167+
```
168+
steps:
169+
- uses: actions/checkout@v2
170+
- uses: TrueBrain/actions-flake8@v2
171+
with:
172+
extra_arguments: "--hang-closing"
173+
```

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ inputs:
3434
description: 'List of flake8 error classes to classify as Warning'
3535
required: false
3636
default: ''
37+
extra_arguments:
38+
description: 'Extra arguments given to flake8'
39+
required: false
40+
default: ''
3741
runs:
3842
using: 'composite'
3943
steps:
@@ -60,6 +64,7 @@ runs:
6064
INPUT_PLUGINS: ${{ inputs.plugins }}
6165
INPUT_ERROR_CLASSES: ${{ inputs.error_classes }}
6266
INPUT_WARNING_CLASSES: ${{ inputs.warning_classes }}
67+
INPUT_EXTRA_ARGUMENTS: ${{ inputs.extra_arguments }}
6368
branding:
6469
icon: 'code'
6570
color: 'blue'

action/entrypoint.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,27 @@ echo "::add-matcher::${ACTION_FOLDER}/flake8-matcher.json"
1717

1818
# Create the flake8 arguments.
1919
echo "Running flake8 on '${INPUT_PATH}' with the following options:"
20+
2021
command_args=""
22+
2123
echo " - ignoring: '${INPUT_IGNORE}'"
2224
if [ "x${INPUT_IGNORE}" != "x" ]; then
2325
command_args="${command_args} --ignore ${INPUT_IGNORE}"
2426
fi
27+
2528
echo " - max line length: '${INPUT_MAX_LINE_LENGTH}'"
2629
if [ "x${INPUT_MAX_LINE_LENGTH}" != "x" ]; then
2730
command_args="${command_args} --max-line-length ${INPUT_MAX_LINE_LENGTH}"
2831
fi
32+
2933
echo " - path: '${INPUT_PATH}'"
3034
command_args="${command_args} ${INPUT_PATH}"
35+
36+
echo " - extra arguments: '${INPUT_EXTRA_ARGUMENTS}'"
37+
if [ "x${INPUT_EXTRA_ARGUMENTS}" != "x" ]; then
38+
command_args="${command_args} ${INPUT_EXTRA_ARGUMENTS}"
39+
fi
40+
3141
echo "Resulting command: flake8 ${command_args}"
3242

3343
# Run flake8.

example_length/example.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def line_that_will_be_way_too_long_but_not_long_enough_to_trigger_with_the_set_length():
2+
pass

0 commit comments

Comments
 (0)