Merge pull request #346 from nemchik/color

Add colors to output
This commit is contained in:
Thomas Hughes 2020-07-01 16:30:24 -05:00 committed by GitHub
commit 9d5d792af8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 157 additions and 128 deletions

View file

@ -54,8 +54,8 @@ ValidateInput()
# Validate GITHUB_WORKSPACE # # Validate GITHUB_WORKSPACE #
############################ ############################
if [ -z "$GITHUB_WORKSPACE" ]; then if [ -z "$GITHUB_WORKSPACE" ]; then
echo "ERROR! Failed to get [GITHUB_WORKSPACE]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_WORKSPACE]!${NC}"
echo "ERROR:[$GITHUB_WORKSPACE]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_WORKSPACE]${NC}"
exit 1 exit 1
else else
echo "Successfully found:[GITHUB_WORKSPACE], value:[$GITHUB_WORKSPACE]" echo "Successfully found:[GITHUB_WORKSPACE], value:[$GITHUB_WORKSPACE]"
@ -66,15 +66,15 @@ ValidateInput()
####################### #######################
if [ -z "$IMAGE_REPO" ]; then if [ -z "$IMAGE_REPO" ]; then
# No repo was pulled # No repo was pulled
echo "ERROR! Failed to get [IMAGE_REPO]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [IMAGE_REPO]!${NC}"
echo "ERROR:[$IMAGE_REPO]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$IMAGE_REPO]${NC}"
exit 1 exit 1
elif [[ "$IMAGE_REPO" == "github/super-linter" ]]; then elif [[ "$IMAGE_REPO" == "github/super-linter" ]]; then
# Found our main repo # Found our main repo
echo "Successfully found:[IMAGE_REPO], value:[$IMAGE_REPO]" echo "Successfully found:[IMAGE_REPO], value:[$IMAGE_REPO]"
else else
# This is a fork and we cant pull vars or any info # This is a fork and we cant pull vars or any info
echo "WARN! No image to cleanup as this is a forked branch, and not being built with current automation!" echo -e "${NC}${F[Y]}WARN!${NC} No image to cleanup as this is a forked branch, and not being built with current automation!${NC}"
exit 0 exit 0
fi fi
@ -82,8 +82,8 @@ ValidateInput()
# Validate IMAGE_VERSION # # Validate IMAGE_VERSION #
########################## ##########################
if [ -z "$IMAGE_VERSION" ]; then if [ -z "$IMAGE_VERSION" ]; then
echo "ERROR! Failed to get [IMAGE_VERSION]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [IMAGE_VERSION]!${NC}"
echo "ERROR:[$IMAGE_VERSION]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$IMAGE_VERSION]${NC}"
exit 1 exit 1
else else
echo "Successfully found:[IMAGE_VERSION], value:[$IMAGE_VERSION]" echo "Successfully found:[IMAGE_VERSION], value:[$IMAGE_VERSION]"
@ -93,8 +93,8 @@ ValidateInput()
# Validate DOCKER_USERNAME # # Validate DOCKER_USERNAME #
############################ ############################
if [ -z "$DOCKER_USERNAME" ]; then if [ -z "$DOCKER_USERNAME" ]; then
echo "ERROR! Failed to get [DOCKER_USERNAME]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_USERNAME]!${NC}"
echo "ERROR:[$DOCKER_USERNAME]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$DOCKER_USERNAME]${NC}"
exit 1 exit 1
else else
echo "Successfully found:[DOCKER_USERNAME], value:[$DOCKER_USERNAME]" echo "Successfully found:[DOCKER_USERNAME], value:[$DOCKER_USERNAME]"
@ -104,8 +104,8 @@ ValidateInput()
# Validate DOCKER_PASSWORD # # Validate DOCKER_PASSWORD #
############################ ############################
if [ -z "$DOCKER_PASSWORD" ]; then if [ -z "$DOCKER_PASSWORD" ]; then
echo "ERROR! Failed to get [DOCKER_PASSWORD]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_PASSWORD]!${NC}"
echo "ERROR:[$DOCKER_PASSWORD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$DOCKER_PASSWORD]${NC}"
exit 1 exit 1
else else
echo "Successfully found:[DOCKER_PASSWORD], value:[********]" echo "Successfully found:[DOCKER_PASSWORD], value:[********]"
@ -157,8 +157,8 @@ LoginToDocker()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# ERROR # ERROR
echo "ERROR! Failed to authenticate to DockerHub!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to authenticate to DockerHub!${NC}"
echo "ERROR:[$LOGIN_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LOGIN_CMD]${NC}"
exit 1 exit 1
else else
# SUCCESS # SUCCESS
@ -197,8 +197,8 @@ RemoveImage()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# ERROR # ERROR
echo "ERROR! Failed to gain token from DockerHub!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to gain token from DockerHub!${NC}"
echo "ERROR:[$TOKEN]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$TOKEN]${NC}"
exit 1 exit 1
else else
# SUCCESS # SUCCESS
@ -222,8 +222,8 @@ RemoveImage()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# ERROR # ERROR
echo "ERROR! Failed to remove tag from DockerHub!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to remove tag from DockerHub!${NC}"
echo "ERROR:[$REMOVE_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$REMOVE_CMD]${NC}"
exit 1 exit 1
else else
# SUCCESS # SUCCESS

