From 091455a66daa96c6cd9f8675b119c779c0067759 Mon Sep 17 00:00:00 2001 From: Nayuta Ishii Date: Sun, 22 Dec 2024 15:06:46 +0900 Subject: [PATCH 1/5] Support reviewdog command line argument changes --- README.md | 11 +++++++++++ action.yml | 9 +++++++++ script.sh | 12 +++++++++++- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c5d343f..e2c12f3 100644 --- a/README.md +++ b/README.md @@ -80,12 +80,22 @@ See [reviewdog documentation for filter mode](https://github.com/reviewdog/revie ### `fail_on_error` +**Deprecated**. This option is no longer recommended for use and will be removed in future versions. + Optional. Exit code for reviewdog when errors are found [`true`, `false`]. The default is `false`. See [reviewdog documentation for exit codes](https://github.com/reviewdog/reviewdog/tree/master#exit-codes) for details. +### `fail_level` + +Optional. The level of failures that will cause the action to fail [any,info,warning,error]. + +The default is `error`. + +See [reviewdog documentation for fail level](https://github.com/reviewdog/reviewdog/tree/master?tab=readme-ov-file#fail-level) for details. + ### `flags` Optional. Additional reviewdog flags. Useful for debugging errors, when it can be set to `-tee`. @@ -139,6 +149,7 @@ jobs: reporter: github-pr-review # Change reviewdog reporter filter_mode: nofilter # Check all files, not just the diff fail_on_error: true # Fail action if errors are found + fail_level: any # Fail action if any level of failures are found flags: -tee # Add debug flag to reviewdog trivy_flags: "" # Optional ``` diff --git a/action.yml b/action.yml index 099d9f8..6175fc1 100644 --- a/action.yml +++ b/action.yml @@ -35,12 +35,20 @@ inputs: Default is added. default: 'added' required: false + fail_level: + description: | + The level of failures that will cause the action to fail [any,info,warning,error] + Default is error. + default: '' + required: false fail_on_error: description: | + **Deprecated**. This option is no longer recommended for use and will be removed in future versions. Exit code for reviewdog when errors are found [true,false] Default is `false`. default: 'false' required: false + deprecated: true flags: description: 'Additional reviewdog flags' default: '' @@ -94,6 +102,7 @@ runs: INPUT_TOOL_NAME: ${{ inputs.tool_name }} INPUT_FILTER_MODE: ${{ inputs.filter_mode }} INPUT_FAIL_ON_ERROR: ${{ inputs.fail_on_error }} + INPUT_FAIL_LEVEL: ${{ inputs.fail_level }} INPUT_FLAGS: ${{ inputs.flags }} INPUT_TRIVY_VERSION: ${{ inputs.trivy_version }} INPUT_TRIVY_COMMAND: ${{ inputs.trivy_command }} diff --git a/script.sh b/script.sh index 42813d8..d7bf3e8 100755 --- a/script.sh +++ b/script.sh @@ -99,6 +99,16 @@ echo '::endgroup::' echo '::group:: Running trivy with reviewdog 🐶 ...' export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" + if [[ -n "${INPUT_FAIL_LEVEL}" ]]; then + fail_level="--fail-level=${INPUT_FAIL_LEVEL}" + elif [[ "${INPUT_FAIL_ON_ERROR}" = "true" ]]; then + # For backward compatibility, default to any if fail-on-error is true + # Deprecated + fail_level="--fail-level=any" + else + fail_level="" + fi + # Allow failures now, as reviewdog handles them set +Eeuo pipefail @@ -108,7 +118,7 @@ echo '::group:: Running trivy with reviewdog 🐶 ...' -name="${INPUT_TOOL_NAME}" \ -reporter="${INPUT_REPORTER}" \ -level="${INPUT_LEVEL}" \ - -fail-on-error="${INPUT_FAIL_ON_ERROR}" \ + ${fail_level} \ -filter-mode="${INPUT_FILTER_MODE}" \ ${INPUT_FLAGS} From 7e82a5ed3a08bfaffe6f324586ec81342544b3eb Mon Sep 17 00:00:00 2001 From: Nayuta Ishii Date: Wed, 25 Dec 2024 15:06:23 +0900 Subject: [PATCH 2/5] Update action.yml Co-authored-by: Shoma Okamoto <32533860+shmokmt@users.noreply.github.com> --- action.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 6175fc1..4bf727e 100644 --- a/action.yml +++ b/action.yml @@ -37,9 +37,8 @@ inputs: required: false fail_level: description: | - The level of failures that will cause the action to fail [any,info,warning,error] - Default is error. - default: '' + If set to `none`, always use exit code 0 for reviewdog. Otherwise, exit code 1 for reviewdog if it finds at least 1 issue with severity greater than or equal to the given level. Possible values: [none,any,info,warning,error] Default is `none`. + default: 'none' required: false fail_on_error: description: | From 0b9d098285160c6ba0e20c6900c8e64443998474 Mon Sep 17 00:00:00 2001 From: Nayuta Ishii Date: Wed, 25 Dec 2024 15:06:30 +0900 Subject: [PATCH 3/5] Update action.yml Co-authored-by: Shoma Okamoto <32533860+shmokmt@users.noreply.github.com> --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 4bf727e..062b359 100644 --- a/action.yml +++ b/action.yml @@ -47,7 +47,7 @@ inputs: Default is `false`. default: 'false' required: false - deprecated: true + deprecationMessage: Deprecated, use `fail_level` instead. flags: description: 'Additional reviewdog flags' default: '' From 740dc6a60faf8756df2acaa470b24d249e835016 Mon Sep 17 00:00:00 2001 From: Nayuta Ishii Date: Fri, 10 Jan 2025 17:43:25 +0900 Subject: [PATCH 4/5] Update README.md Co-authored-by: Shoma Okamoto <32533860+shmokmt@users.noreply.github.com> --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e2c12f3..861b902 100644 --- a/README.md +++ b/README.md @@ -90,9 +90,9 @@ See [reviewdog documentation for exit codes](https://github.com/reviewdog/review ### `fail_level` -Optional. The level of failures that will cause the action to fail [any,info,warning,error]. +Optional. If set to none, always use exit code 0 for reviewdog. Otherwise, exit code 1 for reviewdog if it finds at least 1 issue with severity greater than or equal to the given level. Possible values: [none, any, info, warning, error] Default is none. -The default is `error`. +The default is `none`. See [reviewdog documentation for fail level](https://github.com/reviewdog/reviewdog/tree/master?tab=readme-ov-file#fail-level) for details. From 914851fd9965e2768d669b94713548a68b800fb6 Mon Sep 17 00:00:00 2001 From: Nayuta Ishii Date: Fri, 10 Jan 2025 17:45:58 +0900 Subject: [PATCH 5/5] Pass fail flag directory --- script.sh | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/script.sh b/script.sh index d7bf3e8..828d253 100755 --- a/script.sh +++ b/script.sh @@ -99,16 +99,6 @@ echo '::endgroup::' echo '::group:: Running trivy with reviewdog 🐶 ...' export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" - if [[ -n "${INPUT_FAIL_LEVEL}" ]]; then - fail_level="--fail-level=${INPUT_FAIL_LEVEL}" - elif [[ "${INPUT_FAIL_ON_ERROR}" = "true" ]]; then - # For backward compatibility, default to any if fail-on-error is true - # Deprecated - fail_level="--fail-level=any" - else - fail_level="" - fi - # Allow failures now, as reviewdog handles them set +Eeuo pipefail @@ -118,7 +108,8 @@ echo '::group:: Running trivy with reviewdog 🐶 ...' -name="${INPUT_TOOL_NAME}" \ -reporter="${INPUT_REPORTER}" \ -level="${INPUT_LEVEL}" \ - ${fail_level} \ + -fail-on-error="${INPUT_FAIL_ON_ERROR}" \ + -fail-level="${INPUT_FAIL_LEVEL}" \ -filter-mode="${INPUT_FILTER_MODE}" \ ${INPUT_FLAGS}