Merge pull request #191 from github/disableFlag

Disable flag
This commit is contained in:
Zack Koppert 2020-06-19 10:58:44 -07:00 committed by GitHub
commit 774b8a9139
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 2 deletions

View file

@ -131,7 +131,8 @@ ENV GITHUB_SHA=${GITHUB_SHA} \
ANSIBLE_DIRECTORY=${ANSIBLE_DIRECTORY} \ ANSIBLE_DIRECTORY=${ANSIBLE_DIRECTORY} \
RUN_LOCAL=${RUN_LOCAL} \ RUN_LOCAL=${RUN_LOCAL} \
TEST_CASE_RUN=${TEST_CASE_RUN} \ 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 # # Copy scripts to container #

View file

@ -137,6 +137,7 @@ and won't run anything unexpected.
| **VALIDATE_CSS** | `true` | Flag to enable or disable the linting process of the language. | | **VALIDATE_CSS** | `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). | | **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. | | **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. |
| **DEFAULT_WORKSPACE** | `/tmp/lint` | The location containing files to lint if you are running locally. | | **DEFAULT_WORKSPACE** | `/tmp/lint` | The location containing files to lint if you are running locally. |
### Template rules files ### Template rules files

View file

@ -96,6 +96,7 @@ VALIDATE_GO="${VALIDATE_GO}" # Boolean to validate lang
VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM}" # Boolean to validate language VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM}" # Boolean to validate language
VALIDATE_CSS="${VALIDATE_CSS}" # Boolean to validate language VALIDATE_CSS="${VALIDATE_CSS}" # Boolean to validate language
TEST_CASE_RUN="${TEST_CASE_RUN}" # Boolean to validate only test cases 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 # # Debug Vars #
@ -115,6 +116,7 @@ DEFAULT_ACTIONS_RUNNER_DEBUG='false' # Default value for debugg
RAW_FILE_ARRAY=() # Array of all files that were changed 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 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 TEST_CASE_FOLDER='.automation/test' # Folder for test cases we should always ignore
DEFAULT_DISABLE_ERRORS='false' # Default to enabling errors
########################## ##########################
# Array of changed files # # Array of changed files #
@ -1125,6 +1127,28 @@ GetValidationInfo()
ANSIBLE_DIRECTORY="$TEMP_ANSIBLE_DIRECTORY" ANSIBLE_DIRECTORY="$TEMP_ANSIBLE_DIRECTORY"
fi 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 #
###############################
DISABLE_ERRORS=$(echo "$DISABLE_ERRORS" | awk '{print tolower($0)}')
############################
# Set to false if not true #
############################
if [ "$DISABLE_ERRORS" != "true" ]; then
DISABLE_ERRORS="false"
fi
############################ ############################
# Get the run verbose flag # # Get the run verbose flag #
############################ ############################
@ -1908,10 +1932,16 @@ Footer()
fi fi
done done
##################################
# Exit with 0 if errors disabled #
##################################
if [ "$DISABLE_ERRORS" == "true" ]; then
echo "WARN! Exiting with exit code:[0] as:[DISABLE_ERRORS] was set to:[$DISABLE_ERRORS]"
exit 0
############################### ###############################
# Exit with 1 if errors found # # 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_JSON" -ne 0 ] || \
[ "$ERRORS_FOUND_XML" -ne 0 ] || \ [ "$ERRORS_FOUND_XML" -ne 0 ] || \
[ "$ERRORS_FOUND_MARKDOWN" -ne 0 ] || \ [ "$ERRORS_FOUND_MARKDOWN" -ne 0 ] || \