View file

@ -53,8 +53,8 @@ CheckGHEPid()
# Check the shell for errors # # Check the shell for errors #
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
echo "ERROR! Failed to sleep!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to sleep!${NC}"
echo "ERROR:[$SLEEP_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$SLEEP_CMD]${NC}"
echo "Will try to call apply as last effort..." echo "Will try to call apply as last effort..."
#################################### ####################################
# Call config apply as last effort # # Call config apply as last effort #
@ -117,8 +117,8 @@ CheckGHEProcess()
# Check the shell for errors # # Check the shell for errors #
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
echo "ERROR! Failed to sleep!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to sleep!${NC}"
echo "ERROR:[$SLEEP_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$SLEEP_CMD]${NC}"
echo "Will try to call apply as last effort..." echo "Will try to call apply as last effort..."
#################################### ####################################
# Call config apply as last effort # # Call config apply as last effort #
@ -161,12 +161,12 @@ RunConfigApply()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# Errors # Errors
echo "ERROR! Failed to run config apply command!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to run config apply command!${NC}"
echo "ERROR:[$APPLY_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$APPLY_CMD]${NC}"
exit 1 exit 1
else else
# Success # Success
echo "Successfully ran $GHE_APPLY_COMMAND" echo -e "${NC}${F[B]}Successfully ran ${F[C]}$GHE_APPLY_COMMAND${NC}"
fi fi
} }
################################################################################ ################################################################################

View file

