Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fail_level argument and deprecate fail_on_error #23

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
level: error
fail_on_error: true
fail_level: any
- name: check the exit code
if: ${{ !success() }}
run: echo 'The previous step should fail' && exit 1
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This action runs [Linkspector](https://github.com/UmbrellaDocs/linkspector) with
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
fail_on_error: true
fail_level: any
```

## Action inputs
Expand Down Expand Up @@ -58,9 +58,14 @@ For more details, see [Reporters](https://github.com/reviewdog/reviewdog?tab=rea

For more details, please see [Filter mode support table](https://github.com/reviewdog/reviewdog?tab=readme-ov-file#filter-mode-support-table).

### `fail_level`

(Optional) Exit code for reviewdog when errors are found with severity greater than or equal to the given level [none,any,info,warning,error].
Default is `none`.

### `fail_on_error`

(Optional) Exit code for reviewdog when errors are found [true,false]
(Optional, deprecated) Exit code for reviewdog when errors are found [true,false]. This option is ignored if `fail_level` is used.
Default is `false`.

### `reviewdog_flags`
Expand Down
16 changes: 14 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ inputs:
Filtering mode for the reviewdog command [added,diff_context,file,nofilter].
Default is added.
default: 'added'
fail_level:
Exit code for reviewdog when errors are found with severity greater than or equal to the given level [none,any,info,warning,error].
Default is `none`.
Comment on lines +26 to +28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fail_level:
Exit code for reviewdog when errors are found with severity greater than or equal to the given level [none,any,info,warning,error].
Default is `none`.
fail_level:
description: |
Exit code for reviewdog when errors are found with severity greater than or equal to the given level [none,any,info,warning,error].

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes YML error.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gaurav-nelson The fail_level input on line 26 needs to be indented two spaces in your suggested change.

default: ''
fail_on_error:
description: |
Exit code for reviewdog when errors are found [true,false].
(Deprecated) Exit code for reviewdog when errors are found [true,false]. This option is ignored if `fail_level` is used.
Default is `false`.
default: 'false'
reviewdog_flags:
Expand All @@ -45,6 +49,14 @@ runs:
- uses: reviewdog/action-setup@v1
with:
reviewdog_version: v0.20.2
- run: |
if [ -n "${{ inputs.fail_level }}" ]; then
echo "INPUT_FAIL_LEVEL=${{ inputs.fail_level }}" >> $GITHUB_ENV
elif [ "${{ inputs.fail_on_error }}" = 'true' ]; then
echo 'INPUT_FAIL_LEVEL=any' >> $GITHUB_ENV
else
echo 'INPUT_FAIL_LEVEL=none' >> $GITHUB_ENV
fi
bitcoin-tools marked this conversation as resolved.
Show resolved Hide resolved
- run: $GITHUB_ACTION_PATH/script.sh
shell: bash
env:
Expand All @@ -54,7 +66,7 @@ runs:
INPUT_LEVEL: ${{ inputs.level }}
INPUT_REPORTER: ${{ inputs.reporter }}
INPUT_FILTER_MODE: ${{ inputs.filter_mode }}
INPUT_FAIL_ON_ERROR: ${{ inputs.fail_on_error }}
INPUT_FAIL_LEVEL: ${{ env.INPUT_FAIL_LEVEL }}
INPUT_REVIEWDOG_FLAGS: ${{ inputs.reviewdog_flags }}
INPUT_CONFIG_FILE: ${{ inputs.config_file }}
branding:
Expand Down
2 changes: 1 addition & 1 deletion script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ linkspector check -c "${INPUT_CONFIG_FILE}" -j |
-name="${INPUT_TOOL_NAME}" \
-reporter="${INPUT_REPORTER}" \
-filter-mode="${INPUT_FILTER_MODE}" \
-fail-on-error="${INPUT_FAIL_ON_ERROR}" \
-fail-level="${INPUT_FAIL_LEVEL}" \
-level="${INPUT_LEVEL}" \
"${INPUT_REVIEWDOG_FLAGS}"
exit_code=$?
Expand Down