Skip to content

Commit

Permalink
Merge pull request #28 from reviewdog/suggestion
Browse files Browse the repository at this point in the history
Support suggestion
  • Loading branch information
haya14busa authored Sep 25, 2021
2 parents 2fb55c8 + ea324dc commit f627b97
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ cd "${GITHUB_WORKSPACE}" || exit

export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"

FILES=$(find "${INPUT_PATH:-'.'}" -not -path "${INPUT_EXCLUDE}" -type f -name "${INPUT_PATTERN:-'*.sh'}")

echo '::group:: Running shellcheck ...'
if [ "${INPUT_REPORTER}" = 'github-pr-review' ]; then
# erroformat: https://git.io/JeGMU
shellcheck -f json ${INPUT_SHELLCHECK_FLAGS:-'--external-sources'} $(find "${INPUT_PATH:-'.'}" -not -path "${INPUT_EXCLUDE}" -type f -name "${INPUT_PATTERN:-'*.sh'}") \
# shellcheck disable=SC2086
shellcheck -f json ${INPUT_SHELLCHECK_FLAGS:-'--external-sources'} ${FILES} \
| jq -r '.[] | "\(.file):\(.line):\(.column):\(.level):\(.message) [SC\(.code)](https://github.com/koalaman/shellcheck/wiki/SC\(.code))"' \
| reviewdog \
-efm="%f:%l:%c:%t%*[^:]:%m" \
Expand All @@ -24,16 +28,36 @@ if [ "${INPUT_REPORTER}" = 'github-pr-review' ]; then
-filter-mode="${INPUT_FILTER_MODE}" \
-fail-on-error="${INPUT_FAIL_ON_ERROR}" \
-level="${INPUT_LEVEL}" \
${INPUT_REVIEWDOG_FLAGS}
${INPUT_REVIEWDOG_FLAGS} || EXIT_CODE=$?
else
# github-pr-check,github-check (GitHub Check API) doesn't support markdown annotation.
shellcheck -f checkstyle ${INPUT_SHELLCHECK_FLAGS:-'--external-sources'} $(find "${INPUT_PATH:-'.'}" -not -path "${INPUT_EXCLUDE}" -type f -name "${INPUT_PATTERN:-'*.sh'}") \
# shellcheck disable=SC2086
shellcheck -f checkstyle ${INPUT_SHELLCHECK_FLAGS:-'--external-sources'} ${FILES} \
| reviewdog \
-f="checkstyle" \
-name="shellcheck" \
-reporter="${INPUT_REPORTER:-github-pr-check}" \
-filter-mode="${INPUT_FILTER_MODE}" \
-fail-on-error="${INPUT_FAIL_ON_ERROR}" \
-level="${INPUT_LEVEL}" \
${INPUT_REVIEWDOG_FLAGS}
${INPUT_REVIEWDOG_FLAGS} || EXIT_CODE=$?
fi
echo '::endgroup::'

echo '::group:: Running shellcheck (suggestion) ...'
# -reporter must be github-pr-review for the suggestion feature.
# shellcheck disable=SC2086
shellcheck -f diff ${FILES} \
| reviewdog \
-name="shellcheck (suggestion)" \
-f=diff \
-f.diff.strip=1 \
-reporter="github-pr-review" \
-filter-mode="${INPUT_FILTER_MODE}" \
-fail-on-error="${INPUT_FAIL_ON_ERROR}" \
${INPUT_REVIEWDOG_FLAGS} || EXIT_CODE_SUGGESTION=$?
echo '::endgroup::'

if [ -n "${EXIT_CODE}" ] || [ -n "${EXIT_CODE_SUGGESTION}" ]; then
exit 1
fi

0 comments on commit f627b97

Please sign in to comment.