@ -60,22 +60,22 @@ ValidateInput()
# Validate GITHUB_WORKSPACE # # Validate GITHUB_WORKSPACE #
############################# #############################
if [ -z "$GITHUB_WORKSPACE" ]; then if [ -z "$GITHUB_WORKSPACE" ]; then
echo "ERROR! Failed to get [GITHUB_WORKSPACE]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_WORKSPACE]!${NC}"
echo "ERROR:[$GITHUB_WORKSPACE]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_WORKSPACE]${NC}"
exit 1 exit 1
else else
echo "Successfully found:[GITHUB_WORKSPACE], value:[$GITHUB_WORKSPACE]" echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[$GITHUB_WORKSPACE]${NC}"
fi fi
##################### #####################
# Validate REGISTRY # # Validate REGISTRY #
##################### #####################
if [ -z "$REGISTRY" ]; then if [ -z "$REGISTRY" ]; then
echo "ERROR! Failed to get [REGISTRY]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [REGISTRY]!${NC}"
echo "ERROR:[$REGISTRY]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$REGISTRY]${NC}"
exit 1 exit 1
else else
echo "Successfully found:[REGISTRY], value:[$REGISTRY]" echo -e "${NC}${F[B]}Successfully found:${F[W]}[REGISTRY]${F[B]}, value:${F[W]}[$REGISTRY]${NC}"
fi fi
##################################################### #####################################################
@ -86,22 +86,22 @@ ValidateInput()
# Validate GPR_USERNAME # # Validate GPR_USERNAME #
######################### #########################
if [ -z "$GPR_USERNAME" ]; then if [ -z "$GPR_USERNAME" ]; then
echo "ERROR! Failed to get [GPR_USERNAME]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GPR_USERNAME]!${NC}"
echo "ERROR:[$GPR_USERNAME]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GPR_USERNAME]${NC}"
exit 1 exit 1
else else
echo "Successfully found:[GPR_USERNAME], value:[$GPR_USERNAME]" echo -e "${NC}${F[B]}Successfully found:${F[W]}[GPR_USERNAME]${F[B]}, value:${F[W]}[$GPR_USERNAME]${NC}"
fi fi
###################### ######################
# Validate GPR_TOKEN # # Validate GPR_TOKEN #
###################### ######################
if [ -z "$GPR_TOKEN" ]; then if [ -z "$GPR_TOKEN" ]; then
echo "ERROR! Failed to get [GPR_TOKEN]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GPR_TOKEN]!${NC}"
echo "ERROR:[$GPR_TOKEN]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GPR_TOKEN]${NC}"
exit 1 exit 1
else else
echo "Successfully found:[GPR_TOKEN], value:[********]" echo -e "${NC}${F[B]}Successfully found:${F[W]}[GPR_TOKEN]${F[B]}, value:${F[W]}[********]${NC}"
fi fi
######################################## ########################################
# See if we need values for Ducker hub # # See if we need values for Ducker hub #
@ -111,28 +111,28 @@ ValidateInput()
# Validate DOCKER_USERNAME # # Validate DOCKER_USERNAME #
############################ ############################
if [ -z "$DOCKER_USERNAME" ]; then if [ -z "$DOCKER_USERNAME" ]; then
echo "ERROR! Failed to get [DOCKER_USERNAME]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_USERNAME]!${NC}"
echo "ERROR:[$DOCKER_USERNAME]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$DOCKER_USERNAME]${NC}"
exit 1 exit 1
else else
echo "Successfully found:[DOCKER_USERNAME], value:[$DOCKER_USERNAME]" echo -e "${NC}${F[B]}Successfully found:${F[W]}[DOCKER_USERNAME]${F[B]}, value:${F[W]}[$DOCKER_USERNAME]${NC}"
fi fi
############################ ############################
# Validate DOCKER_PASSWORD # # Validate DOCKER_PASSWORD #
############################ ############################
if [ -z "$DOCKER_PASSWORD" ]; then if [ -z "$DOCKER_PASSWORD" ]; then
echo "ERROR! Failed to get [DOCKER_PASSWORD]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_PASSWORD]!${NC}"
echo "ERROR:[$DOCKER_PASSWORD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$DOCKER_PASSWORD]${NC}"
exit 1 exit 1
else else
echo "Successfully found:[DOCKER_PASSWORD], value:[********]" echo -e "${NC}${F[B]}Successfully found:${F[W]}[DOCKER_PASSWORD]${F[B]}, value:${F[B]}[********]${NC}"
fi fi
########################################### ###########################################
# We were not passed a registry to update # # We were not passed a registry to update #
########################################### ###########################################
else else
echo "ERROR! Failed to find a valid registry!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find a valid registry!${NC}"
echo "Registry:[$REGISTRY]" echo "Registry:[$REGISTRY]"
exit 1 exit 1
fi fi
@ -142,11 +142,11 @@ ValidateInput()
# Validate IMAGE_REPO # # Validate IMAGE_REPO #
####################### #######################
if [ -z "$IMAGE_REPO" ]; then if [ -z "$IMAGE_REPO" ]; then
echo "ERROR! Failed to get [IMAGE_REPO]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [IMAGE_REPO]!${NC}"
echo "ERROR:[$IMAGE_REPO]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$IMAGE_REPO]${NC}"
exit 1 exit 1
else else
echo "Successfully found:[IMAGE_REPO], value:[$IMAGE_REPO]" echo -e "${NC}${F[B]}Successfully found:${F[W]}[IMAGE_REPO]${F[B]}, value:${F[W]}[$IMAGE_REPO]${NC}"
############################################### ###############################################
# Need to see if GPR registry and update name # # Need to see if GPR registry and update name #
############################################### ###############################################
@ -161,7 +161,7 @@ ValidateInput()
# Validate IMAGE_VERSION # # Validate IMAGE_VERSION #
########################## ##########################
if [ -z "$IMAGE_VERSION" ]; then if [ -z "$IMAGE_VERSION" ]; then
echo "WARN! Failed to get [IMAGE_VERSION]!" echo -e "${NC}${F[Y]}WARN!${NC} Failed to get [IMAGE_VERSION]!${NC}"
echo "Pulling from Branch Name..." echo "Pulling from Branch Name..."
############################## ##############################
# Get the name of the branch # # Get the name of the branch #
@ -177,8 +177,8 @@ ValidateInput()
# Check the shell for errors # # Check the shell for errors #
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
echo "ERROR! Failed to get branch name!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get branch name!${NC}"
echo "ERROR:[$BRANCH_NAME]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$BRANCH_NAME]${NC}"
exit 1 exit 1
fi fi
@ -193,7 +193,7 @@ ValidateInput()
IMAGE_VERSION="$BRANCH_NAME" IMAGE_VERSION="$BRANCH_NAME"
echo "Tag:[$IMAGE_VERSION]" echo "Tag:[$IMAGE_VERSION]"
else else
echo "Successfully found:[IMAGE_VERSION], value:[$IMAGE_VERSION]" echo -e "${NC}${F[B]}Successfully found:${F[W]}[IMAGE_VERSION]${F[B]}, value:${F[W]}[$IMAGE_VERSION]${NC}"
fi fi
################################## ##################################
@ -224,11 +224,11 @@ ValidateInput()
# Validate DOCKERFILE_PATH # # Validate DOCKERFILE_PATH #
############################ ############################
if [ -z "$DOCKERFILE_PATH" ]; then if [ -z "$DOCKERFILE_PATH" ]; then
echo "ERROR! Failed to get [DOCKERFILE_PATH]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKERFILE_PATH]!${NC}"
echo "ERROR:[$DOCKERFILE_PATH]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$DOCKERFILE_PATH]${NC}"
exit 1 exit 1
else else
echo "Successfully found:[DOCKERFILE_PATH], value:[$DOCKERFILE_PATH]" echo -e "${NC}${F[B]}Successfully found:${F[W]}[DOCKERFILE_PATH]${F[B]}, value:${F[W]}[$DOCKERFILE_PATH]${NC}"
fi fi
} }
################################################################################ ################################################################################
@ -267,12 +267,12 @@ Authenticate()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# ERROR # ERROR
echo "ERROR! Failed to authenticate to $NAME!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to authenticate to $NAME!${NC}"
echo "ERROR:[$LOGIN_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LOGIN_CMD]${NC}"
exit 1 exit 1
else else
# SUCCESS # SUCCESS
echo "Successfully authenticated to $NAME!" echo -e "${NC}${F[B]}Successfully authenticated to ${F[C]}$NAME${F[B]}!${NC}"
fi fi
} }
################################################################################ ################################################################################
@ -293,7 +293,7 @@ BuildImage()
################################ ################################
if [ ! -f "$DOCKERFILE_PATH" ]; then if [ ! -f "$DOCKERFILE_PATH" ]; then
# No file found # No file found
echo "ERROR! failed to find Dockerfile at:[$DOCKERFILE_PATH]" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to find Dockerfile at:[$DOCKERFILE_PATH]${NC}"
echo "Please make sure you give full path!" echo "Please make sure you give full path!"
echo "Example:[/configs/Dockerfile] or [Dockerfile] if at root directory" echo "Example:[/configs/Dockerfile] or [Dockerfile] if at root directory"
exit 1 exit 1
@ -314,11 +314,11 @@ BuildImage()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# ERROR # ERROR
echo "ERROR! failed to [build] Dockerfile!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [build] Dockerfile!${NC}"
exit 1 exit 1
else else
# SUCCESS # SUCCESS
echo "Successfully Built image!" echo -e "${NC}${F[B]}Successfully Built image!${NC}"
fi fi
######################################################## ########################################################
@ -338,11 +338,11 @@ BuildImage()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# ERROR # ERROR
echo "ERROR! failed to [tag] Dockerfile!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [tag] Dockerfile!${NC}"
exit 1 exit 1
else else
# SUCCESS # SUCCESS
echo "Successfully tagged image!" echo -e "${NC}${F[B]}Successfully tagged image!${NC}"
fi fi
fi fi
} }
@ -374,11 +374,11 @@ UploadImage()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# ERROR # ERROR
echo "ERROR! failed to [upload] Dockerfile!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [upload] Dockerfile!${NC}"
exit 1 exit 1
else else
# SUCCESS # SUCCESS
echo "Successfully Uploaded Docker image:[$IMAGE_VERSION] to $REGISTRY!" echo -e "${NC}${F[B]}Successfully Uploaded Docker image:${F[W]}[$IMAGE_VERSION]${F[B]} to ${F[C]}$REGISTRY${F[B]}!${NC}"
fi fi
######################### #########################
@ -397,8 +397,8 @@ UploadImage()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# ERROR # ERROR
echo "ERROR! Failed to get information about built Image!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get information about built Image!${NC}"
echo "ERROR:[$GET_INFO_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GET_INFO_CMD]${NC}"
exit 1 exit 1
else else
################ ################
@ -440,11 +440,11 @@ UploadImage()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# ERROR # ERROR
echo "ERROR! failed to [upload] MAJOR_TAG:[$MAJOR_TAG] Dockerfile!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [upload] MAJOR_TAG:[$MAJOR_TAG] Dockerfile!${NC}"
exit 1 exit 1
else else
# SUCCESS # SUCCESS
echo "Successfully Uploaded TAGOR_TAG:[$MAJOR_TAG] Docker image to $REGISTRY!" echo -e "${NC}${F[B]}Successfully Uploaded TAGOR_TAG:${F[W]}[$MAJOR_TAG]${F[B]} Docker image to ${F[C]}$REGISTRY${F[B]}!${NC}"
fi fi
fi fi
} }
@ -495,7 +495,7 @@ else
######### #########
# ERROR # # ERROR #
######### #########
echo "ERROR! Registry not set correctly!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Registry not set correctly!${NC}"
echo "Registry:[$REGISTRY]" echo "Registry:[$REGISTRY]"
exit 1 exit 1
fi fi

