-
Notifications
You must be signed in to change notification settings - Fork 5
/
script.sh
executable file
·80 lines (58 loc) · 2.03 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
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env bash
set -euo pipefail
BASE_PATH="$(cd "$(dirname "$0")" && pwd)"
INPUT_PYRIGHT_VERSION=${INPUT_PYRIGHT_VERSION:-latest}
cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit 1
TEMP_PATH="$(mktemp -d)"
PATH="${TEMP_PATH}:$PATH"
export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"
echo '::group::🐶 Installing reviewdog ... https://github.com/reviewdog/reviewdog'
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b "${TEMP_PATH}" "${REVIEWDOG_VERSION}" 2>&1
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
cleanup() {
if [ -n "${RDTMP:-}" ] && [ -d "${RDTMP:-}" ]; then
rm -rf "$RDTMP"
fi
}
echo '::group::🔎 Running pyright with reviewdog 🐶 ...'
RDTMP=$(mktemp -d)
trap cleanup EXIT
set -x
# shellcheck disable=SC2086
npm exec --yes -- "pyright@${INPUT_PYRIGHT_VERSION}" "${PYRIGHT_ARGS[@]}" ${INPUT_PYRIGHT_FLAGS:-} >"$RDTMP/pyright.json" || true
python3 "${BASE_PATH}/pyright_to_rdjson/pyright_to_rdjson.py" <"$RDTMP/pyright.json" >"$RDTMP/rdjson.json"
set +e
# shellcheck disable=SC2086
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} < "$RDTMP/rdjson.json"
reviewdog_rc=$?
set +x
echo "reviewdog exited with exit status $reviewdog_rc"
echo '::endgroup::'
exit $reviewdog_rc