From 705c736bd376c8031a02485d020e4eb46e3ca318 Mon Sep 17 00:00:00 2001 From: dvdandroid Date: Fri, 12 Jun 2020 00:27:12 +0200 Subject: [PATCH 1/2] Add Android flag support --- README.md | 5 +++++ action.yml | 5 +++++ entrypoint.sh | 8 +++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dfc02cf..5320d19 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,11 @@ The default is `github-pr-check`. Optional. Fails the current check if any error was found [`true`/`false`] The default value is false. +### `android` + +Optional. Runs KtLint with [Android Kotlin Style Guide](https://android.github.io/kotlin-guides/style.html) [`true`/`false`] +The default value is false. + ## Example usage ```yml diff --git a/action.yml b/action.yml index a790e12..d355b3d 100644 --- a/action.yml +++ b/action.yml @@ -22,6 +22,10 @@ inputs: Default is false. required: false default: 'false' + android: + description: Run KtLint with Android Kotlin Style Guide + required: false + default: 'false' runs: using: 'docker' image: 'Dockerfile' @@ -30,6 +34,7 @@ runs: - ${{ inputs.level }} - ${{ inputs.reporter }} - ${{ inputs.fail_on_error }} + - ${{ inputs.android }} branding: icon: 'edit' color: 'blue' diff --git a/entrypoint.sh b/entrypoint.sh index 4ff5fbb..833e1b3 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,12 +1,18 @@ #!/bin/sh +export ANDROID= + if [ "$INPUT_FAIL_ON_ERROR" = true ] ; then set -o pipefail fi +if [ "$INPUT_ANDROID" = true ] ; then + export ANDROID=--android +fi + cd "$GITHUB_WORKSPACE" export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" -ktlint --reporter=checkstyle \ +ktlint --reporter=checkstyle $ANDROID \ | reviewdog -f=checkstyle -name="ktlint" -reporter="${INPUT_REPORTER}" -level="${INPUT_LEVEL}" From 2c29e309909acbbfb3a185084ffdaedc9e028090 Mon Sep 17 00:00:00 2001 From: dvdandroid Date: Fri, 12 Jun 2020 00:29:56 +0200 Subject: [PATCH 2/2] Add relative flag support --- README.md | 5 +++++ action.yml | 5 +++++ entrypoint.sh | 8 +++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dfc02cf..1176979 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,11 @@ The default is `github-pr-check`. Optional. Fails the current check if any error was found [`true`/`false`] The default value is false. +### `relative` + +Optional. Print files relative to the working directory [`true`/`false`] +The default value is false. + ## Example usage ```yml diff --git a/action.yml b/action.yml index a790e12..12f1637 100644 --- a/action.yml +++ b/action.yml @@ -22,6 +22,10 @@ inputs: Default is false. required: false default: 'false' + relative: + description: Print files relative to the working directory + required: false + default: 'false' runs: using: 'docker' image: 'Dockerfile' @@ -30,6 +34,7 @@ runs: - ${{ inputs.level }} - ${{ inputs.reporter }} - ${{ inputs.fail_on_error }} + - ${{ inputs.relative }} branding: icon: 'edit' color: 'blue' diff --git a/entrypoint.sh b/entrypoint.sh index 4ff5fbb..ffc8ea1 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,12 +1,18 @@ #!/bin/sh +export RELATIVE= + if [ "$INPUT_FAIL_ON_ERROR" = true ] ; then set -o pipefail fi +if [ "$INPUT_RELATIVE" = true ] ; then + export RELATIVE=--relative +fi + cd "$GITHUB_WORKSPACE" export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" -ktlint --reporter=checkstyle \ +ktlint --reporter=checkstyle $RELATIVE \ | reviewdog -f=checkstyle -name="ktlint" -reporter="${INPUT_REPORTER}" -level="${INPUT_LEVEL}"