View file

@ -39,7 +39,7 @@ function BuildFileList()
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# Error # Error
echo "Failed to switch to $DEFAULT_BRANCH branch to get files changed!" echo "Failed to switch to $DEFAULT_BRANCH branch to get files changed!"
echo "ERROR:[$SWITCH_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$SWITCH_CMD]${NC}"
exit 1 exit 1
fi fi
@ -67,8 +67,8 @@ function BuildFileList()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# Error # Error
echo "ERROR! Failed to gain a list of all files changed!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to gain a list of all files changed!${NC}"
echo "ERROR:[${RAW_FILE_ARRAY[*]}]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${RAW_FILE_ARRAY[*]}]${NC}"
exit 1 exit 1
fi fi
@ -375,7 +375,7 @@ function BuildFileList()
####################### #######################
# It is a bash script # # It is a bash script #
####################### #######################
echo "WARN! Found bash script without extension:[.sh]" echo -e "${NC}${F[Y]}WARN!${NC} Found bash script without extension:[.sh]${NC}"
echo "Please update file with proper extensions." echo "Please update file with proper extensions."
################################ ################################
# Append the file to the array # # Append the file to the array #
@ -389,7 +389,7 @@ function BuildFileList()
####################### #######################
# It is a Ruby script # # It is a Ruby script #
####################### #######################
echo "WARN! Found ruby script without extension:[.rb]" echo -e "${NC}${F[Y]}WARN!${NC} Found ruby script without extension:[.rb]${NC}"
echo "Please update file with proper extensions." echo "Please update file with proper extensions."
################################ ################################
# Append the file to the array # # Append the file to the array #
@ -403,7 +403,7 @@ function BuildFileList()
############################ ############################
# Extension was not found! # # Extension was not found! #
############################ ############################
echo " - WARN! Failed to get filetype for:[$FILE]!" echo -e "${NC}${F[Y]} - WARN!${NC} Failed to get filetype for:[$FILE]!${NC}"
########################################################## ##########################################################
# Set the READ_ONLY_CHANGE_FLAG since this could be exec # # Set the READ_ONLY_CHANGE_FLAG since this could be exec #
########################################################## ##########################################################
@ -430,7 +430,7 @@ function BuildFileList()
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# Error # Error
echo "Failed to switch back to branch!" echo "Failed to switch back to branch!"
echo "ERROR:[$SWITCH2_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$SWITCH2_CMD]${NC}"
exit 1 exit 1
fi fi
@ -439,5 +439,5 @@ function BuildFileList()
################ ################
echo "" echo ""
echo "----------------------------------------------" echo "----------------------------------------------"
echo "Successfully gathered list of files..." echo -e "${NC}${F[B]}Successfully gathered list of files...${NC}"
} }

