From 4d5f4b50e9075e55cb13f740d57473878e82c3a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ADl=20Pechorin?= <68131387+berhram@users.noreply.github.com> Date: Mon, 3 Apr 2023 14:47:32 +0300 Subject: [PATCH] Add custom RuleSet support (#38) --- README.md | 4 ++++ action.yml | 5 +++++ entrypoint.sh | 7 ++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fe49c4f..bbcaaf5 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,10 @@ The default value is `ktlint`. Optional. Defines a file glob to identify files to be checked. The default value is an empty string. +### `custom_rule_path` + +Optional. Provides path to JAR file with custom rules. The default value is an empty string. + ## Example usage ```yml diff --git a/action.yml b/action.yml index b656dc5..76bc4f8 100644 --- a/action.yml +++ b/action.yml @@ -52,6 +52,10 @@ inputs: description: Optionally defines a file glob to identify files to be checked required: false default: '' + custom_rule_path: + description: Path to custom rule set JAR + required: false + default: '' runs: using: 'docker' image: 'Dockerfile' @@ -66,6 +70,7 @@ runs: - ${{ inputs.baseline }} - ${{ inputs.ktlint_version }} - ${{ inputs.name }} + - ${{ inputs.custom_rule_path }} branding: icon: 'edit' color: 'blue' diff --git a/entrypoint.sh b/entrypoint.sh index d95ddfd..8e9be04 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -3,6 +3,7 @@ export RELATIVE= export ANDROID= export BASELINE= +export CUSTOM_RULE_PATH= if [ "$INPUT_KTLINT_VERSION" = "latest" ]; then curl -sSL https://api.github.com/repos/pinterest/ktlint/releases/latest --header "authorization: Bearer ${INPUT_GITHUB_TOKEN}" | @@ -30,6 +31,10 @@ if [ "$INPUT_ANDROID" = true ]; then export ANDROID=--android fi +if [ "$INPUT_CUSTOM_RULE_PATH" ]; then + export CUSTOM_RULE_PATH="--ruleset=${INPUT_CUSTOM_RULE_PATH}" +fi + cd "$GITHUB_WORKSPACE" git config --global --add safe.directory $GITHUB_WORKSPACE @@ -38,7 +43,7 @@ export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" echo ktlint version: "$(ktlint --version)" -ktlint --reporter=checkstyle $RELATIVE $ANDROID $BASELINE $INPUT_FILE_GLOB | +ktlint --reporter=checkstyle $CUSTOM_RULE_PATH $RELATIVE $ANDROID $BASELINE $INPUT_FILE_GLOB | reviewdog -f=checkstyle \ -name="${INPUT_NAME}" \ -reporter="${INPUT_REPORTER}" \