forked from jordemort/action-pyright
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.sh
executable file
·69 lines (54 loc) · 1.88 KB
/
script.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bash
set -euo pipefail
BASE_PATH="$(cd "$(dirname "$0")" && pwd)"
cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit 1
export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"
REVIEWDOG_VERSION="0.13.0"
echo "::group::🐶 Installing reviewdog ${REVIEWDOG_VERSION} ... https://github.com/reviewdog/reviewdog"
wget "https://github.com/reviewdog/reviewdog/releases/download/v${REVIEWDOG_VERSION}/reviewdog_${REVIEWDOG_VERSION}_Linux_x86_64.tar.gz"
tar -zxf "reviewdog_${REVIEWDOG_VERSION}_Linux_x86_64.tar.gz"
PATH="$(pwd):$PATH"
echo '::endgroup::'
echo '::group::🐍 Installing pyright ...'
if [ -z "${INPUT_PYRIGHT_VERSION:-}" ]; then
npm install pyright
else
npm install "pyright@${INPUT_PYRIGHT_VERSION}"
fi
echo '::endgroup::'
PYRIGHT_ARGS=(--outputjson)
if [ -n "${INPUT_PYTHON_PLATFORM:-}" ] ; then
PYRIGHT_ARGS+=(--pythonplatform "$INPUT_PYTHON_PLATFORM")
fi
if [ -n "${INPUT_PYTHON_VERSION:-}" ] ; then
PYRIGHT_ARGS+=(--pythonversion "$INPUT_PYTHON_VERSION")
fi
if [ -n "${INPUT_TYPESHED_PATH:-}" ] ; then
PYRIGHT_ARGS+=(--typeshed-path "$INPUT_TYPESHED_PATH")
fi
if [ -n "${INPUT_VENV_PATH:-}" ] ; then
PYRIGHT_ARGS+=(--venv-path "$INPUT_VENV_PATH")
fi
if [ -n "${INPUT_PROJECT:-}" ] ; then
PYRIGHT_ARGS+=(--project "$INPUT_PROJECT")
fi
if [ -n "${INPUT_LIB:-}" ] ; then
if [ "${INPUT_LIB^^}" != "FALSE" ] ; then
PYRIGHT_ARGS+=(--lib)
fi
fi
echo '::group::🔎 Running pyright with reviewdog 🐶 ...'
# shellcheck disable=SC2086
ls -al
"$(npm bin)/pyright" "${PYRIGHT_ARGS[@]}" ${INPUT_PYRIGHT_FLAGS:-} |
python3 "${BASE_PATH}/pyright_to_rdjson.py" |
reviewdog -f=rdjson \
-name="${INPUT_TOOL_NAME}" \
-reporter="${INPUT_REPORTER:-github-pr-review}" \
-filter-mode="${INPUT_FILTER_MODE}" \
-fail-on-error="${INPUT_FAIL_ON_ERROR}" \
-level="${INPUT_LEVEL}" \
${INPUT_REVIEWDOG_FLAGS}
reviewdog_rc=$?
echo '::endgroup::'
exit $reviewdog_rc