forked from py-actions/flake8
-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
entrypoint.sh
executable file
·40 lines (32 loc) · 1.25 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
set -eu # Increase bash strictness
if [[ -n "${GITHUB_WORKSPACE}" ]]; then
cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit
fi
export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"
export REVIEWDOG_VERSION=v0.20.2
echo "[action-flake8] Installing reviewdog..."
wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b /tmp "${REVIEWDOG_VERSION}"
if [[ "$(which flake8)" == "" ]]; then
echo "[action-flake8] Installing flake8 package..."
python -m pip install --upgrade flake8
fi
echo "[action-flake8] Flake8 version:"
flake8 --version
echo "[action-flake8] Checking python code with the flake8 linter and reviewdog..."
exit_val="0"
# shellcheck disable=SC2086
flake8 . ${INPUT_FLAKE8_ARGS} 2>&1 | # Removes ansi codes see https://github.com/reviewdog/errorformat/issues/51
/tmp/reviewdog -f="${INPUT_ERROR_FORMAT}" \
-name="${INPUT_TOOL_NAME}" \
-reporter="${INPUT_REPORTER}" \
-filter-mode="${INPUT_FILTER_MODE}" \
-fail-level="${INPUT_FAIL_LEVEL}" \
-fail-on-error="${INPUT_FAIL_ON_ERROR}" \
-level="${INPUT_LEVEL}" \
${INPUT_REVIEWDOG_FLAGS} || exit_val="$?"
echo "[action-flake8] Clean up reviewdog..."
rm /tmp/reviewdog
if [[ "${exit_val}" -ne '0' ]]; then
exit 1
fi