From 6b7d4fe797e588fe613adb446ec13cd7c721824d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20N=C3=BCrnberg?= Date: Wed, 30 Oct 2024 08:57:37 +0000 Subject: [PATCH 1/3] add ignore_warnings_on_exit and ignore_errors_on_exit options to avoid a non-zero error code in the presence of warnings or errors respectively --- README.md | 2 ++ action.yml | 8 ++++++++ phpcs-action.bash | 10 ++++++++++ 3 files changed, 20 insertions(+) diff --git a/README.md b/README.md index c04b61c..7bbaf49 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,8 @@ The following configuration options are available: + `severity` - The minimum severity required to display an error or warning + `error_severity` - The minimum severity required to display an error + `warning_severity` - The minimum severity required to display a warning ++ `ignore_warnings_on_exit` - Exit with a zero error code despite the presence of warnings (1 = true, default 0 = false). ++ `ignore_errors_on_exit` - xit with a zero error code despite the presence of errors (1 = true, default 0 = false). + `args` - Extra arguments to pass to the phpcs binary If you require other configurations of PHPMD, please request them in the [Github issue tracker]. diff --git a/action.yml b/action.yml index b7d6489..99638f5 100644 --- a/action.yml +++ b/action.yml @@ -81,6 +81,14 @@ inputs: description: The minimum severity required to display a warning required: false + ignore_warnings_on_exit: + desctiption: Exit with a zero error code despite the presence of warnings (1 = true, default 0 = false). + required: false + + ignore_errors_on_exit: + description: Exit with a zero error code despite the presence of errors (1 = true, default 0 = false). + required: false + args: description: Extra arguments to pass to the phpcs binary required: false diff --git a/phpcs-action.bash b/phpcs-action.bash index 008e132..c22c186 100755 --- a/phpcs-action.bash +++ b/phpcs-action.bash @@ -95,6 +95,16 @@ then command_string+=(--warning-severity="$ACTION_WARNING_SEVERITY") fi +if [ -n "$ACTION_IGNORE_WARNINGS_ON_EXIT" ] +then + command_string+=(--runtime-set ignore_warnings_on_exit "$ACTION_IGNORE_WARNINGS_ON_EXIT") +fi + +if [ -n "$ACTION_IGNORE_ERRORS_ON_EXIT" ] +then + command_string+=(--runtime-set ignore_errors_on_exit "$ACTION_IGNORE_ERRORS_ON_EXIT") +fi + if [ -n "$ACTION_ARGS" ] then command_string+=($ACTION_ARGS) From 4f7a2a14ba3aeb25826988fe25c05c56b0b1a344 Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Mon, 18 Nov 2024 08:56:54 +0000 Subject: [PATCH 2/3] 1) fix a typo in "description"pass 2) allow true/false as well as 1/0 3) pass the env variable from the input --- action.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 99638f5..58ddf08 100644 --- a/action.yml +++ b/action.yml @@ -82,11 +82,11 @@ inputs: required: false ignore_warnings_on_exit: - desctiption: Exit with a zero error code despite the presence of warnings (1 = true, default 0 = false). + description: Exit with a zero error code despite the presence of warnings required: false ignore_errors_on_exit: - description: Exit with a zero error code despite the presence of errors (1 = true, default 0 = false). + description: Exit with a zero error code despite the presence of errors required: false args: @@ -117,6 +117,8 @@ runs: ACTION_SEVERITY: ${{ inputs.severity }} ACTION_ERROR_SEVERITY: ${{ inputs.error_severity }} ACTION_WARNING_SEVERITY: ${{ inputs.warning_severity }} + ACTION_IGNORE_WARNINGS_ON_EXIT: ${{ inputs.ignore_warnings_on_exit }} + ACTION_IGNORE_ERRORS_ON_EXIT: ${{ inputs.ignore_errors_on_exit }} ACTION_ARGS: ${{ inputs.args }} id: phpcs_run From d414a012d1c671de994583ef62d11f852a6ecff0 Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Mon, 18 Nov 2024 08:57:22 +0000 Subject: [PATCH 3/3] normalise true/false values into the phpcs 1/0 expected values --- phpcs-action.bash | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/phpcs-action.bash b/phpcs-action.bash index c22c186..78c63a1 100755 --- a/phpcs-action.bash +++ b/phpcs-action.bash @@ -97,11 +97,21 @@ fi if [ -n "$ACTION_IGNORE_WARNINGS_ON_EXIT" ] then - command_string+=(--runtime-set ignore_warnings_on_exit "$ACTION_IGNORE_WARNINGS_ON_EXIT") + case "$ACTION_IGNORE_WARNINGS_ON_EXIT" in + 'true'|'1') normalised_value=1 ;; + 'false'|'0') normalised_value=0 ;; + *) normalised_value=0 ;; + esac + command_string+=(--runtime-set ignore_warnings_on_exit "$normalised_value") fi if [ -n "$ACTION_IGNORE_ERRORS_ON_EXIT" ] then + case "$ACTION_IGNORE_ERRORS_ON_EXIT" in + 'true'|'1') normalised_value=1 ;; + 'false'|'0') normalised_value=0 ;; + *) normalised_value=0 ;; + esac command_string+=(--runtime-set ignore_errors_on_exit "$ACTION_IGNORE_ERRORS_ON_EXIT") fi