From a687a047dc2fb1ba3f901112c4ccaba64812b319 Mon Sep 17 00:00:00 2001 From: Alexey Egin <10329086+alaegin@users.noreply.github.com> Date: Wed, 10 Feb 2021 22:41:53 +0300 Subject: [PATCH] Implement fail_on_error feature for github-pr-review reporter (#21) * Implement fail_on_error feature for github-pr-review reporter * Enable fail_on_error by default * Provide fail_on_error arg to container * Update action version --- README.md | 22 ++++++++++++++-------- action.yml | 7 +++++++ entrypoint.sh | 4 ++++ 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index bafa3ae..8ce44b1 100644 --- a/README.md +++ b/README.md @@ -24,42 +24,48 @@ This action has several inputs you may be interested in: ### `github_token` -**Required.** Must be in form of github_token: ${{ secrets.github_token }}. +**Required.** Must be in form of `github_token: ${{ secrets.github_token }}`. ### `reviewdog_level` -Optional. Report level for reviewdog's `github-pr-check` reporter [`info`,`warning`,`error`]. +Optional. Report level for reviewdog's `github-pr-check` reporter [`info`,`warning`,`error`]. It's same as `-level` flag of reviewdog. The default is `error`. ### `reviewdog_filter` -Optional. Filter mode for reviewdog. [`added `,`diff_context`,`file`,`nofilter`] -It's same as `-filter-mode` flag of reviewdog. +Optional. Filter mode for reviewdog. [`added `,`diff_context`,`file`,`nofilter`] +It's same as `-filter-mode` flag of reviewdog. The default is `added`. [Read more](https://github.com/reviewdog/reviewdog#filter-mode) ### `reviewdog_reporter` -Optional. Reporter for reviewdog. [`github-pr-check`,`github-pr-review`] +Optional. Reporter for reviewdog. [`github-pr-check`,`github-pr-review`] The default is `github-pr-check`. [Read more](https://github.com/reviewdog/reviewdog#reporters) ### `detekt_config` -Optional. Path to the config file for detekt. The default is `default-detekt-config.yml` +Optional. Path to the config file for detekt. +The default is `default-detekt-config.yml` [Read more](https://detekt.github.io/detekt/cli.html) ### `detekt_excludes` -Optional. Globing patterns describing paths to exclude from the analysis. +Optional. Globing patterns describing paths to exclude from the analysis. The default is `**/build/**,**/.idea/**` [Read more](https://detekt.github.io/detekt/cli.html) +### `fail_on_error` + +Optional. Fails the current check if any error was found [`true`/`false`] +The default value is `true`. + ## Usage Following example runs detekt with @@ -81,7 +87,7 @@ jobs: ref: ${{ github.head_ref }} - name: detekt - uses: alaegin/Detekt-Action@v1.15.0 + uses: DominuS-RU/Detekt-Action@v1.15.0.1 with: github_token: ${{ secrets.github_token }} detekt_config: detekt-config.yml # Change config path diff --git a/action.yml b/action.yml index a240105..f43c962 100644 --- a/action.yml +++ b/action.yml @@ -28,6 +28,12 @@ inputs: description: 'Globing patterns describing paths to exclude from the analysis.' required: false default: '**/build/**,**/.idea/**' + fail_on_error: + description: | + Fails the current check if any error was found [true/false] + Default is false. + required: false + default: 'true' runs: using: 'docker' image: 'Dockerfile' @@ -38,6 +44,7 @@ runs: - ${{ inputs.reviewdog_reporter }} - ${{ inputs.detekt_config }} - ${{ inputs.detekt_excludes }} + - ${{ inputs.fail_on_error }} branding: icon: 'check-square' color: 'orange' diff --git a/entrypoint.sh b/entrypoint.sh index 16b6519..6e386cb 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -3,6 +3,10 @@ # cd or fail cd "$GITHUB_WORKSPACE" || exit 1 +if [ "$INPUT_FAIL_ON_ERROR" = true ] ; then + set -o pipefail +fi + export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" detekt --fail-fast --config "${INPUT_DETEKT_CONFIG}" \