View file

@ -10,6 +10,8 @@
# Source Function Files # # Source Function Files #
######################### #########################
# shellcheck source=/dev/null # shellcheck source=/dev/null
source /action/lib/termColors.sh # Source the function script(s)
# shellcheck source=/dev/null
source /action/lib/buildFileList.sh # Source the function script(s) source /action/lib/buildFileList.sh # Source the function script(s)
# shellcheck source=/dev/null # shellcheck source=/dev/null
source /action/lib/validation.sh # Source the function script(s) source /action/lib/validation.sh # Source the function script(s)
@ -277,7 +279,7 @@ GetLinterVersions()
# Check the shell for errors # # Check the shell for errors #
############################## ##############################
if [ $ERROR_CODE -ne 0 ] || [ -z "${GET_VERSION_CMD[*]}" ]; then if [ $ERROR_CODE -ne 0 ] || [ -z "${GET_VERSION_CMD[*]}" ]; then
echo "WARN! Failed to get version info for:[$LINTER]" echo -e "${NC}${F[Y]}WARN!${NC} Failed to get version info for:[$LINTER]${NC}"
echo "---------------------------------------------" echo "---------------------------------------------"
else else
########################## ##########################
@ -363,8 +365,8 @@ GetStandardRules()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# ERROR # ERROR
echo "ERROR! Failed to gain list of ENV vars to load!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to gain list of ENV vars to load!${NC}"
echo "ERROR:[${GET_ENV_ARRAY[*]}]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GET_ENV_ARRAY[*]}]${NC}"
exit 1 exit 1
fi fi
@ -565,33 +567,33 @@ GetGitHubVars()
# Validate we have a value # # Validate we have a value #
############################ ############################
if [ -z "$GITHUB_SHA" ]; then if [ -z "$GITHUB_SHA" ]; then
echo "ERROR! Failed to get [GITHUB_SHA]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_SHA]!${NC}"
echo "ERROR:[$GITHUB_SHA]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_SHA]${NC}"
exit 1 exit 1
else else
echo "Successfully found:[GITHUB_SHA], value:[$GITHUB_SHA]" echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_SHA]${F[B]}, value:${F[W]}[$GITHUB_SHA]${NC}"
fi fi
############################ ############################
# Validate we have a value # # Validate we have a value #
############################ ############################
if [ -z "$GITHUB_WORKSPACE" ]; then if [ -z "$GITHUB_WORKSPACE" ]; then
echo "ERROR! Failed to get [GITHUB_WORKSPACE]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_WORKSPACE]!${NC}"
echo "ERROR:[$GITHUB_WORKSPACE]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_WORKSPACE]${NC}"
exit 1 exit 1
else else
echo "Successfully found:[GITHUB_WORKSPACE], value:[$GITHUB_WORKSPACE]" echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[$GITHUB_WORKSPACE]${NC}"
fi fi
############################ ############################
# Validate we have a value # # Validate we have a value #
############################ ############################
if [ -z "$GITHUB_EVENT_PATH" ]; then if [ -z "$GITHUB_EVENT_PATH" ]; then
echo "ERROR! Failed to get [GITHUB_EVENT_PATH]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_EVENT_PATH]!${NC}"
echo "ERROR:[$GITHUB_EVENT_PATH]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_EVENT_PATH]${NC}"
exit 1 exit 1
else else
echo "Successfully found:[GITHUB_EVENT_PATH], value:[$GITHUB_EVENT_PATH]" echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_EVENT_PATH]${F[B]}, value:${F[W]}[$GITHUB_EVENT_PATH]${F[B]}${NC}"
fi fi
################################################## ##################################################
@ -607,11 +609,11 @@ GetGitHubVars()
# Validate we have a value # # Validate we have a value #
############################ ############################
if [ -z "$GITHUB_ORG" ]; then if [ -z "$GITHUB_ORG" ]; then
echo "ERROR! Failed to get [GITHUB_ORG]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_ORG]!${NC}"
echo "ERROR:[$GITHUB_ORG]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_ORG]${NC}"
exit 1 exit 1
else else
echo "Successfully found:[GITHUB_ORG], value:[$GITHUB_ORG]" echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_ORG]${F[B]}, value:${F[W]}[$GITHUB_ORG]${NC}"
fi fi
####################### #######################
@ -623,11 +625,11 @@ GetGitHubVars()
# Validate we have a value # # Validate we have a value #
############################ ############################
if [ -z "$GITHUB_REPO" ]; then if [ -z "$GITHUB_REPO" ]; then
echo "ERROR! Failed to get [GITHUB_REPO]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_REPO]!${NC}"
echo "ERROR:[$GITHUB_REPO]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_REPO]${NC}"
exit 1 exit 1
else else
echo "Successfully found:[GITHUB_REPO], value:[$GITHUB_REPO]" echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_REPO]${F[B]}, value:${F[W]}[$GITHUB_REPO]${NC}"
fi fi
fi fi
} }
@ -662,14 +664,14 @@ function ValidatePowershellModules()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# Failed # Failed
echo "ERROR! Failed find module [PSScriptAnalyzer] for [$LINTER_NAME] in system!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed find module [PSScriptAnalyzer] for [$LINTER_NAME] in system!${NC}"
echo "ERROR:[PSSA_MODULE $VALIDATE_PSSA_MODULE] [PSSA_CMD $VALIDATE_PSSA_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[PSSA_MODULE $VALIDATE_PSSA_MODULE] [PSSA_CMD $VALIDATE_PSSA_CMD]${NC}"
exit 1 exit 1
else else
# Success # Success
if [[ "$ACTIONS_RUNNER_DEBUG" == "true" ]]; then if [[ "$ACTIONS_RUNNER_DEBUG" == "true" ]]; then
echo "Successfully found module [$VALIDATE_PSSA_MODULE] in system" echo -e "${NC}${F[B]}Successfully found module ${F[W]}[$VALIDATE_PSSA_MODULE]${F[B]} in system${NC}"
echo "Successfully found command [$VALIDATE_PSSA_CMD] in system" echo -e "${NC}${F[B]}Successfully found command ${F[W]}[$VALIDATE_PSSA_CMD]${F[B]} in system${NC}"
fi fi
fi fi
} }
@ -700,7 +702,7 @@ Footer()
################## ##################
if [ "${!ERROR_COUNTER}" -ne 0 ]; then if [ "${!ERROR_COUNTER}" -ne 0 ]; then
# Print the goods # Print the goods
echo "ERRORS FOUND in $LANGUAGE:[${!ERROR_COUNTER}]" echo -e "${NC}${B[R]}${F[W]}ERRORS FOUND${NC} in $LANGUAGE:[${!ERROR_COUNTER}]${NC}"
fi fi
done done
@ -708,7 +710,7 @@ Footer()
# Exit with 0 if errors disabled # # Exit with 0 if errors disabled #
################################## ##################################
if [ "$DISABLE_ERRORS" == "true" ]; then if [ "$DISABLE_ERRORS" == "true" ]; then
echo "WARN! Exiting with exit code:[0] as:[DISABLE_ERRORS] was set to:[$DISABLE_ERRORS]" echo -e "${NC}${F[Y]}WARN!${NC} Exiting with exit code:[0] as:[DISABLE_ERRORS] was set to:[$DISABLE_ERRORS]${NC}"
exit 0 exit 0
############################### ###############################
# Exit with 1 if errors found # # Exit with 1 if errors found #
@ -740,14 +742,14 @@ Footer()
[ "$ERRORS_FOUND_CLOJURE" -ne 0 ] || \ [ "$ERRORS_FOUND_CLOJURE" -ne 0 ] || \
[ "$ERRORS_FOUND_KOTLIN" -ne 0 ]; then [ "$ERRORS_FOUND_KOTLIN" -ne 0 ]; then
# Failed exit # Failed exit
echo "Exiting with errors found!" echo -e "${NC}${F[R]}Exiting with errors found!${NC}"
exit 1 exit 1
else else
################# #################
# Footer prints # # Footer prints #
################# #################
echo "" echo ""
echo "All file(s) linted successfully with no errors detected" echo -e "${NC}${F[G]}All file(s) linted successfully with no errors detected${NC}"
echo "----------------------------------------------" echo "----------------------------------------------"
echo "" echo ""
# Successful exit # Successful exit

