2020-06-29 10:55:59 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
################################################################################
|
|
|
|
########### Super-Linter Validation Functions @admiralawkbar ###################
|
|
|
|
################################################################################
|
|
|
|
################################################################################
|
|
|
|
########################## FUNCTION CALLS BELOW ################################
|
|
|
|
################################################################################
|
|
|
|
################################################################################
|
|
|
|
#### Function GetValidationInfo ################################################
|
2020-07-01 17:40:40 -04:00
|
|
|
function GetValidationInfo() {
|
2020-06-29 10:55:59 -04:00
|
|
|
############################################
|
|
|
|
# Print headers for user provided env vars #
|
|
|
|
############################################
|
|
|
|
echo ""
|
|
|
|
echo "--------------------------------------------"
|
|
|
|
echo "Gathering user validation information..."
|
|
|
|
|
|
|
|
###########################################
|
|
|
|
# Skip validation if were running locally #
|
|
|
|
###########################################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [[ ${RUN_LOCAL} != "true" ]]; then
|
2020-06-29 10:55:59 -04:00
|
|
|
###############################
|
|
|
|
# Convert string to lowercase #
|
|
|
|
###############################
|
2020-07-21 12:09:05 -04:00
|
|
|
VALIDATE_ALL_CODEBASE="${VALIDATE_ALL_CODEBASE,,}"
|
2020-06-29 10:55:59 -04:00
|
|
|
######################################
|
|
|
|
# Validate we should check all files #
|
|
|
|
######################################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [[ ${VALIDATE_ALL_CODEBASE} != "false" ]]; then
|
2020-06-29 10:55:59 -04:00
|
|
|
# Set to true
|
2020-07-21 13:09:07 -04:00
|
|
|
VALIDATE_ALL_CODEBASE="${DEFAULT_VALIDATE_ALL_CODEBASE}"
|
2020-06-29 10:55:59 -04:00
|
|
|
echo "- Validating ALL files in code base..."
|
|
|
|
else
|
|
|
|
# Its false
|
|
|
|
echo "- Only validating [new], or [edited] files in code base..."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
######################
|
|
|
|
# Create Print Array #
|
|
|
|
######################
|
|
|
|
PRINT_ARRAY=()
|
|
|
|
|
|
|
|
################################
|
|
|
|
# Convert strings to lowercase #
|
|
|
|
################################
|
2020-07-21 12:09:05 -04:00
|
|
|
VALIDATE_ANSIBLE="${VALIDATE_ANSIBLE,,}"
|
|
|
|
VALIDATE_ARM="${VALIDATE_ARM,,}"
|
|
|
|
VALIDATE_BASH="${VALIDATE_BASH,,}"
|
|
|
|
VALIDATE_CLOJURE="${VALIDATE_CLOJURE,,}"
|
2020-07-22 15:07:08 -04:00
|
|
|
VALIDATE_CLOUDFORMATION="${VALIDATE_CLOUDFORMATION,,}"
|
2020-07-21 12:09:05 -04:00
|
|
|
VALIDATE_COFFEE="${VALIDATE_COFFEE,,}"
|
|
|
|
VALIDATE_CSS="${VALIDATE_CSS,,}"
|
|
|
|
VALIDATE_DART="${VALIDATE_DART,,}"
|
|
|
|
VALIDATE_DOCKER="${VALIDATE_DOCKER,,}"
|
|
|
|
VALIDATE_EDITORCONFIG="${VALIDATE_EDITORCONFIG,,}"
|
|
|
|
VALIDATE_ENV="${VALIDATE_ENV,,}"
|
|
|
|
VALIDATE_GO="${VALIDATE_GO,,}"
|
|
|
|
VALIDATE_HTML="${VALIDATE_HTML,,}"
|
|
|
|
VALIDATE_JAVASCRIPT_ES="${VALIDATE_JAVASCRIPT_ES,,}"
|
|
|
|
VALIDATE_JAVASCRIPT_STANDARD="${VALIDATE_JAVASCRIPT_STANDARD,,}"
|
|
|
|
VALIDATE_JSON="${VALIDATE_JSON,,}"
|
|
|
|
VALIDATE_JSX="${VALIDATE_JSX,,}"
|
|
|
|
VALIDATE_KOTLIN="${VALIDATE_KOTLIN,,}"
|
|
|
|
VALIDATE_MARKDOWN="${VALIDATE_MARKDOWN,,}"
|
|
|
|
VALIDATE_OPENAPI="${VALIDATE_OPENAPI,,}"
|
|
|
|
VALIDATE_PERL="${VALIDATE_PERL,,}"
|
|
|
|
VALIDATE_PHP="${VALIDATE_PHP,,}"
|
|
|
|
VALIDATE_POWERSHELL="${VALIDATE_POWERSHELL,,}"
|
|
|
|
VALIDATE_PROTOBUF="${VALIDATE_PROTOBUF,,}"
|
|
|
|
VALIDATE_PYTHON="${VALIDATE_PYTHON,,}"
|
|
|
|
VALIDATE_RAKU="${VALIDATE_RAKU,,}"
|
|
|
|
VALIDATE_RUBY="${VALIDATE_RUBY,,}"
|
2020-07-21 14:50:04 -04:00
|
|
|
VALIDATE_STATES="${VALIDATE_STATES,,}"
|
2020-07-21 12:09:05 -04:00
|
|
|
VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM,,}"
|
|
|
|
VALIDATE_TSX="${VALIDATE_TSX,,}"
|
|
|
|
VALIDATE_TYPESCRIPT_ES="${VALIDATE_TYPESCRIPT_ES,,}"
|
|
|
|
VALIDATE_TYPESCRIPT_STANDARD="${VALIDATE_TYPESCRIPT_STANDARD,,}"
|
|
|
|
VALIDATE_YAML="${VALIDATE_YAML,,}"
|
|
|
|
VALIDATE_XML="${VALIDATE_XML,,}"
|
2020-06-29 10:55:59 -04:00
|
|
|
|
|
|
|
################################################
|
|
|
|
# Determine if any linters were explicitly set #
|
|
|
|
################################################
|
|
|
|
ANY_SET="false"
|
2020-07-22 15:26:45 -04:00
|
|
|
# Loop through all languages
|
|
|
|
for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do
|
|
|
|
# build the variable
|
|
|
|
VALIDATE_LANGUAGE="VALIDATE_${LANGUAGE}"
|
|
|
|
# Check to see if the variable was set
|
|
|
|
if [ -n ${!VALIDATE_LANGUAGE} ]; then
|
|
|
|
# It was set, need to set flag
|
|
|
|
ANY_SET="true"
|
2020-06-29 10:55:59 -04:00
|
|
|
fi
|
2020-07-22 15:26:45 -04:00
|
|
|
done
|
2020-06-29 10:55:59 -04:00
|
|
|
|
|
|
|
|
|
|
|
###################################################
|
2020-07-22 15:26:45 -04:00
|
|
|
# Validate if we should check individual lanuages #
|
2020-06-29 10:55:59 -04:00
|
|
|
###################################################
|
2020-07-22 15:26:45 -04:00
|
|
|
# Loop through all languages
|
|
|
|
for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do
|
|
|
|
# build the variable
|
|
|
|
VALIDATE_LANGUAGE="VALIDATE_${LANGUAGE}"
|
|
|
|
# Check if ANY_SET was set
|
|
|
|
if [[ ${ANY_SET} == "true" ]]; then
|
|
|
|
# Check to see if the variable was set
|
|
|
|
if [ -z ${!VALIDATE_LANGUAGE} ]; then
|
|
|
|
# Flag was not set, default to false
|
|
|
|
eval "${VALIDATE_LANGUAGE}='false'"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
# No linter flags were set - default all to true
|
|
|
|
eval "${VALIDATE_LANGUAGE}='true'"
|
2020-07-04 18:14:27 -04:00
|
|
|
fi
|
2020-07-22 15:26:45 -04:00
|
|
|
done
|
2020-06-21 03:16:45 -04:00
|
|
|
|
2020-06-29 10:55:59 -04:00
|
|
|
#######################################
|
|
|
|
# Print which linters we are enabling #
|
|
|
|
#######################################
|
2020-07-22 15:26:45 -04:00
|
|
|
# Loop through all languages
|
|
|
|
for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do
|
|
|
|
# build the variable
|
|
|
|
VALIDATE_LANGUAGE="VALIDATE_${LANGUAGE}"
|
|
|
|
if [[ ${!VALIDATE_LANGUAGE} == "true" ]]; then
|
|
|
|
# We need to validate
|
|
|
|
PRINT_ARRAY+=("- Validating [$LANGUAGE] files in code base...")
|
|
|
|
else
|
|
|
|
# We are skipping the language
|
|
|
|
PRINT_ARRAY+=("- Excluding [$LANGUAGE] files in code base...")
|
|
|
|
fi
|
|
|
|
done
|
2020-06-29 10:55:59 -04:00
|
|
|
|
|
|
|
##############################
|
|
|
|
# Validate Ansible Directory #
|
|
|
|
##############################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ -z "${ANSIBLE_DIRECTORY}" ]; then
|
2020-06-29 10:55:59 -04:00
|
|
|
# No Value, need to default
|
2020-07-21 13:09:07 -04:00
|
|
|
ANSIBLE_DIRECTORY="${DEFAULT_ANSIBLE_DIRECTORY}"
|
2020-06-29 10:55:59 -04:00
|
|
|
else
|
|
|
|
# Check if first char is '/'
|
|
|
|
if [[ ${ANSIBLE_DIRECTORY:0:1} == "/" ]]; then
|
|
|
|
# Remove first char
|
|
|
|
ANSIBLE_DIRECTORY="${ANSIBLE_DIRECTORY:1}"
|
|
|
|
fi
|
|
|
|
# Need to give it full path
|
2020-07-21 13:09:07 -04:00
|
|
|
TEMP_ANSIBLE_DIRECTORY="${GITHUB_WORKSPACE}/${ANSIBLE_DIRECTORY}"
|
2020-06-29 10:55:59 -04:00
|
|
|
# Set the value
|
2020-07-21 13:09:07 -04:00
|
|
|
ANSIBLE_DIRECTORY="${TEMP_ANSIBLE_DIRECTORY}"
|
2020-06-29 10:55:59 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
###############################
|
|
|
|
# Get the disable errors flag #
|
|
|
|
###############################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ -z "${DISABLE_ERRORS}" ]; then
|
2020-06-29 10:55:59 -04:00
|
|
|
##################################
|
|
|
|
# No flag passed, set to default #
|
|
|
|
##################################
|
2020-07-21 13:09:07 -04:00
|
|
|
DISABLE_ERRORS="${DEFAULT_DISABLE_ERRORS}"
|
2020-06-29 10:55:59 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
###############################
|
|
|
|
# Convert string to lowercase #
|
|
|
|
###############################
|
2020-07-21 12:09:05 -04:00
|
|
|
DISABLE_ERRORS="${DISABLE_ERRORS,,}"
|
2020-06-29 10:55:59 -04:00
|
|
|
|
|
|
|
############################
|
|
|
|
# Set to false if not true #
|
|
|
|
############################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ "${DISABLE_ERRORS}" != "true" ]; then
|
2020-06-29 10:55:59 -04:00
|
|
|
DISABLE_ERRORS="false"
|
|
|
|
fi
|
|
|
|
|
|
|
|
############################
|
|
|
|
# Get the run verbose flag #
|
|
|
|
############################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ -z "${ACTIONS_RUNNER_DEBUG}" ]; then
|
2020-06-29 10:55:59 -04:00
|
|
|
##################################
|
|
|
|
# No flag passed, set to default #
|
|
|
|
##################################
|
2020-07-21 13:09:07 -04:00
|
|
|
ACTIONS_RUNNER_DEBUG="${DEFAULT_ACTIONS_RUNNER_DEBUG}"
|
2020-06-29 10:55:59 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
###############################
|
|
|
|
# Convert string to lowercase #
|
|
|
|
###############################
|
2020-07-21 12:09:05 -04:00
|
|
|
ACTIONS_RUNNER_DEBUG="${ACTIONS_RUNNER_DEBUG,,}"
|
2020-06-29 10:55:59 -04:00
|
|
|
|
|
|
|
############################
|
|
|
|
# Set to true if not false #
|
|
|
|
############################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ "${ACTIONS_RUNNER_DEBUG}" != "false" ]; then
|
2020-06-29 10:55:59 -04:00
|
|
|
ACTIONS_RUNNER_DEBUG="true"
|
|
|
|
fi
|
|
|
|
|
|
|
|
###################
|
|
|
|
# Debug on runner #
|
|
|
|
###################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then
|
2020-06-29 10:55:59 -04:00
|
|
|
###########################
|
|
|
|
# Print the validate info #
|
|
|
|
###########################
|
2020-07-01 17:40:40 -04:00
|
|
|
for LINE in "${PRINT_ARRAY[@]}"; do
|
2020-07-21 13:09:07 -04:00
|
|
|
echo "${LINE}"
|
2020-06-29 10:55:59 -04:00
|
|
|
done
|
|
|
|
|
|
|
|
echo "--- DEBUG INFO ---"
|
|
|
|
echo "---------------------------------------------"
|
|
|
|
RUNNER=$(whoami)
|
2020-07-21 13:09:07 -04:00
|
|
|
echo "Runner:[${RUNNER}]"
|
2020-06-29 10:55:59 -04:00
|
|
|
echo "ENV:"
|
|
|
|
printenv
|
|
|
|
echo "---------------------------------------------"
|
|
|
|
fi
|
|
|
|
}
|