Skip to content

Commit

Permalink
Implement fail_on_error feature for github-pr-review reporter (#21)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
alaegin authored Feb 10, 2021
1 parent d240f7f commit a687a04
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -81,7 +87,7 @@ jobs:
ref: ${{ github.head_ref }}

- name: detekt
uses: alaegin/[email protected]
uses: DominuS-RU/[email protected].1
with:
github_token: ${{ secrets.github_token }}
detekt_config: detekt-config.yml # Change config path
Expand Down
7 changes: 7 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -38,6 +44,7 @@ runs:
- ${{ inputs.reviewdog_reporter }}
- ${{ inputs.detekt_config }}
- ${{ inputs.detekt_excludes }}
- ${{ inputs.fail_on_error }}
branding:
icon: 'check-square'
color: 'orange'
4 changes: 4 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}" \
Expand Down

0 comments on commit a687a04

Please sign in to comment.