From ca57ba19ae1e49dd117c911f2f863154aeffafb9 Mon Sep 17 00:00:00 2001 From: Dmitriy Belyaev Date: Fri, 28 Jul 2023 11:33:40 +0200 Subject: [PATCH 1/4] add checkstyle cmd default parameters --- entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 2dc1169..0be22c8 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -17,7 +17,7 @@ exec java -jar /checkstyle.jar -c "${INPUT_CHECKSTYLE_CONFIG}" "${INPUT_WORKDIR} | reviewdog -f=checkstyle \ -name="checkstyle" \ -reporter="${INPUT_REPORTER:-github-pr-check}" \ - -filter-mode="${INPUT_FILTER_MODE}" \ - -fail-on-error="${INPUT_FAIL_ON_ERROR}" \ + -filter-mode="${INPUT_FILTER_MODE:-added}" \ + -fail-on-error="${INPUT_FAIL_ON_ERROR:-false}" \ -level="${INPUT_LEVEL}" \ ${INPUT_REVIEWDOG_FLAGS} From a91e58c6e1fa2dc594058e081a06d1d570bec715 Mon Sep 17 00:00:00 2001 From: Tochiori Yausufmi <32325140+tochi-y@users.noreply.github.com> Date: Sun, 14 Feb 2021 22:48:06 +0900 Subject: [PATCH 2/4] add properties_file option # Conflicts: # action.yml # entrypoint.sh --- README.md | 7 ++++++- action.yml | 4 ++++ entrypoint.sh | 9 ++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f1fc908..3265824 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,6 @@ An example of how the reported Checkstyle violations will look on a pull request ![PR comment with violation](https://user-images.githubusercontent.com/6915328/149333188-4600a75d-5670-4013-9395-d5852e3c7839.png) - ## Usage ```yaml @@ -116,3 +115,9 @@ config for the [Sun coding conventions](https://www.oracle.com/java/technologies Additional reviewdog flags. **`Default:`** `` + +* ### `properties_file` + + Properties file relative to the root directory. + + **`Default:`** `` diff --git a/action.yml b/action.yml index 3b5216f..eabf712 100644 --- a/action.yml +++ b/action.yml @@ -46,6 +46,10 @@ inputs: This field will always try to follow Checkstyle releases as close as possible and will use the latest available by default. If it is not a default preference for your project, please, pin the needed version using this property. default: "10.12.1" + properties_file: + description: | + Properties file relative to the root directory. + default: '' runs: using: "docker" image: "Dockerfile" diff --git a/entrypoint.sh b/entrypoint.sh index 0be22c8..e256281 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,10 +1,17 @@ #!/bin/sh + +echo "Running check" + set -e if [ -n "${GITHUB_WORKSPACE}" ] ; then cd "${GITHUB_WORKSPACE}" || exit fi +if [ -n "${INPUT_PROPERTIES_FILE}" ]; then + OPT_PROPERTIES_FILE="-p ${INPUT_PROPERTIES_FILE}" +fi + export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" printenv @@ -13,7 +20,7 @@ ls # fetch checkstyle of a requested version wget -O - -q "https://github.com/checkstyle/checkstyle/releases/download/checkstyle-${INPUT_CHECKSTYLE_VERSION}/checkstyle-${INPUT_CHECKSTYLE_VERSION}-all.jar" > /checkstyle.jar -exec java -jar /checkstyle.jar -c "${INPUT_CHECKSTYLE_CONFIG}" "${INPUT_WORKDIR}" -f xml \ +exec java -jar /checkstyle.jar "${INPUT_WORKDIR}" -c "${INPUT_CHECKSTYLE_CONFIG}" "${INPUT_WORKDIR}" ${OPT_PROPERTIES_FILE} -f xml \ | reviewdog -f=checkstyle \ -name="checkstyle" \ -reporter="${INPUT_REPORTER:-github-pr-check}" \ From bc38f542b012f032a324d60301edc5083eb56a78 Mon Sep 17 00:00:00 2001 From: Kerwin Bryant Date: Wed, 10 May 2023 15:30:30 +0800 Subject: [PATCH 3/4] update entrypoint.sh to take care of possible network\installation issues and timeouts Add precondition detection: The installation of reviewdog in the container will fail if there is a network timeout. Therefore, if reviewdog does not exist, exit directly to avoid finding the problem after downloading checkstyle, which is a waste of time. Downloading checkstyle theory also takes time. Before time-consuming operation (non-real-time response), output log feedback current process. # Conflicts: # entrypoint.sh --- entrypoint.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index e256281..8abc0b9 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,6 +2,8 @@ echo "Running check" +command -v reviewdog >/dev/null 2>&1 || { echo >&2 "reviewdog: not found"; exit 1; } + set -e if [ -n "${GITHUB_WORKSPACE}" ] ; then @@ -18,6 +20,7 @@ printenv ls # fetch checkstyle of a requested version +echo "Downloading Checkstyle v${INPUT_CHECKSTYLE_VERSION}" wget -O - -q "https://github.com/checkstyle/checkstyle/releases/download/checkstyle-${INPUT_CHECKSTYLE_VERSION}/checkstyle-${INPUT_CHECKSTYLE_VERSION}-all.jar" > /checkstyle.jar exec java -jar /checkstyle.jar "${INPUT_WORKDIR}" -c "${INPUT_CHECKSTYLE_CONFIG}" "${INPUT_WORKDIR}" ${OPT_PROPERTIES_FILE} -f xml \ From c1923ae1ecf9de5e7aac3eaafe991ba7d1ff1e3c Mon Sep 17 00:00:00 2001 From: Dmitriy Belyaev Date: Fri, 28 Jul 2023 13:17:15 +0200 Subject: [PATCH 4/4] clean-ups adjust logs fix copy-paste error --- entrypoint.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 8abc0b9..84b89b6 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,7 +1,5 @@ #!/bin/sh -echo "Running check" - command -v reviewdog >/dev/null 2>&1 || { echo >&2 "reviewdog: not found"; exit 1; } set -e @@ -20,10 +18,11 @@ printenv ls # fetch checkstyle of a requested version -echo "Downloading Checkstyle v${INPUT_CHECKSTYLE_VERSION}" +echo "Download Checkstyle v${INPUT_CHECKSTYLE_VERSION}" wget -O - -q "https://github.com/checkstyle/checkstyle/releases/download/checkstyle-${INPUT_CHECKSTYLE_VERSION}/checkstyle-${INPUT_CHECKSTYLE_VERSION}-all.jar" > /checkstyle.jar -exec java -jar /checkstyle.jar "${INPUT_WORKDIR}" -c "${INPUT_CHECKSTYLE_CONFIG}" "${INPUT_WORKDIR}" ${OPT_PROPERTIES_FILE} -f xml \ +echo "Run Checkstyle check" +exec java -jar /checkstyle.jar "${INPUT_WORKDIR}" -c "${INPUT_CHECKSTYLE_CONFIG}" ${OPT_PROPERTIES_FILE} -f xml \ | reviewdog -f=checkstyle \ -name="checkstyle" \ -reporter="${INPUT_REPORTER:-github-pr-check}" \