27
lib/termColors.sh Normal file
View file

@ -0,0 +1,27 @@
#!/usr/bin/env bash
declare -Agr B=(
[B]=$(echo -e "\e[44m")
[C]=$(echo -e "\e[46m")
[G]=$(echo -e "\e[42m")
[K]=$(echo -e "\e[40m")
[M]=$(echo -e "\e[45m")
[R]=$(echo -e "\e[41m")
[W]=$(echo -e "\e[47m")
[Y]=$(echo -e "\e[43m")
)
declare -Agr F=(
[B]=$(echo -e "\e[0;34m")
[C]=$(echo -e "\e[0;36m")
[G]=$(echo -e "\e[0;32m")
[K]=$(echo -e "\e[0;30m")
[M]=$(echo -e "\e[0;35m")
[R]=$(echo -e "\e[0;31m")
[W]=$(echo -e "\e[0;37m")
[Y]=$(echo -e "\e[0;33m")
)
readonly NC=$(echo -e "\e[0m")
export B
export F
export NC

View file

@ -50,13 +50,13 @@ function LintCodebase()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# Failed # Failed
echo "ERROR! Failed to find [$LINTER_NAME] in system!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find [$LINTER_NAME] in system!${NC}"
echo "ERROR:[$VALIDATE_INSTALL_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$VALIDATE_INSTALL_CMD]${NC}"
exit 1 exit 1
else else
# Success # Success
if [[ "$ACTIONS_RUNNER_DEBUG" == "true" ]]; then if [[ "$ACTIONS_RUNNER_DEBUG" == "true" ]]; then
echo "Successfully found binary for [$LINTER_NAME] in system" echo -e "${NC}${F[B]}Successfully found binary for ${F[W]}[$LINTER_NAME]${F[B]} in system${NC}"
echo "Location:[$VALIDATE_INSTALL_CMD]" echo "Location:[$VALIDATE_INSTALL_CMD]"
fi fi
fi fi
@ -187,15 +187,15 @@ function LintCodebase()
######### #########
# Error # # Error #
######### #########
echo "ERROR! Found errors in [$LINTER_NAME] linter!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [$LINTER_NAME] linter!${NC}"
echo "ERROR:[$LINT_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LINT_CMD]${NC}"
# Increment the error count # Increment the error count
(("ERRORS_FOUND_$FILE_TYPE++")) (("ERRORS_FOUND_$FILE_TYPE++"))
else else
########### ###########
# Success # # Success #
########### ###########
echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully" echo -e "${NC}${F[B]} - File:${F[W]}[$FILE_NAME]${F[B]} was linted with ${F[W]}[$LINTER_NAME]${F[B]} successfully${NC}"
fi fi
done done
fi fi
@ -240,12 +240,12 @@ function TestCodebase()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# Failed # Failed
echo "ERROR! Failed to find [$LINTER_NAME] in system!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find [$LINTER_NAME] in system!${NC}"
echo "ERROR:[$VALIDATE_INSTALL_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$VALIDATE_INSTALL_CMD]${NC}"
exit 1 exit 1
else else
# Success # Success
echo "Successfully found binary in system" echo -e "${NC}${F[B]}Successfully found binary in system${NC}"
echo "Location:[$VALIDATE_INSTALL_CMD]" echo "Location:[$VALIDATE_INSTALL_CMD]"
fi fi
@ -358,9 +358,9 @@ function TestCodebase()
######### #########
# Error # # Error #
######### #########
echo "ERROR! Found errors in [$LINTER_NAME] linter!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [$LINTER_NAME] linter!${NC}"
echo "ERROR:[$LINT_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LINT_CMD]${NC}"
echo "ERROR: Linter CMD:[$LINTER_COMMAND $FILE]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC} Linter CMD:[$LINTER_COMMAND $FILE]${NC}"
# Increment the error count # Increment the error count
(("ERRORS_FOUND_$FILE_TYPE++")) (("ERRORS_FOUND_$FILE_TYPE++"))
# Increment counter that check was ran # Increment counter that check was ran
@ -369,7 +369,7 @@ function TestCodebase()
########### ###########
# Success # # Success #
########### ###########
echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully" echo -e "${NC}${F[B]} - File:${F[W]}[$FILE_NAME]${F[B]} was linted with ${F[W]}[$LINTER_NAME]${F[B]} successfully${NC}"
# Increment counter that check was ran # Increment counter that check was ran
((TESTS_RAN++)) ((TESTS_RAN++))
fi fi
@ -384,10 +384,10 @@ function TestCodebase()
######### #########
# Error # # Error #
######### #########
echo "ERROR! Found errors in [$LINTER_NAME] linter!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [$LINTER_NAME] linter!${NC}"
echo "ERROR! This file should have failed test case!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} This file should have failed test case!${NC}"
echo "ERROR:[$LINT_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LINT_CMD]${NC}"
echo "ERROR: Linter CMD:[$LINTER_COMMAND $FILE]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC} Linter CMD:[$LINTER_COMMAND $FILE]${NC}"
# Increment the error count # Increment the error count
(("ERRORS_FOUND_$FILE_TYPE++")) (("ERRORS_FOUND_$FILE_TYPE++"))
# Increment counter that check was ran # Increment counter that check was ran
@ -396,7 +396,7 @@ function TestCodebase()
########### ###########
# Success # # Success #
########### ###########
echo " - File:[$FILE_NAME] failed test case with [$LINTER_NAME] successfully" echo -e "${NC}${F[B]} - File:${F[W]}[$FILE_NAME]${F[B]} failed test case with ${F[W]}[$LINTER_NAME]${F[B]} successfully${NC}"
# Increment counter that check was ran # Increment counter that check was ran
((TESTS_RAN++)) ((TESTS_RAN++))
fi fi
@ -410,7 +410,7 @@ function TestCodebase()
################################################# #################################################
# We failed to find files and no tests were ran # # We failed to find files and no tests were ran #
################################################# #################################################
echo "ERROR! Failed to find any tests ran for the Linter:[$LINTER_NAME]"! echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find any tests ran for the Linter:[$LINTER_NAME]${NC}"!
echo "Please validate logic or that tests exist!" echo "Please validate logic or that tests exist!"
exit 1 exit 1
fi fi
@ -513,14 +513,14 @@ function LintAnsibleFiles()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# Failed # Failed
echo "ERROR! Failed to find $LINTER_NAME in system!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find $LINTER_NAME in system!${NC}"
echo "ERROR:[$VALIDATE_INSTALL_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$VALIDATE_INSTALL_CMD]${NC}"
exit 1 exit 1
else else
# Success # Success
if [[ "$ACTIONS_RUNNER_DEBUG" == "true" ]]; then if [[ "$ACTIONS_RUNNER_DEBUG" == "true" ]]; then
# Success # Success
echo "Successfully found binary in system" echo -e "${NC}${F[B]}Successfully found binary in system${NC}"
echo "Location:[$VALIDATE_INSTALL_CMD]" echo "Location:[$VALIDATE_INSTALL_CMD]"
fi fi
fi fi
@ -619,15 +619,15 @@ function LintAnsibleFiles()
######### #########
# Error # # Error #
######### #########
echo "ERROR! Found errors in [$LINTER_NAME] linter!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [$LINTER_NAME] linter!${NC}"
echo "ERROR:[$LINT_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LINT_CMD]${NC}"
# Increment error count # Increment error count
((ERRORS_FOUND_ANSIBLE++)) ((ERRORS_FOUND_ANSIBLE++))
else else
########### ###########
# Success # # Success #
########### ###########
echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully" echo -e "${NC}${F[B]} - File:${F[W]}[$FILE_NAME]${F[B]} was linted with ${F[W]}[$LINTER_NAME]${F[B]} successfully${NC}"
fi fi
done done
else # No ansible directory found in path else # No ansible directory found in path
@ -638,7 +638,7 @@ function LintAnsibleFiles()
######################## ########################
# No Ansible dir found # # No Ansible dir found #
######################## ########################
echo "WARN! No Ansible base directory found at:[$ANSIBLE_DIRECTORY]" echo -e "${NC}${F[Y]}WARN!${NC} No Ansible base directory found at:[$ANSIBLE_DIRECTORY]${NC}"
echo "skipping ansible lint" echo "skipping ansible lint"
fi fi
fi fi