|
1 | 1 | #!/bin/sh |
2 | 2 |
|
3 | | -# Copy the matcher to the host system; otherwise "add-matcher" can't find it. |
4 | | -cp /code/flake8-matcher.json /github/workflow/flake8-matcher.json |
5 | | -echo "::add-matcher::${RUNNER_TEMP}/_github_workflow/flake8-matcher.json" |
| 3 | +# Copy the matcher to a shared volume with the host; otherwise "add-matcher" |
| 4 | +# can't find it. |
| 5 | +cp /code/flake8-matcher.json ${HOME}/ |
| 6 | +echo "::add-matcher::${HOME}/flake8-matcher.json" |
6 | 7 |
|
7 | | -# Run flake8. We add 'error/warning' as GitHub Actions ProblemMatcher needs |
8 | | -# the text 'error/warning' to know how to classify it. |
9 | | -# The weird piping is needed because we want to get the exitcode from flake8, |
10 | | -# but there is no other good universal way of doing so. |
11 | | -# e.g. PIPESTATUS and pipestatus only work in bash/zsh respectively. |
12 | | -echo "Running flake8 on '${INPUT_PATH}' with the following options..." |
| 8 | +# Create the flake8 arguments |
| 9 | +echo "Running flake8 on '${INPUT_PATH}' with the following options:" |
13 | 10 | command_args="" |
14 | | -echo "Ignoring '${INPUT_IGNORE}'" |
15 | | -if [ "x${INPUT_IGNORE}" != "x" ]; then |
| 11 | +echo " - ignoring: '${INPUT_IGNORE}'" |
| 12 | +if [ "x${INPUT_IGNORE}" != "x" ]; then |
16 | 13 | command_args="${command_args} --ignore ${INPUT_IGNORE}" |
17 | 14 | fi |
18 | | -echo "Max line length '${INPUT_MAX_LINE_LENGTH}'" |
19 | | -if [ "x${INPUT_MAX_LINE_LENGTH}" != "x" ]; then |
| 15 | +echo " - nax line length: '${INPUT_MAX_LINE_LENGTH}'" |
| 16 | +if [ "x${INPUT_MAX_LINE_LENGTH}" != "x" ]; then |
20 | 17 | command_args="${command_args} --max-line-length ${INPUT_MAX_LINE_LENGTH}" |
21 | 18 | fi |
22 | | -echo "Resulting CLI options ${command_args}" |
23 | | -exec 5>&1 |
24 | | -res=`{ { flake8 ${command_args} ${INPUT_PATH}; echo $? 1>&4; } | sed -r 's/: ([^W][0-9][0-9][0-9])/: error: \1/;s/: (W[0-9][0-9][0-9])/: warning: \1/' 1>&5; } 4>&1` |
25 | | -if [ "$res" = "0" ]; then |
| 19 | +echo " - path: '${INPUT_PATH}'" |
| 20 | +command_args="${command_args} ${INPUT_PATH}" |
| 21 | +echo "Resulting command: flake8 ${command_args}" |
| 22 | + |
| 23 | +# Run flake8 |
| 24 | +flake8 ${command_args} |
| 25 | +if [ "$?" = "0" ]; then |
26 | 26 | echo "Flake8 found no problems" |
27 | 27 | else |
28 | 28 | echo "Flake8 found one or more problems" |
29 | 29 | fi |
30 | 30 |
|
31 | 31 | # Remove the matcher, so no other jobs hit it. |
32 | | -echo "::remove-matcher owner=flake8::" |
| 32 | +echo "::remove-matcher owner=flake8-error::" |
| 33 | +echo "::remove-matcher owner=flake8-warning::" |
33 | 34 |
|
34 | 35 | # If we are in warn-only mode, return always as if we pass |
35 | 36 | if [ -n "${INPUT_ONLY_WARN}" ]; then |
|
0 commit comments