From 976bc9c852a50d4d24074950f68a810ed6774433 Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Thu, 18 Jun 2020 15:12:41 -0400 Subject: [PATCH 01/10] Add environment variable for disabling errors --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 89eab906..bd8bce43 100644 --- a/Dockerfile +++ b/Dockerfile @@ -125,7 +125,8 @@ ENV GITHUB_SHA=${GITHUB_SHA} \ ANSIBLE_DIRECTORY=${ANSIBLE_DIRECTORY} \ RUN_LOCAL=${RUN_LOCAL} \ TEST_CASE_RUN=${TEST_CASE_RUN} \ - ACTIONS_RUNNER_DEBUG=${ACTIONS_RUNNER_DEBUG} + ACTIONS_RUNNER_DEBUG=${ACTIONS_RUNNER_DEBUG} \ + DISABLE_ERRORS=${DISABLE_ERRORS} ############################# # Copy scripts to container # From 4d2b216eaf25247d5fd6500feb8d3af1e42e434c Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Thu, 18 Jun 2020 15:17:59 -0400 Subject: [PATCH 02/10] Add variable and default --- lib/linter.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/linter.sh b/lib/linter.sh index 4ea4461b..92897eec 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -89,6 +89,7 @@ VALIDATE_DOCKER="${VALIDATE_DOCKER}" # Boolean to validate lang VALIDATE_GO="${VALIDATE_GO}" # Boolean to validate language VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM}" # Boolean to validate language TEST_CASE_RUN="${TEST_CASE_RUN}" # Boolean to validate only test cases +DISABLE_ERRORS="${DISABLE_ERRORS}" # Boolean to enable warning-only output without throwing errors ############## # Debug Vars # @@ -108,6 +109,7 @@ DEFAULT_ACTIONS_RUNNER_DEBUG='false' # Default value for debugg RAW_FILE_ARRAY=() # Array of all files that were changed READ_ONLY_CHANGE_FLAG=0 # Flag set to 1 if files changed are not txt or md TEST_CASE_FOLDER='.automation/test' # Folder for test cases we should always ignore +DEFULAT_DISABLE_ERRORS='false' # Default to enabling errors ########################## # Array of changed files # From 2338c2c98ed3e43c9affd508bd1314600993f262 Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Thu, 18 Jun 2020 15:22:13 -0400 Subject: [PATCH 03/10] Parse DEFAULT_ERRORS variable --- lib/linter.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/linter.sh b/lib/linter.sh index 92897eec..4188f6af 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1096,6 +1096,30 @@ GetValidationInfo() # Set the value ANSIBLE_DIRECTORY="$TEMP_ANSIBLE_DIRECTORY" fi + + ############################### + # Get the disable errors flag # + ############################### + if [ -z "$DISABLE_ERRORS" ]; then + ################################## + # No flag passed, set to default # + ################################## + DISABLE_ERRORS="$DEFAULT_DISABLE_ERRORS" + fi + + ############################### + # Convert string to lowercase # + ############################### + DSIABLE_ERRORS=$(echo "$DISABLE_ERRORS" | awk '{print tolower($0)}') + + ############################ + # Set to false if not true # + ############################ + if [ "$DISABLE_ERRORS" != "true" ]; then + ACTIONS_RUNNER_DEBUG="false" + fi + + ############################ # Get the run verbose flag # From ff19ebe77d28621cc482b3a028da6d739d384dcc Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Thu, 18 Jun 2020 15:24:47 -0400 Subject: [PATCH 04/10] exit early if errors are disabled --- lib/linter.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/linter.sh b/lib/linter.sh index 4188f6af..f72f3e03 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1895,6 +1895,14 @@ Footer() fi done + ################################## + # Exit with 0 if errors disabled # + ################################## + + if ${ERRORS_DISABLED} then + exit 0 + fi + ############################### # Exit with 1 if errors found # ############################### From cf8b1eddfe41db50e98843e07c71796b3af5940b Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Thu, 18 Jun 2020 15:25:54 -0400 Subject: [PATCH 05/10] Update lib/linter.sh --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index f72f3e03..021fa960 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1116,7 +1116,7 @@ GetValidationInfo() # Set to false if not true # ############################ if [ "$DISABLE_ERRORS" != "true" ]; then - ACTIONS_RUNNER_DEBUG="false" + DISABLE_ERRORS="false" fi From 49c6b4fa7d7be72438a9a6c6cc437a2b542a1e28 Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Thu, 18 Jun 2020 15:26:21 -0400 Subject: [PATCH 06/10] Update lib/linter.sh --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index 021fa960..5c81665f 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1899,7 +1899,7 @@ Footer() # Exit with 0 if errors disabled # ################################## - if ${ERRORS_DISABLED} then + if ${DISABLE_ERRORS} then exit 0 fi From 95af99a134d4cf50be67f4f856e14f7a32506e61 Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Thu, 18 Jun 2020 16:47:05 -0400 Subject: [PATCH 07/10] Update lib/linter.sh --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index 5c81665f..719aa9e0 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -109,7 +109,7 @@ DEFAULT_ACTIONS_RUNNER_DEBUG='false' # Default value for debugg RAW_FILE_ARRAY=() # Array of all files that were changed READ_ONLY_CHANGE_FLAG=0 # Flag set to 1 if files changed are not txt or md TEST_CASE_FOLDER='.automation/test' # Folder for test cases we should always ignore -DEFULAT_DISABLE_ERRORS='false' # Default to enabling errors +DEFAULT_DISABLE_ERRORS='false' # Default to enabling errors ########################## # Array of changed files # From dc881c2d1ab3196175244032eceb3a92d24d535c Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Thu, 18 Jun 2020 16:47:52 -0400 Subject: [PATCH 08/10] Update lib/linter.sh --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index 719aa9e0..6fa50fae 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1110,7 +1110,7 @@ GetValidationInfo() ############################### # Convert string to lowercase # ############################### - DSIABLE_ERRORS=$(echo "$DISABLE_ERRORS" | awk '{print tolower($0)}') + DISABLE_ERRORS=$(echo "$DISABLE_ERRORS" | awk '{print tolower($0)}') ############################ # Set to false if not true # From 2f7f03efe36ee55c6cb58b2a33554f70b2affbf4 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Fri, 19 Jun 2020 12:39:08 -0500 Subject: [PATCH 09/10] fixing logic --- lib/linter.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 6fa50fae..01e85333 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1096,7 +1096,7 @@ GetValidationInfo() # Set the value ANSIBLE_DIRECTORY="$TEMP_ANSIBLE_DIRECTORY" fi - + ############################### # Get the disable errors flag # ############################### @@ -1119,8 +1119,6 @@ GetValidationInfo() DISABLE_ERRORS="false" fi - - ############################ # Get the run verbose flag # ############################ @@ -1898,15 +1896,13 @@ Footer() ################################## # Exit with 0 if errors disabled # ################################## - - if ${DISABLE_ERRORS} then + if [ "$DISABLE_ERRORS" == "true" ]; then + echo "WARN! Exiting with exit code:[0] as:[DISABLE_ERRORS] was set to:[$DISABLE_ERRORS]" exit 0 - fi - ############################### # Exit with 1 if errors found # ############################### - if [ "$ERRORS_FOUND_YML" -ne 0 ] || \ + elif [ "$ERRORS_FOUND_YML" -ne 0 ] || \ [ "$ERRORS_FOUND_JSON" -ne 0 ] || \ [ "$ERRORS_FOUND_XML" -ne 0 ] || \ [ "$ERRORS_FOUND_MARKDOWN" -ne 0 ] || \ From d5fa264b0def91474e83749540f38b97e3a0f3a2 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Fri, 19 Jun 2020 12:40:53 -0500 Subject: [PATCH 10/10] Adding flag to readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 2fd43bf2..5dff4639 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,7 @@ and won't run anything unexpected. | **VALIDATE_TERRAFORM** | `true` | Flag to enable or disable the linting process of the language. | | **ANSIBLE_DIRECTORY** | `/ansible` | Flag to set the root directory for Ansible file location(s). | | **ACTIONS_RUNNER_DEBUG** | `false` | Flag to enable additional information about the linter, versions, and additional output. | +| **DISABLE_ERRORS** | `false` | Flag to have the linter complete with exit code 0 even if errors were detected. | ### Template rules files You can use the **GitHub** **Super-Linter** *with* or *without* your own personal rules sets. This allows for greater flexibility for each individual code base. The Template rules all try to follow the standards we believe should be enabled at the basic level.