Adding the verbosity check

This commit is contained in:
Lucas Gravley 2020-04-27 12:46:05 -05:00
parent 27dd6e71a0
commit 2a16b17bda

View file

@ -339,15 +339,20 @@ GetStandardRules()
#### Function LintAnsibleFiles #################################################
LintAnsibleFiles()
{
######################
# Create Print Array #
######################
PRINT_ARRAY=()
################
# print header #
################
echo ""
echo "----------------------------------------------"
echo "----------------------------------------------"
echo "Linting [Ansible] files..."
echo "----------------------------------------------"
echo "----------------------------------------------"
PRINT_ARRAY+=("")
PRINT_ARRAY+=("----------------------------------------------")
PRINT_ARRAY+=("----------------------------------------------")
PRINT_ARRAY+=("Linting [Ansible] files...")
PRINT_ARRAY+=("----------------------------------------------")
PRINT_ARRAY+=("----------------------------------------------")
######################
# Name of the linter #
@ -387,6 +392,11 @@ LintAnsibleFiles()
##########################
LIST_FILES=()
#######################
# Create flag to skip #
#######################
SKIP_FLAG=0
######################################################
# Only go into ansible linter if we have base folder #
######################################################
@ -420,7 +430,24 @@ LintAnsibleFiles()
###################################
# Send message that were skipping #
###################################
echo "- Skipping Ansible lint run as file(s) that were modified were read only..."
#echo "- Skipping Ansible lint run as file(s) that were modified were read only..."
############################
# Create flag to skip loop #
############################
SKIP_FLAG=1
fi
####################################
# Check if we have data to look at #
####################################
if [ $SKIP_FLAG -eq 0 ]; then
for LINE in "${PRINT_ARRAY[@]}"
do
#########################
# Print the header line #
#########################
echo "$LINE"
done
fi
##################
@ -476,13 +503,18 @@ LintAnsibleFiles()
echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully"
fi
done
else
else # No ansible directory found in path
###############################
# Check to see if debug is on #
###############################
if [[ "$ACTIONS_RUNNER_DEBUG" != "false" ]]; then
########################
# No Ansible dir found #
########################
echo "WARN! No Ansible base directory found at:[$ANSIBLE_DIRECTORY]"
echo "skipping ansible lint"
fi
fi
}
################################################################################
#### Function GetGitHubVars ####################################################
@ -1316,15 +1348,20 @@ LintCodebase()
FILE_EXTENSIONS="$1" && shift # Pull the variable and remove from array path (Example: *.json)
FILE_ARRAY=("$@") # Array of files to validate (Example: $FILE_ARRAY_JSON)
######################
# Create Print Array #
######################
PRINT_ARRAY=()
################
# print header #
################
echo ""
echo "----------------------------------------------"
echo "----------------------------------------------"
echo "Linting [$FILE_TYPE] files..."
echo "----------------------------------------------"
echo "----------------------------------------------"
PRINT_ARRAY+=("")
PRINT_ARRAY+=("----------------------------------------------")
PRINT_ARRAY+=("----------------------------------------------")
PRINT_ARRAY+=("Linting [$FILE_TYPE] files...")
PRINT_ARRAY+=("----------------------------------------------")
PRINT_ARRAY+=("----------------------------------------------")
#######################################
# Validate we have jsonlint installed #
@ -1347,21 +1384,29 @@ LintCodebase()
exit 1
else
# Success
if [[ "$ACTIONS_RUNNER_DEBUG" != "false" ]]; then
echo "Successfully found binary in system"
echo "Location:[$VALIDATE_INSTALL_CMD]"
fi
fi
##########################
# Initialize empty Array #
##########################
LIST_FILES=()
################
# Set the flag #
################
SKIP_FLAG=0
############################################################
# Check to see if we need to go through array or all files #
############################################################
if [ ${#FILE_ARRAY[@]} -eq 0 ] && [ "$VALIDATE_ALL_CODEBASE" == "false" ]; then
# No files found in commit and user has asked to not validate code base
echo " - No files found in chageset to lint for language:[$FILE_TYPE]"
SKIP_FLAG=1
# echo " - No files found in chageset to lint for language:[$FILE_TYPE]"
elif [ ${#FILE_ARRAY[@]} -ne 0 ]; then
# We have files added to array of files to check
LIST_FILES=("${FILE_ARRAY[@]}") # Copy the array into list
@ -1373,6 +1418,18 @@ LintCodebase()
LIST_FILES=($(cd "$GITHUB_WORKSPACE" || exit; find . -type f -regex "$FILE_EXTENSIONS" 2>&1))
fi
if [ $SKIP_FLAG -eq 0 ]; then
######################
# Print Header array #
######################
for LINE in "${PRINT_ARRAY[@]}"
do
#########################
# Print the header info #
#########################
echo "$LINE"
done
##################
# Lint the files #
##################
@ -1428,6 +1485,7 @@ LintCodebase()
echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully"
fi
done
fi
}
################################################################################
#### Function TestCodebase #####################################################