Merge remote-tracking branch 'upstream/master' into arm-ttk

This commit is contained in:
Kevin Rowlandson 2020-07-03 13:28:08 +01:00
commit 4cbda27751
No known key found for this signature in database
GPG key ID: F33348ACAE26BE84
14 changed files with 655 additions and 586 deletions

View file

@ -28,8 +28,7 @@ DOCKERFILE_PATH="${DOCKERFILE_PATH}" # Path to the Dockerfile to be uploaded
################################################################################ ################################################################################
################################################################################ ################################################################################
#### Function Header ########################################################### #### Function Header ###########################################################
Header() Header() {
{
echo "" echo ""
echo "-------------------------------------------------------" echo "-------------------------------------------------------"
echo "----- GitHub Actions remove image from DockerHub ------" echo "----- GitHub Actions remove image from DockerHub ------"
@ -38,8 +37,7 @@ Header()
} }
################################################################################ ################################################################################
#### Function ValidateInput #################################################### #### Function ValidateInput ####################################################
ValidateInput() ValidateInput() {
{
# Need to validate we have the basic variables # Need to validate we have the basic variables
################ ################
# Print header # # Print header #
@ -54,8 +52,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 +64,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 +80,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 +91,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 +102,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:[********]"
@ -114,7 +112,7 @@ ValidateInput()
################################################## ##################################################
# Check if we need to get the name of the branch # # Check if we need to get the name of the branch #
################################################## ##################################################
if [[ "$IMAGE_VERSION" != "latest" ]]; then if [[ $IMAGE_VERSION != "latest" ]]; then
################################## ##################################
# Remove non alpha-numeric chars # # Remove non alpha-numeric chars #
################################## ##################################
@ -131,8 +129,7 @@ ValidateInput()
} }
################################################################################ ################################################################################
#### Function LoginToDocker #################################################### #### Function LoginToDocker ####################################################
LoginToDocker() LoginToDocker() {
{
################ ################
# Print header # # Print header #
################ ################
@ -157,8 +154,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
@ -167,8 +164,7 @@ LoginToDocker()
} }
################################################################################ ################################################################################
#### Function RemoveImage ###################################################### #### Function RemoveImage ######################################################
RemoveImage() RemoveImage() {
{
################ ################
# Print header # # Print header #
################ ################
@ -197,8 +193,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 +218,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
@ -232,8 +228,7 @@ RemoveImage()
} }
################################################################################ ################################################################################
#### Function Footer ########################################################### #### Function Footer ###########################################################
Footer() Footer() {
{
echo "" echo ""
echo "-------------------------------------------------------" echo "-------------------------------------------------------"
echo "The step has completed" echo "The step has completed"

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

@ -34,8 +34,7 @@ UPDATE_MAJOR_TAG=0 # Flag to deploy the major tag version a
################################################################################ ################################################################################
################################################################################ ################################################################################
#### Function Header ########################################################### #### Function Header ###########################################################
Header() Header() {
{
echo "" echo ""
echo "-------------------------------------------------------" echo "-------------------------------------------------------"
echo "---- GitHub Actions Upload image to [$REGISTRY] ----" echo "---- GitHub Actions Upload image to [$REGISTRY] ----"
@ -44,8 +43,7 @@ Header()
} }
################################################################################ ################################################################################
#### Function ValidateInput #################################################### #### Function ValidateInput ####################################################
ValidateInput() ValidateInput() {
{
# Need to validate we have the basic variables # Need to validate we have the basic variables
################ ################
# Print header # # Print header #
@ -60,97 +58,96 @@ 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
##################################################### #####################################################
# See if we need values for GitHub package Registry # # See if we need values for GitHub package Registry #
##################################################### #####################################################
if [[ "$REGISTRY" == "GPR" ]]; then if [[ $REGISTRY == "GPR" ]]; then
######################### #########################
# 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 #
######################################## ########################################
elif [[ "$REGISTRY" == "Docker" ]]; then elif [[ $REGISTRY == "Docker" ]]; then
############################ ############################
# 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
####################### #######################
# 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 #
############################################### ###############################################
if [[ "$REGISTRY" == "GPR" ]]; then if [[ $REGISTRY == "GPR" ]]; then
NAME="docker.pkg.github.com/$IMAGE_REPO/super-linter" NAME="docker.pkg.github.com/$IMAGE_REPO/super-linter"
IMAGE_REPO="$NAME" IMAGE_REPO="$NAME"
echo "Updated [IMAGE_REPO] to:[$IMAGE_REPO] for GPR" echo "Updated [IMAGE_REPO] to:[$IMAGE_REPO] for GPR"
@ -161,7 +158,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 +174,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 +190,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
################################## ##################################
@ -204,7 +201,7 @@ ValidateInput()
###################################################################### ######################################################################
# Check if this is a latest to a versioned release at create new tag # # Check if this is a latest to a versioned release at create new tag #
###################################################################### ######################################################################
if [[ "$IMAGE_VERSION" =~ $REGEX ]]; then if [[ $IMAGE_VERSION =~ $REGEX ]]; then
# Need to get the major version, and set flag to update # Need to get the major version, and set flag to update
##################### #####################
@ -224,17 +221,16 @@ 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
} }
################################################################################ ################################################################################
#### Function Authenticate ##################################################### #### Function Authenticate #####################################################
Authenticate() Authenticate() {
{
################ ################
# Pull in Vars # # Pull in Vars #
################ ################
@ -267,18 +263,17 @@ 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
} }
################################################################################ ################################################################################
#### Function BuildImage ####################################################### #### Function BuildImage #######################################################
BuildImage() BuildImage() {
{
################ ################
# Print header # # Print header #
################ ################
@ -293,7 +288,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 +309,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,18 +333,17 @@ 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
} }
################################################################################ ################################################################################
#### Function UploadImage ###################################################### #### Function UploadImage ######################################################
UploadImage() UploadImage() {
{
################ ################
# Print header # # Print header #
################ ################
@ -374,11 +368,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 +391,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,18 +434,17 @@ 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
} }
################################################################################ ################################################################################
#### Function Footer ########################################################### #### Function Footer ###########################################################
Footer() Footer() {
{
echo "" echo ""
echo "-------------------------------------------------------" echo "-------------------------------------------------------"
echo "The step has completed" echo "The step has completed"
@ -480,14 +473,14 @@ BuildImage
###################### ######################
# Login to DockerHub # # Login to DockerHub #
###################### ######################
if [[ "$REGISTRY" == "Docker" ]]; then if [[ $REGISTRY == "Docker" ]]; then
# Authenticate "Username" "Password" "Url" "Name" # Authenticate "Username" "Password" "Url" "Name"
Authenticate "$DOCKER_USERNAME" "$DOCKER_PASSWORD" "" "Dockerhub" Authenticate "$DOCKER_USERNAME" "$DOCKER_PASSWORD" "" "Dockerhub"
#################################### ####################################
# Login to GitHub Package Registry # # Login to GitHub Package Registry #
#################################### ####################################
elif [[ "$REGISTRY" == "GPR" ]]; then elif [[ $REGISTRY == "GPR" ]]; then
# Authenticate "Username" "Password" "Url" "Name" # Authenticate "Username" "Password" "Url" "Name"
Authenticate "$GPR_USERNAME" "$GPR_TOKEN" "https://docker.pkg.github.com" "GitHub Package Registry" Authenticate "$GPR_USERNAME" "$GPR_TOKEN" "https://docker.pkg.github.com" "GitHub Package Registry"
@ -495,7 +488,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

@ -31,6 +31,8 @@ jobs:
name: Deploy Docker Image - DEV name: Deploy Docker Image - DEV
# Set the agent to run on # Set the agent to run on
runs-on: ubuntu-latest runs-on: ubuntu-latest
# Prevent duplicate run from happening when a forked push is committed
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
################## ##################
# Load all steps # # Load all steps #
################## ##################

61
.github/workflows/stale.yml vendored Normal file
View file

@ -0,0 +1,61 @@
---
###############################
###############################
## StaleBot for Super-Linter ##
###############################
###############################
on:
schedule:
# every day at 0:00 UTC
- cron: "0 0 * * *"
issue_comment:
types: [created, deleted, edited]
###################
# Name of the Job #
###################
name: "Stale[bot]"
###############
# Run the job #
###############
jobs:
#######################
# Mark an Issue Stale #
#######################
markstale:
runs-on: ubuntu-latest
# only run on schedule
if: "github.event_name == 'schedule'"
steps:
- name: Mark issue stale
uses: actions/stale@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: "This issue has been automatically marked as stale because it has not had recent activity.\nIt will be closed in 14 days if no further activity occurs.\nThank you for your contributions.\n\nIf you think this issue should stay open, please remove the `O: stale 🤖` label or comment on the issue."
stale-pr-message: "This pull request has been automatically marked as stale because it has not had recent activity.\nIt will be closed in 14 days if no further activity occurs.\nThank you for your contributions.\n\nIf you think this pull request should stay open, please remove the `O: stale 🤖` label or comment on the pull request."
days-before-stale: 30
days-before-close: 14
stale-issue-label: "O: stale 🤖"
exempt-issue-label: "O: backlog 🤖"
stale-pr-label: "O: stale 🤖"
exempt-pr-label: "O: backlog 🤖"
##################
# Mark not stale #
##################
marknotstale:
runs-on: ubuntu-latest
# do not run on schedule
if: "github.event_name == 'issue_comment' && contains(github.event.issue.labels.*.name, 'O: stale 🤖') && github.event.issue.user.type != 'Bot'"
steps:
- name: Mark issue not stale
uses: actions/github-script@v2
with:
script: |
github.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: 'O: stale 🤖'
})

View file

@ -60,7 +60,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base
| **YAML** | [YamlLint](https://github.com/adrienverge/yamllint) | | **YAML** | [YamlLint](https://github.com/adrienverge/yamllint) |
## How to use ## How to use
<img height="512" src="https://github.com/github/super-linter/blob/quickstart/docs/how-to.gif?raw=true" alt="How to gif"> More in-depth [tutorial](https://www.youtube.com/watch?v=EDAmFKO4Zt0&t=118s) available
To use this **GitHub** Action you will need to complete the following: To use this **GitHub** Action you will need to complete the following:
1. Create a new file in your repository called `.github/workflows/linter.yml` 1. Create a new file in your repository called `.github/workflows/linter.yml`
@ -96,8 +96,10 @@ name: Lint Code Base
############################# #############################
on: on:
push: push:
branches-ignore: branches-ignore: [master]
- 'master' # Remove the line above to run when pushing to master
pull_request:
branches: [master]
############### ###############
# Set the Job # # Set the Job #
@ -126,7 +128,8 @@ jobs:
uses: docker://github/super-linter:v3 uses: docker://github/super-linter:v3
env: env:
VALIDATE_ALL_CODEBASE: false VALIDATE_ALL_CODEBASE: false
VALIDATE_ANSIBLE: false DEFAULT_BRANCH: master
... ...
``` ```

View file

@ -1,6 +1,6 @@
// https://github.com/terraform-linters/tflint/blob/master/docs/guides/config.md // https://github.com/terraform-linters/tflint/blob/master/docs/guides/config.md
config { config {
module = true module = false
deep_check = false deep_check = false
force = false force = false

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 MiB

View file

@ -9,15 +9,14 @@
################################################################################ ################################################################################
################################################################################ ################################################################################
#### Function BuildFileList #################################################### #### Function BuildFileList ####################################################
function BuildFileList() function BuildFileList() {
{
# Need to build a list of all files changed # Need to build a list of all files changed
# This can be pulled from the GITHUB_EVENT_PATH payload # This can be pulled from the GITHUB_EVENT_PATH payload
################ ################
# print header # # print header #
################ ################
if [[ "$ACTIONS_RUNNER_DEBUG" == "true" ]]; then if [[ $ACTIONS_RUNNER_DEBUG == "true" ]]; then
echo "" echo ""
echo "----------------------------------------------" echo "----------------------------------------------"
echo "Pulling in code history and branches..." echo "Pulling in code history and branches..."
@ -26,7 +25,10 @@ function BuildFileList()
################################################################################# #################################################################################
# Switch codebase back to the default branch to get a list of all files changed # # Switch codebase back to the default branch to get a list of all files changed #
################################################################################# #################################################################################
SWITCH_CMD=$(cd "$GITHUB_WORKSPACE" || exit; git pull --quiet; git checkout "$DEFAULT_BRANCH" 2>&1) SWITCH_CMD=$(
git -C "$GITHUB_WORKSPACE" pull --quiet
git -C "$GITHUB_WORKSPACE" checkout "$DEFAULT_BRANCH" 2>&1
)
####################### #######################
# Load the error code # # Load the error code #
@ -39,14 +41,14 @@ 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
################ ################
# print header # # print header #
################ ################
if [[ "$ACTIONS_RUNNER_DEBUG" == "true" ]]; then if [[ $ACTIONS_RUNNER_DEBUG == "true" ]]; then
echo "" echo ""
echo "----------------------------------------------" echo "----------------------------------------------"
echo "Generating Diff with:[git diff --name-only '$DEFAULT_BRANCH..$GITHUB_SHA' --diff-filter=d]" echo "Generating Diff with:[git diff --name-only '$DEFAULT_BRANCH..$GITHUB_SHA' --diff-filter=d]"
@ -67,8 +69,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
@ -78,8 +80,7 @@ function BuildFileList()
echo "" echo ""
echo "----------------------------------------------" echo "----------------------------------------------"
echo "Files that have been modified in the commit(s):" echo "Files that have been modified in the commit(s):"
for FILE in "${RAW_FILE_ARRAY[@]}" for FILE in "${RAW_FILE_ARRAY[@]}"; do
do
############## ##############
# Print file # # Print file #
############## ##############
@ -100,11 +101,11 @@ function BuildFileList()
##################### #####################
# Get the CFN files # # Get the CFN files #
##################### #####################
if [ "$FILE_TYPE" == "json" ] || [ "$FILE_TYPE" == "yml" ] || [ "$FILE_TYPE" == "yaml" ] && DetectCloudFormationFile "$FILE"; then if [ "$FILE_TYPE" == "yml" ] || [ "$FILE_TYPE" == "yaml" ]; then
################################ ################################
# Append the file to the array # # Append the file to the array #
################################ ################################
FILE_ARRAY_CFN+=("$FILE") FILE_ARRAY_YML+=("$FILE")
########################################################## ##########################################################
# Set the READ_ONLY_CHANGE_FLAG since this could be exec # # Set the READ_ONLY_CHANGE_FLAG since this could be exec #
########################################################## ##########################################################
@ -118,11 +119,12 @@ function BuildFileList()
# Append the file to the array # # Append the file to the array #
################################ ################################
FILE_ARRAY_CFN+=("$FILE") FILE_ARRAY_CFN+=("$FILE")
fi
########################################################## ##########################################################
# Set the READ_ONLY_CHANGE_FLAG since this could be exec # # Set the READ_ONLY_CHANGE_FLAG since this could be exec #
########################################################## ##########################################################
READ_ONLY_CHANGE_FLAG=1 READ_ONLY_CHANGE_FLAG=1
fi
###################### ######################
# Get the JSON files # # Get the JSON files #
###################### ######################
@ -351,7 +353,7 @@ function BuildFileList()
# Set the READ_ONLY_CHANGE_FLAG since this could be exec # # Set the READ_ONLY_CHANGE_FLAG since this could be exec #
########################################################## ##########################################################
READ_ONLY_CHANGE_FLAG=1 READ_ONLY_CHANGE_FLAG=1
elif [ "$FILE" == "Dockerfile" ]; then elif [ "$FILE" == "dockerfile" ]; then
################################ ################################
# Append the file to the array # # Append the file to the array #
################################ ################################
@ -378,11 +380,11 @@ function BuildFileList()
################# #################
# Check if bash # # Check if bash #
################# #################
if [[ "$GET_FILE_TYPE_CMD" == *"Bourne-Again shell script"* ]]; then if [[ $GET_FILE_TYPE_CMD == *"Bourne-Again shell script"* ]]; then
####################### #######################
# 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 #
@ -392,11 +394,11 @@ function BuildFileList()
# Set the READ_ONLY_CHANGE_FLAG since this could be exec # # Set the READ_ONLY_CHANGE_FLAG since this could be exec #
########################################################## ##########################################################
READ_ONLY_CHANGE_FLAG=1 READ_ONLY_CHANGE_FLAG=1
elif [[ "$GET_FILE_TYPE_CMD" == *"Ruby script"* ]]; then elif [[ $GET_FILE_TYPE_CMD == *"Ruby script"* ]]; then
####################### #######################
# 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 #
@ -410,7 +412,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 #
########################################################## ##########################################################
@ -424,7 +426,7 @@ function BuildFileList()
######################################### #########################################
# Need to switch back to branch of code # # Need to switch back to branch of code #
######################################### #########################################
SWITCH2_CMD=$(cd "$GITHUB_WORKSPACE" || exit; git checkout --progress --force "$GITHUB_SHA" 2>&1) SWITCH2_CMD=$(git -C "$GITHUB_WORKSPACE" checkout --progress --force "$GITHUB_SHA" 2>&1)
####################### #######################
# Load the error code # # Load the error code #
@ -437,7 +439,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
@ -446,5 +448,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)
@ -229,8 +231,7 @@ ERRORS_FOUND_OPENAPI=0 # Count of errors found
################################################################################ ################################################################################
################################################################################ ################################################################################
#### Function Header ########################################################### #### Function Header ###########################################################
Header() Header() {
{
############################### ###############################
# Give them the possum action # # Give them the possum action #
############################### ###############################
@ -251,8 +252,7 @@ Header()
} }
################################################################################ ################################################################################
#### Function GetLinterVersions ################################################ #### Function GetLinterVersions ################################################
GetLinterVersions() GetLinterVersions() {
{
######################### #########################
# Print version headers # # Print version headers #
######################### #########################
@ -263,8 +263,8 @@ GetLinterVersions()
########################################################## ##########################################################
# Go through the array of linters and print version info # # Go through the array of linters and print version info #
########################################################## ##########################################################
for LINTER in "${LINTER_ARRAY[@]}" for LINTER in "${LINTER_ARRAY[@]}"; do
do echo "[$LINTER]:"
################### ###################
# Get the version # # Get the version #
################### ###################
@ -287,7 +287,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 "[$LINTER]: WARN! Failed to get version info for:[$LINTER]" echo -e "${NC}${F[Y]}WARN!${NC} Failed to get version info for:[$LINTER]${NC}"
else else
########################## ##########################
# Print the version info # # Print the version info #
@ -303,54 +303,43 @@ GetLinterVersions()
} }
################################################################################ ################################################################################
#### Function GetLinterRules ################################################### #### Function GetLinterRules ###################################################
GetLinterRules() GetLinterRules() {
{
# Need to validate the rules files exist # Need to validate the rules files exist
################ ################
# Pull in vars # # Pull in vars #
################ ################
FILE_NAME="$1" # Name fo the linter file LANGUAGE_NAME="$1" # Name of the language were looking for
FILE_LOCATION="$2" # Location of the linter file
#######################################################
# Need to create the variables for the real variables #
#######################################################
LANGUAGE_FILE_NAME="${LANGUAGE_NAME}_FILE_NAME"
LANGUAGE_LINTER_RULES="${LANGUAGE_NAME}_LINTER_RULES"
##################################### #####################################
# Validate we have the linter rules # # Validate we have the linter rules #
##################################### #####################################
if [ -f "$GITHUB_WORKSPACE/$LINTER_RULES_PATH/$FILE_NAME" ]; then if [ -f "$GITHUB_WORKSPACE/$LINTER_RULES_PATH/${!LANGUAGE_FILE_NAME}" ]; then
echo "----------------------------------------------" echo "----------------------------------------------"
echo "User provided file:[$FILE_NAME], setting rules file..." echo "User provided file:[${!LANGUAGE_FILE_NAME}], setting rules file..."
#################################### ########################################
# Copy users into default location # # Update the path to the file location #
#################################### ########################################
CP_CMD=$(cp "$GITHUB_WORKSPACE/$LINTER_RULES_PATH/$FILE_NAME" "$FILE_LOCATION" 2>&1) declare -g "${LANGUAGE_LINTER_RULES}=$GITHUB_WORKSPACE/$LINTER_RULES_PATH/${!LANGUAGE_FILE_NAME}"
###################
# Load Error code #
###################
ERROR_CODE=$?
##############################
# Check the shell for errors #
##############################
if [ $ERROR_CODE -ne 0 ]; then
echo "ERROR! Failed to set file:[$FILE_NAME] as default!"
echo "ERROR:[$CP_CMD]"
exit 1
fi
else else
######################################################## ########################################################
# No user default provided, using the template default # # No user default provided, using the template default #
######################################################## ########################################################
if [[ "$ACTIONS_RUNNER_DEBUG" == "true" ]]; then if [[ $ACTIONS_RUNNER_DEBUG == "true" ]]; then
echo " -> Codebase does NOT have file:[$LINTER_RULES_PATH/$FILE_NAME], using Default rules at:[$FILE_LOCATION]" echo " -> Codebase does NOT have file:[$LINTER_RULES_PATH/${!LANGUAGE_FILE_NAME}], using Default rules at:[${!LANGUAGE_LINTER_RULES}]"
fi fi
fi fi
} }
################################################################################ ################################################################################
#### Function GetStandardRules ################################################# #### Function GetStandardRules #################################################
GetStandardRules() GetStandardRules() {
{
################ ################
# Pull In Vars # # Pull In Vars #
################ ################
@ -369,9 +358,9 @@ GetStandardRules()
######################################### #########################################
# Only env vars that are marked as true # Only env vars that are marked as true
GET_ENV_ARRAY=() GET_ENV_ARRAY=()
if [[ "$LINTER" == "javascript" ]]; then if [[ $LINTER == "javascript" ]]; then
mapfile -t GET_ENV_ARRAY < <(yq .env "$JAVASCRIPT_LINTER_RULES" | grep true) mapfile -t GET_ENV_ARRAY < <(yq .env "$JAVASCRIPT_LINTER_RULES" | grep true)
elif [[ "$LINTER" == "typescript" ]]; then elif [[ $LINTER == "typescript" ]]; then
mapfile -t GET_ENV_ARRAY < <(yq .env "$TYPESCRIPT_LINTER_RULES" | grep true) mapfile -t GET_ENV_ARRAY < <(yq .env "$TYPESCRIPT_LINTER_RULES" | grep true)
fi fi
@ -385,8 +374,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
@ -404,8 +393,7 @@ GetStandardRules()
############################# #############################
# Pull out the envs to load # # Pull out the envs to load #
############################# #############################
for ENV in "${GET_ENV_ARRAY[@]}" for ENV in "${GET_ENV_ARRAY[@]}"; do
do
############################# #############################
# remove spaces from return # # remove spaces from return #
############################# #############################
@ -421,16 +409,15 @@ GetStandardRules()
######################################### #########################################
# Remove trailing and ending whitespace # # Remove trailing and ending whitespace #
######################################### #########################################
if [[ "$LINTER" == "javascript" ]]; then if [[ $LINTER == "javascript" ]]; then
JAVASCRIPT_STANDARD_LINTER_RULES="$(echo -e "${ENV_STRING}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" JAVASCRIPT_STANDARD_LINTER_RULES="$(echo -e "${ENV_STRING}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
elif [[ "$LINTER" == "typescript" ]]; then elif [[ $LINTER == "typescript" ]]; then
TYPESCRIPT_STANDARD_LINTER_RULES="$(echo -e "${ENV_STRING}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" TYPESCRIPT_STANDARD_LINTER_RULES="$(echo -e "${ENV_STRING}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
fi fi
} }
################################################################################ ################################################################################
#### Function DetectOpenAPIFile ################################################ #### Function DetectOpenAPIFile ################################################
DetectOpenAPIFile() DetectOpenAPIFile() {
{
################ ################
# Pull in vars # # Pull in vars #
################ ################
@ -439,7 +426,7 @@ DetectOpenAPIFile()
############################### ###############################
# Check the file for keywords # # Check the file for keywords #
############################### ###############################
grep -E '"openapi":|"swagger":|^openapi:|^swagger:' "$GITHUB_WORKSPACE/$FILE" > /dev/null grep -E '"openapi":|"swagger":|^openapi:|^swagger:' "$FILE" > /dev/null
####################### #######################
# Load the error code # # Load the error code #
@ -497,8 +484,7 @@ DetectARMFile()
} }
################################################################################ ################################################################################
#### Function DetectCloudFormationFile ######################################### #### Function DetectCloudFormationFile #########################################
DetectCloudFormationFile() DetectCloudFormationFile() {
{
################ ################
# Pull in Vars # # Pull in Vars #
################ ################
@ -549,8 +535,7 @@ DetectCloudFormationFile()
################################################################################ ################################################################################
#### Function GetGitHubVars #################################################### #### Function GetGitHubVars ####################################################
GetGitHubVars() GetGitHubVars() {
{
########## ##########
# Prints # # Prints #
########## ##########
@ -590,7 +575,7 @@ GetGitHubVars()
################################# #################################
# Check if were running locally # # Check if were running locally #
################################# #################################
if [[ "$RUN_LOCAL" != "false" ]]; then if [[ $RUN_LOCAL != "false" ]]; then
########################################## ##########################################
# We are running locally for a debug run # # We are running locally for a debug run #
########################################## ##########################################
@ -611,7 +596,6 @@ GetGitHubVars()
# No need to touch or set the GITHUB_ORG # No need to touch or set the GITHUB_ORG
# No need to touch or set the GITHUB_REPO # No need to touch or set the GITHUB_REPO
################################# #################################
# Set the VALIDATE_ALL_CODEBASE # # Set the VALIDATE_ALL_CODEBASE #
################################# #################################
@ -621,33 +605,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
################################################## ##################################################
@ -663,11 +647,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
####################### #######################
@ -679,21 +663,20 @@ 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
} }
################################################################################ ################################################################################
#### Function ValidatePowershellModules ######################################## #### Function ValidatePowershellModules ########################################
function ValidatePowershellModules() function ValidatePowershellModules() {
{
VALIDATE_PSSA_MODULE=$(pwsh -c "(Get-Module -Name PSScriptAnalyzer -ListAvailable | Select-Object -First 1).Name" 2>&1) VALIDATE_PSSA_MODULE=$(pwsh -c "(Get-Module -Name PSScriptAnalyzer -ListAvailable | Select-Object -First 1).Name" 2>&1)
# If module found, ensure Invoke-ScriptAnalyzer command is available # If module found, ensure Invoke-ScriptAnalyzer command is available
if [[ "$VALIDATE_PSSA_MODULE" == "PSScriptAnalyzer" ]]; then if [[ $VALIDATE_PSSA_MODULE == "PSScriptAnalyzer" ]]; then
VALIDATE_PSSA_CMD=$(pwsh -c "(Get-Command Invoke-ScriptAnalyzer | Select-Object -First 1).Name" 2>&1) VALIDATE_PSSA_CMD=$(pwsh -c "(Get-Command Invoke-ScriptAnalyzer | Select-Object -First 1).Name" 2>&1)
else else
# Failed to find module # Failed to find module
@ -703,7 +686,7 @@ function ValidatePowershellModules()
######################################### #########################################
# validate we found the script analyzer # # validate we found the script analyzer #
######################################### #########################################
if [[ "$VALIDATE_PSSA_CMD" != "Invoke-ScriptAnalyzer" ]]; then if [[ $VALIDATE_PSSA_CMD != "Invoke-ScriptAnalyzer" ]]; then
# Failed to find module # Failed to find module
exit 1 exit 1
fi fi
@ -718,21 +701,20 @@ 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
} }
################################################################################ ################################################################################
#### Function Footer ########################################################### #### Function Footer ###########################################################
Footer() Footer() {
{
echo "" echo ""
echo "----------------------------------------------" echo "----------------------------------------------"
echo "----------------------------------------------" echo "----------------------------------------------"
@ -744,8 +726,7 @@ Footer()
############################## ##############################
# Prints for errors if found # # Prints for errors if found #
############################## ##############################
for LANGUAGE in "${LANGUAGE_ARRAY[@]}" for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do
do
########################### ###########################
# Build the error counter # # Build the error counter #
########################### ###########################
@ -756,7 +737,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
@ -764,47 +745,47 @@ 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 #
############################### ###############################
elif [ "$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 ] ||
[ "$ERRORS_FOUND_BASH" -ne 0 ] || \ [ "$ERRORS_FOUND_BASH" -ne 0 ] ||
[ "$ERRORS_FOUND_PERL" -ne 0 ] || \ [ "$ERRORS_FOUND_PERL" -ne 0 ] ||
[ "$ERRORS_FOUND_PHP" -ne 0 ] || \ [ "$ERRORS_FOUND_PHP" -ne 0 ] ||
[ "$ERRORS_FOUND_PYTHON" -ne 0 ] || \ [ "$ERRORS_FOUND_PYTHON" -ne 0 ] ||
[ "$ERRORS_FOUND_COFFEESCRIPT" -ne 0 ] || \ [ "$ERRORS_FOUND_COFFEESCRIPT" -ne 0 ] ||
[ "$ERRORS_FOUND_ANSIBLE" -ne 0 ] || \ [ "$ERRORS_FOUND_ANSIBLE" -ne 0 ] ||
[ "$ERRORS_FOUND_JAVASCRIPT_ES" -ne 0 ] || \ [ "$ERRORS_FOUND_JAVASCRIPT_ES" -ne 0 ] ||
[ "$ERRORS_FOUND_JAVASCRIPT_STANDARD" -ne 0 ] || \ [ "$ERRORS_FOUND_JAVASCRIPT_STANDARD" -ne 0 ] ||
[ "$ERRORS_FOUND_TYPESCRIPT_ES" -ne 0 ] || \ [ "$ERRORS_FOUND_TYPESCRIPT_ES" -ne 0 ] ||
[ "$ERRORS_FOUND_TYPESCRIPT_STANDARD" -ne 0 ] || \ [ "$ERRORS_FOUND_TYPESCRIPT_STANDARD" -ne 0 ] ||
[ "$ERRORS_FOUND_DOCKER" -ne 0 ] || \ [ "$ERRORS_FOUND_DOCKER" -ne 0 ] ||
[ "$ERRORS_FOUND_GO" -ne 0 ] || \ [ "$ERRORS_FOUND_GO" -ne 0 ] ||
[ "$ERRORS_FOUND_TERRAFORM" -ne 0 ] || \ [ "$ERRORS_FOUND_TERRAFORM" -ne 0 ] ||
[ "$ERRORS_FOUND_POWERSHELL" -ne 0 ] || \ [ "$ERRORS_FOUND_POWERSHELL" -ne 0 ] ||
[ "$ERRORS_FOUND_ARM" -ne 0 ] || \ [ "$ERRORS_FOUND_ARM" -ne 0 ] ||
[ "$ERRORS_FOUND_RUBY" -ne 0 ] || \ [ "$ERRORS_FOUND_RUBY" -ne 0 ] ||
[ "$ERRORS_FOUND_CSS" -ne 0 ] || \ [ "$ERRORS_FOUND_CSS" -ne 0 ] ||
[ "$ERRORS_FOUND_CFN" -ne 0 ] || \ [ "$ERRORS_FOUND_CFN" -ne 0 ] ||
[ "$ERRORS_FOUND_ENV" -ne 0 ] || \ [ "$ERRORS_FOUND_ENV" -ne 0 ] ||
[ "$ERRORS_FOUND_OPENAPI" -ne 0 ] || \ [ "$ERRORS_FOUND_OPENAPI" -ne 0 ] ||
[ "$ERRORS_FOUND_PROTOBUF" -ne 0 ] || \ [ "$ERRORS_FOUND_PROTOBUF" -ne 0 ] ||
[ "$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
@ -836,40 +817,40 @@ GetValidationInfo
# Get the linter rules # # Get the linter rules #
######################## ########################
# Get YML rules # Get YML rules
GetLinterRules "$YAML_FILE_NAME" "$YAML_LINTER_RULES" GetLinterRules "YAML"
# Get Markdown rules # Get Markdown rules
GetLinterRules "$MD_FILE_NAME" "$MD_LINTER_RULES" GetLinterRules "MD"
# Get Python rules # Get Python rules
GetLinterRules "$PYTHON_FILE_NAME" "$PYTHON_LINTER_RULES" GetLinterRules "PYTHON"
# Get Ruby rules # Get Ruby rules
GetLinterRules "$RUBY_FILE_NAME" "$RUBY_LINTER_RULES" GetLinterRules "RUBY"
# Get Coffeescript rules # Get Coffeescript rules
GetLinterRules "$COFFEE_FILE_NAME" "$COFFEESCRIPT_LINTER_RULES" GetLinterRules "COFFEESCRIPT"
# Get Ansible rules # Get Ansible rules
GetLinterRules "$ANSIBLE_FILE_NAME" "$ANSIBLE_LINTER_RULES" GetLinterRules "ANSIBLE"
# Get JavaScript rules # Get JavaScript rules
GetLinterRules "$JAVASCRIPT_FILE_NAME" "$JAVASCRIPT_LINTER_RULES" GetLinterRules "JAVASCRIPT"
# Get TypeScript rules # Get TypeScript rules
GetLinterRules "$TYPESCRIPT_FILE_NAME" "$TYPESCRIPT_LINTER_RULES" GetLinterRules "TYPESCRIPT"
# Get Golang rules # Get Golang rules
GetLinterRules "$GO_FILE_NAME" "$GO_LINTER_RULES" GetLinterRules "GO"
# Get Docker rules # Get Docker rules
GetLinterRules "$DOCKER_FILE_NAME" "$DOCKER_LINTER_RULES" GetLinterRules "DOCKER"
# Get Terraform rules # Get Terraform rules
GetLinterRules "$TERRAFORM_FILE_NAME" "$TERRAFORM_LINTER_RULES" GetLinterRules "TERRAFORM"
# Get PowerShell rules # Get PowerShell rules
GetLinterRules "$POWERSHELL_FILE_NAME" "$POWERSHELL_LINTER_RULES" GetLinterRules "POWERSHELL"
# Get ARM rules # Get ARM rules
GetLinterRules "$ARM_FILE_NAME" "$ARM_LINTER_RULES" GetLinterRules "ARM"
# Get CSS rules # Get CSS rules
GetLinterRules "$CSS_FILE_NAME" "$CSS_LINTER_RULES" GetLinterRules "CSS"
# Get CFN rules # Get CFN rules
GetLinterRules "$CFN_FILE_NAME" "$CFN_LINTER_RULES" GetLinterRules "CFN"
################################# #################################
# Check if were in verbose mode # # Check if were in verbose mode #
################################# #################################
if [[ "$ACTIONS_RUNNER_DEBUG" == "true" ]]; then if [[ $ACTIONS_RUNNER_DEBUG == "true" ]]; then
################################## ##################################
# Get and print all version info # # Get and print all version info #
################################## ##################################
@ -879,7 +860,7 @@ fi
########################################### ###########################################
# Check to see if this is a test case run # # Check to see if this is a test case run #
########################################### ###########################################
if [[ "$TEST_CASE_RUN" != "false" ]]; then if [[ $TEST_CASE_RUN != "false" ]]; then
########################### ###########################
# Run only the test cases # # Run only the test cases #
########################### ###########################
@ -949,7 +930,7 @@ if [ "$VALIDATE_BASH" == "true" ]; then
# Lint the bash files # # Lint the bash files #
####################### #######################
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
LintCodebase "BASH" "shellcheck" "shellcheck" ".*\.\(sh\)\$" "${FILE_ARRAY_BASH[@]}" LintCodebase "BASH" "shellcheck" "shellcheck --color" ".*\.\(sh\)\$" "${FILE_ARRAY_BASH[@]}"
fi fi
################## ##################
@ -1050,7 +1031,7 @@ if [ "$VALIDATE_ANSIBLE" == "true" ]; then
# Due to the nature of how we want to validate Ansible, we cannot use the # Due to the nature of how we want to validate Ansible, we cannot use the
# standard loop, since it looks for an ansible folder, excludes certain # standard loop, since it looks for an ansible folder, excludes certain
# files, and looks for additional changes, it should be an outlier # files, and looks for additional changes, it should be an outlier
LintAnsibleFiles LintAnsibleFiles "$ANSIBLE_LINTER_RULES" # Passing rules but not needed, dont want to exclude unused var
fi fi
###################### ######################
@ -1214,8 +1195,7 @@ if [ "$VALIDATE_OPENAPI" == "true" ]; then
IFS=$'\n' IFS=$'\n'
mapfile -t LIST_FILES < <(find "$GITHUB_WORKSPACE" -type f -regex ".*\.\(yml\|yaml\|json\)\$" 2>&1) mapfile -t LIST_FILES < <(find "$GITHUB_WORKSPACE" -type f -regex ".*\.\(yml\|yaml\|json\)\$" 2>&1)
for FILE in "${LIST_FILES[@]}" for FILE in "${LIST_FILES[@]}"; do
do
if DetectOpenAPIFile "$FILE"; then if DetectOpenAPIFile "$FILE"; then
FILE_ARRAY_OPENAPI+=("$FILE") FILE_ARRAY_OPENAPI+=("$FILE")
fi fi

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

@ -9,8 +9,7 @@
################################################################################ ################################################################################
################################################################################ ################################################################################
#### Function GetValidationInfo ################################################ #### Function GetValidationInfo ################################################
function GetValidationInfo() function GetValidationInfo() {
{
############################################ ############################################
# Print headers for user provided env vars # # Print headers for user provided env vars #
############################################ ############################################
@ -21,7 +20,7 @@ function GetValidationInfo()
########################################### ###########################################
# Skip validation if were running locally # # Skip validation if were running locally #
########################################### ###########################################
if [[ "$RUN_LOCAL" != "true" ]]; then if [[ $RUN_LOCAL != "true" ]]; then
############################### ###############################
# Convert string to lowercase # # Convert string to lowercase #
############################### ###############################
@ -29,7 +28,7 @@ function GetValidationInfo()
###################################### ######################################
# Validate we should check all files # # Validate we should check all files #
###################################### ######################################
if [[ "$VALIDATE_ALL_CODEBASE" != "false" ]]; then if [[ $VALIDATE_ALL_CODEBASE != "false" ]]; then
# Set to true # Set to true
VALIDATE_ALL_CODEBASE="$DEFAULT_VALIDATE_ALL_CODEBASE" VALIDATE_ALL_CODEBASE="$DEFAULT_VALIDATE_ALL_CODEBASE"
echo "- Validating ALL files in code base..." echo "- Validating ALL files in code base..."
@ -78,41 +77,41 @@ function GetValidationInfo()
# Determine if any linters were explicitly set # # Determine if any linters were explicitly set #
################################################ ################################################
ANY_SET="false" ANY_SET="false"
if [[ -n "$VALIDATE_YAML" || \ if [[ -n $VALIDATE_YAML || -n \
-n "$VALIDATE_JSON" || \ $VALIDATE_JSON || -n \
-n "$VALIDATE_XML" || \ $VALIDATE_XML || -n \
-n "$VALIDATE_MD" || \ $VALIDATE_MD || -n \
-n "$VALIDATE_BASH" || \ $VALIDATE_BASH || -n \
-n "$VALIDATE_PERL" || \ $VALIDATE_PERL || -n \
-n "$VALIDATE_PHP" || \ $VALIDATE_PHP || -n \
-n "$VALIDATE_PYTHON" || \ $VALIDATE_PYTHON || -n \
-n "$VALIDATE_RUBY" || \ $VALIDATE_RUBY || -n \
-n "$VALIDATE_COFFEE" || \ $VALIDATE_COFFEE || -n \
-n "$VALIDATE_ANSIBLE" || \ $VALIDATE_ANSIBLE || -n \
-n "$VALIDATE_JAVASCRIPT_ES" || \ $VALIDATE_JAVASCRIPT_ES || -n \
-n "$VALIDATE_JAVASCRIPT_STANDARD" || \ $VALIDATE_JAVASCRIPT_STANDARD || -n \
-n "$VALIDATE_TYPESCRIPT_ES" || \ $VALIDATE_TYPESCRIPT_ES || -n \
-n "$VALIDATE_TYPESCRIPT_STANDARD" || \ $VALIDATE_TYPESCRIPT_STANDARD || -n \
-n "$VALIDATE_DOCKER" || \ $VALIDATE_DOCKER || -n \
-n "$VALIDATE_GO" || \ $VALIDATE_GO || -n \
-n "$VALIDATE_TERRAFORM" || \ $VALIDATE_TERRAFORM || -n \
-n "$VALIDATE_POWERSHELL" || \ $VALIDATE_POWERSHELL || -n \
-n "$VALIDATE_ARM" || \ $VALIDATE_ARM || -n \
-n "$VALIDATE_CSS" || \ $VALIDATE_CSS || -n \
-n "$VALIDATE_ENV" || \ $VALIDATE_ENV || -n \
-n "$VALIDATE_CLOJURE" || \ $VALIDATE_CLOJURE || -n \
-n "$VALIDATE_PROTOBUF" || \ $VALIDATE_PROTOBUF || -n \
-n "$VALIDATE_OPENAPI" || \ $VALIDATE_OPENAPI || -n \
-n "$VALIDATE_KOTLIN" ]]; then $VALIDATE_KOTLIN ]]; then
ANY_SET="true" ANY_SET="true"
fi fi
#################################### ####################################
# Validate if we should check YAML # # Validate if we should check YAML #
#################################### ####################################
if [[ "$ANY_SET" == "true" ]]; then if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true # Some linter flags were set - only run those set to true
if [[ -z "$VALIDATE_YAML" ]]; then if [[ -z $VALIDATE_YAML ]]; then
# YAML flag was not set - default to false # YAML flag was not set - default to false
VALIDATE_YAML="false" VALIDATE_YAML="false"
fi fi
@ -124,9 +123,9 @@ function GetValidationInfo()
#################################### ####################################
# Validate if we should check JSON # # Validate if we should check JSON #
#################################### ####################################
if [[ "$ANY_SET" == "true" ]]; then if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true # Some linter flags were set - only run those set to true
if [[ -z "$VALIDATE_JSON" ]]; then if [[ -z $VALIDATE_JSON ]]; then
# JSON flag was not set - default to false # JSON flag was not set - default to false
VALIDATE_JSON="false" VALIDATE_JSON="false"
fi fi
@ -138,9 +137,9 @@ function GetValidationInfo()
################################### ###################################
# Validate if we should check XML # # Validate if we should check XML #
################################### ###################################
if [[ "$ANY_SET" == "true" ]]; then if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true # Some linter flags were set - only run those set to true
if [[ -z "$VALIDATE_XML" ]]; then if [[ -z $VALIDATE_XML ]]; then
# XML flag was not set - default to false # XML flag was not set - default to false
VALIDATE_XML="false" VALIDATE_XML="false"
fi fi
@ -152,9 +151,9 @@ function GetValidationInfo()
######################################## ########################################
# Validate if we should check MARKDOWN # # Validate if we should check MARKDOWN #
######################################## ########################################
if [[ "$ANY_SET" == "true" ]]; then if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true # Some linter flags were set - only run those set to true
if [[ -z "$VALIDATE_MD" ]]; then if [[ -z $VALIDATE_MD ]]; then
# MD flag was not set - default to false # MD flag was not set - default to false
VALIDATE_MD="false" VALIDATE_MD="false"
fi fi
@ -166,9 +165,9 @@ function GetValidationInfo()
#################################### ####################################
# Validate if we should check BASH # # Validate if we should check BASH #
#################################### ####################################
if [[ "$ANY_SET" == "true" ]]; then if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true # Some linter flags were set - only run those set to true
if [[ -z "$VALIDATE_BASH" ]]; then if [[ -z $VALIDATE_BASH ]]; then
# BASH flag was not set - default to false # BASH flag was not set - default to false
VALIDATE_BASH="false" VALIDATE_BASH="false"
fi fi
@ -180,9 +179,9 @@ function GetValidationInfo()
#################################### ####################################
# Validate if we should check PERL # # Validate if we should check PERL #
#################################### ####################################
if [[ "$ANY_SET" == "true" ]]; then if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true # Some linter flags were set - only run those set to true
if [[ -z "$VALIDATE_PERL" ]]; then if [[ -z $VALIDATE_PERL ]]; then
# PERL flag was not set - default to false # PERL flag was not set - default to false
VALIDATE_PERL="false" VALIDATE_PERL="false"
fi fi
@ -194,9 +193,9 @@ function GetValidationInfo()
#################################### ####################################
# Validate if we should check PHP # # Validate if we should check PHP #
#################################### ####################################
if [[ "$ANY_SET" == "true" ]]; then if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true # Some linter flags were set - only run those set to true
if [[ -z "$VALIDATE_PHP" ]]; then if [[ -z $VALIDATE_PHP ]]; then
# PHP flag was not set - default to false # PHP flag was not set - default to false
VALIDATE_PHP="false" VALIDATE_PHP="false"
fi fi
@ -208,9 +207,9 @@ function GetValidationInfo()
###################################### ######################################
# Validate if we should check PYTHON # # Validate if we should check PYTHON #
###################################### ######################################
if [[ "$ANY_SET" == "true" ]]; then if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true # Some linter flags were set - only run those set to true
if [[ -z "$VALIDATE_PYTHON" ]]; then if [[ -z $VALIDATE_PYTHON ]]; then
# PYTHON flag was not set - default to false # PYTHON flag was not set - default to false
VALIDATE_PYTHON="false" VALIDATE_PYTHON="false"
fi fi
@ -222,9 +221,9 @@ function GetValidationInfo()
#################################### ####################################
# Validate if we should check RUBY # # Validate if we should check RUBY #
#################################### ####################################
if [[ "$ANY_SET" == "true" ]]; then if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true # Some linter flags were set - only run those set to true
if [[ -z "$VALIDATE_RUBY" ]]; then if [[ -z $VALIDATE_RUBY ]]; then
# RUBY flag was not set - default to false # RUBY flag was not set - default to false
VALIDATE_RUBY="false" VALIDATE_RUBY="false"
fi fi
@ -236,9 +235,9 @@ function GetValidationInfo()
###################################### ######################################
# Validate if we should check COFFEE # # Validate if we should check COFFEE #
###################################### ######################################
if [[ "$ANY_SET" == "true" ]]; then if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true # Some linter flags were set - only run those set to true
if [[ -z "$VALIDATE_COFFEE" ]]; then if [[ -z $VALIDATE_COFFEE ]]; then
# COFFEE flag was not set - default to false # COFFEE flag was not set - default to false
VALIDATE_COFFEE="false" VALIDATE_COFFEE="false"
fi fi
@ -250,9 +249,9 @@ function GetValidationInfo()
####################################### #######################################
# Validate if we should check ANSIBLE # # Validate if we should check ANSIBLE #
####################################### #######################################
if [[ "$ANY_SET" == "true" ]]; then if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true # Some linter flags were set - only run those set to true
if [[ -z "$VALIDATE_ANSIBLE" ]]; then if [[ -z $VALIDATE_ANSIBLE ]]; then
# ANSIBLE flag was not set - default to false # ANSIBLE flag was not set - default to false
VALIDATE_ANSIBLE="false" VALIDATE_ANSIBLE="false"
fi fi
@ -264,9 +263,9 @@ function GetValidationInfo()
############################################# #############################################
# Validate if we should check JAVASCRIPT_ES # # Validate if we should check JAVASCRIPT_ES #
############################################# #############################################
if [[ "$ANY_SET" == "true" ]]; then if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true # Some linter flags were set - only run those set to true
if [[ -z "$VALIDATE_JAVASCRIPT_ES" ]]; then if [[ -z $VALIDATE_JAVASCRIPT_ES ]]; then
# JAVASCRIPT_ES flag was not set - default to false # JAVASCRIPT_ES flag was not set - default to false
VALIDATE_JAVASCRIPT_ES="false" VALIDATE_JAVASCRIPT_ES="false"
fi fi
@ -278,9 +277,9 @@ function GetValidationInfo()
################################################### ###################################################
# Validate if we should check JAVASCRIPT_STANDARD # # Validate if we should check JAVASCRIPT_STANDARD #
################################################### ###################################################
if [[ "$ANY_SET" == "true" ]]; then if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true # Some linter flags were set - only run those set to true
if [[ -z "$VALIDATE_JAVASCRIPT_STANDARD" ]]; then if [[ -z $VALIDATE_JAVASCRIPT_STANDARD ]]; then
# JAVASCRIPT_STANDARD flag was not set - default to false # JAVASCRIPT_STANDARD flag was not set - default to false
VALIDATE_JAVASCRIPT_STANDARD="false" VALIDATE_JAVASCRIPT_STANDARD="false"
fi fi
@ -292,9 +291,9 @@ function GetValidationInfo()
############################################# #############################################
# Validate if we should check TYPESCRIPT_ES # # Validate if we should check TYPESCRIPT_ES #
############################################# #############################################
if [[ "$ANY_SET" == "true" ]]; then if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true # Some linter flags were set - only run those set to true
if [[ -z "$VALIDATE_TYPESCRIPT_ES" ]]; then if [[ -z $VALIDATE_TYPESCRIPT_ES ]]; then
# TYPESCRIPT_ES flag was not set - default to false # TYPESCRIPT_ES flag was not set - default to false
VALIDATE_TYPESCRIPT_ES="false" VALIDATE_TYPESCRIPT_ES="false"
fi fi
@ -306,9 +305,9 @@ function GetValidationInfo()
################################################### ###################################################
# Validate if we should check TYPESCRIPT_STANDARD # # Validate if we should check TYPESCRIPT_STANDARD #
################################################### ###################################################
if [[ "$ANY_SET" == "true" ]]; then if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true # Some linter flags were set - only run those set to true
if [[ -z "$VALIDATE_TYPESCRIPT_STANDARD" ]]; then if [[ -z $VALIDATE_TYPESCRIPT_STANDARD ]]; then
# TYPESCRIPT_STANDARD flag was not set - default to false # TYPESCRIPT_STANDARD flag was not set - default to false
VALIDATE_TYPESCRIPT_STANDARD="false" VALIDATE_TYPESCRIPT_STANDARD="false"
fi fi
@ -320,9 +319,9 @@ function GetValidationInfo()
###################################### ######################################
# Validate if we should check DOCKER # # Validate if we should check DOCKER #
###################################### ######################################
if [[ "$ANY_SET" == "true" ]]; then if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true # Some linter flags were set - only run those set to true
if [[ -z "$VALIDATE_DOCKER" ]]; then if [[ -z $VALIDATE_DOCKER ]]; then
# DOCKER flag was not set - default to false # DOCKER flag was not set - default to false
VALIDATE_DOCKER="false" VALIDATE_DOCKER="false"
fi fi
@ -334,9 +333,9 @@ function GetValidationInfo()
################################## ##################################
# Validate if we should check GO # # Validate if we should check GO #
################################## ##################################
if [[ "$ANY_SET" == "true" ]]; then if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true # Some linter flags were set - only run those set to true
if [[ -z "$VALIDATE_GO" ]]; then if [[ -z $VALIDATE_GO ]]; then
# GO flag was not set - default to false # GO flag was not set - default to false
VALIDATE_GO="false" VALIDATE_GO="false"
fi fi
@ -348,9 +347,9 @@ function GetValidationInfo()
######################################### #########################################
# Validate if we should check TERRAFORM # # Validate if we should check TERRAFORM #
######################################### #########################################
if [[ "$ANY_SET" == "true" ]]; then if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true # Some linter flags were set - only run those set to true
if [[ -z "$VALIDATE_TERRAFORM" ]]; then if [[ -z $VALIDATE_TERRAFORM ]]; then
# TERRAFORM flag was not set - default to false # TERRAFORM flag was not set - default to false
VALIDATE_TERRAFORM="false" VALIDATE_TERRAFORM="false"
fi fi
@ -362,9 +361,9 @@ function GetValidationInfo()
######################################### #########################################
# Validate if we should check POWERSHELL # # Validate if we should check POWERSHELL #
######################################### #########################################
if [[ "$ANY_SET" == "true" ]]; then if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true # Some linter flags were set - only run those set to true
if [[ -z "$VALIDATE_POWERSHELL" ]]; then if [[ -z $VALIDATE_POWERSHELL ]]; then
# POWERSHELL flag was not set - default to false # POWERSHELL flag was not set - default to false
VALIDATE_POWERSHELL="false" VALIDATE_POWERSHELL="false"
fi fi
@ -390,9 +389,9 @@ function GetValidationInfo()
################################### ###################################
# Validate if we should check CSS # # Validate if we should check CSS #
################################### ###################################
if [[ "$ANY_SET" == "true" ]]; then if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true # Some linter flags were set - only run those set to true
if [[ -z "$VALIDATE_CSS" ]]; then if [[ -z $VALIDATE_CSS ]]; then
# CSS flag was not set - default to false # CSS flag was not set - default to false
VALIDATE_CSS="false" VALIDATE_CSS="false"
fi fi
@ -404,9 +403,9 @@ function GetValidationInfo()
################################### ###################################
# Validate if we should check ENV # # Validate if we should check ENV #
################################### ###################################
if [[ "$ANY_SET" == "true" ]]; then if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true # Some linter flags were set - only run those set to true
if [[ -z "$VALIDATE_ENV" ]]; then if [[ -z $VALIDATE_ENV ]]; then
# ENV flag was not set - default to false # ENV flag was not set - default to false
VALIDATE_ENV="false" VALIDATE_ENV="false"
fi fi
@ -418,9 +417,9 @@ function GetValidationInfo()
###################################### ######################################
# Validate if we should check KOTLIN # # Validate if we should check KOTLIN #
###################################### ######################################
if [[ "$ANY_SET" == "true" ]]; then if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true # Some linter flags were set - only run those set to true
if [[ -z "$VALIDATE_KOTLIN" ]]; then if [[ -z $VALIDATE_KOTLIN ]]; then
# ENV flag was not set - default to false # ENV flag was not set - default to false
VALIDATE_KOTLIN="false" VALIDATE_KOTLIN="false"
fi fi
@ -432,9 +431,9 @@ function GetValidationInfo()
####################################### #######################################
# Validate if we should check OPENAPI # # Validate if we should check OPENAPI #
####################################### #######################################
if [[ "$ANY_SET" == "true" ]]; then if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true # Some linter flags were set - only run those set to true
if [[ -z "$VALIDATE_OPENAPI" ]]; then if [[ -z $VALIDATE_OPENAPI ]]; then
# OPENAPI flag was not set - default to false # OPENAPI flag was not set - default to false
VALIDATE_OPENAPI="false" VALIDATE_OPENAPI="false"
fi fi
@ -446,9 +445,9 @@ function GetValidationInfo()
####################################### #######################################
# Validate if we should check PROTOBUF # # Validate if we should check PROTOBUF #
####################################### #######################################
if [[ "$ANY_SET" == "true" ]]; then if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true # Some linter flags were set - only run those set to true
if [[ -z "$VALIDATE_PROTOBUF" ]]; then if [[ -z $VALIDATE_PROTOBUF ]]; then
# PROTOBUF flag was not set - default to false # PROTOBUF flag was not set - default to false
VALIDATE_PROTOBUF="false" VALIDATE_PROTOBUF="false"
fi fi
@ -460,9 +459,9 @@ function GetValidationInfo()
####################################### #######################################
# Validate if we should check Clojure # # Validate if we should check Clojure #
####################################### #######################################
if [[ "$ANY_SET" == "true" ]]; then if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true # Some linter flags were set - only run those set to true
if [[ -z "$VALIDATE_CLOJURE" ]]; then if [[ -z $VALIDATE_CLOJURE ]]; then
# Clojure flag was not set - default to false # Clojure flag was not set - default to false
VALIDATE_CLOJURE="false" VALIDATE_CLOJURE="false"
fi fi
@ -474,132 +473,132 @@ function GetValidationInfo()
####################################### #######################################
# Print which linters we are enabling # # Print which linters we are enabling #
####################################### #######################################
if [[ "$VALIDATE_YAML" == "true" ]]; then if [[ $VALIDATE_YAML == "true" ]]; then
PRINT_ARRAY+=("- Validating [YAML] files in code base...") PRINT_ARRAY+=("- Validating [YAML] files in code base...")
else else
PRINT_ARRAY+=("- Excluding [YAML] files in code base...") PRINT_ARRAY+=("- Excluding [YAML] files in code base...")
fi fi
if [[ "$VALIDATE_JSON" == "true" ]]; then if [[ $VALIDATE_JSON == "true" ]]; then
PRINT_ARRAY+=("- Validating [JSON] files in code base...") PRINT_ARRAY+=("- Validating [JSON] files in code base...")
else else
PRINT_ARRAY+=("- Excluding [JSON] files in code base...") PRINT_ARRAY+=("- Excluding [JSON] files in code base...")
fi fi
if [[ "$VALIDATE_XML" == "true" ]]; then if [[ $VALIDATE_XML == "true" ]]; then
PRINT_ARRAY+=("- Validating [XML] files in code base...") PRINT_ARRAY+=("- Validating [XML] files in code base...")
else else
PRINT_ARRAY+=("- Excluding [XML] files in code base...") PRINT_ARRAY+=("- Excluding [XML] files in code base...")
fi fi
if [[ "$VALIDATE_MD" == "true" ]]; then if [[ $VALIDATE_MD == "true" ]]; then
PRINT_ARRAY+=("- Validating [MARKDOWN] files in code base...") PRINT_ARRAY+=("- Validating [MARKDOWN] files in code base...")
else else
PRINT_ARRAY+=("- Excluding [MARKDOWN] files in code base...") PRINT_ARRAY+=("- Excluding [MARKDOWN] files in code base...")
fi fi
if [[ "$VALIDATE_BASH" == "true" ]]; then if [[ $VALIDATE_BASH == "true" ]]; then
PRINT_ARRAY+=("- Validating [BASH] files in code base...") PRINT_ARRAY+=("- Validating [BASH] files in code base...")
else else
PRINT_ARRAY+=("- Excluding [BASH] files in code base...") PRINT_ARRAY+=("- Excluding [BASH] files in code base...")
fi fi
if [[ "$VALIDATE_PERL" == "true" ]]; then if [[ $VALIDATE_PERL == "true" ]]; then
PRINT_ARRAY+=("- Validating [PERL] files in code base...") PRINT_ARRAY+=("- Validating [PERL] files in code base...")
else else
PRINT_ARRAY+=("- Excluding [PERL] files in code base...") PRINT_ARRAY+=("- Excluding [PERL] files in code base...")
fi fi
if [[ "$VALIDATE_PHP" == "true" ]]; then if [[ $VALIDATE_PHP == "true" ]]; then
PRINT_ARRAY+=("- Validating [PHP] files in code base...") PRINT_ARRAY+=("- Validating [PHP] files in code base...")
else else
PRINT_ARRAY+=("- Excluding [PHP] files in code base...") PRINT_ARRAY+=("- Excluding [PHP] files in code base...")
fi fi
if [[ "$VALIDATE_PYTHON" == "true" ]]; then if [[ $VALIDATE_PYTHON == "true" ]]; then
PRINT_ARRAY+=("- Validating [PYTHON] files in code base...") PRINT_ARRAY+=("- Validating [PYTHON] files in code base...")
else else
PRINT_ARRAY+=("- Excluding [PYTHON] files in code base...") PRINT_ARRAY+=("- Excluding [PYTHON] files in code base...")
fi fi
if [[ "$VALIDATE_RUBY" == "true" ]]; then if [[ $VALIDATE_RUBY == "true" ]]; then
PRINT_ARRAY+=("- Validating [RUBY] files in code base...") PRINT_ARRAY+=("- Validating [RUBY] files in code base...")
else else
PRINT_ARRAY+=("- Excluding [RUBY] files in code base...") PRINT_ARRAY+=("- Excluding [RUBY] files in code base...")
fi fi
if [[ "$VALIDATE_COFFEE" == "true" ]]; then if [[ $VALIDATE_COFFEE == "true" ]]; then
PRINT_ARRAY+=("- Validating [COFFEE] files in code base...") PRINT_ARRAY+=("- Validating [COFFEE] files in code base...")
else else
PRINT_ARRAY+=("- Excluding [COFFEE] files in code base...") PRINT_ARRAY+=("- Excluding [COFFEE] files in code base...")
fi fi
if [[ "$VALIDATE_ANSIBLE" == "true" ]]; then if [[ $VALIDATE_ANSIBLE == "true" ]]; then
PRINT_ARRAY+=("- Validating [ANSIBLE] files in code base...") PRINT_ARRAY+=("- Validating [ANSIBLE] files in code base...")
else else
PRINT_ARRAY+=("- Excluding [ANSIBLE] files in code base...") PRINT_ARRAY+=("- Excluding [ANSIBLE] files in code base...")
fi fi
if [[ "$VALIDATE_JAVASCRIPT_ES" == "true" ]]; then if [[ $VALIDATE_JAVASCRIPT_ES == "true" ]]; then
PRINT_ARRAY+=("- Validating [JAVASCRIPT(eslint)] files in code base...") PRINT_ARRAY+=("- Validating [JAVASCRIPT(eslint)] files in code base...")
else else
PRINT_ARRAY+=("- Excluding [JAVASCRIPT(eslint)] files in code base...") PRINT_ARRAY+=("- Excluding [JAVASCRIPT(eslint)] files in code base...")
fi fi
if [[ "$VALIDATE_JAVASCRIPT_STANDARD" == "true" ]]; then if [[ $VALIDATE_JAVASCRIPT_STANDARD == "true" ]]; then
PRINT_ARRAY+=("- Validating [JAVASCRIPT(standard)] files in code base...") PRINT_ARRAY+=("- Validating [JAVASCRIPT(standard)] files in code base...")
else else
PRINT_ARRAY+=("- Excluding [JAVASCRIPT(standard)] files in code base...") PRINT_ARRAY+=("- Excluding [JAVASCRIPT(standard)] files in code base...")
fi fi
if [[ "$VALIDATE_TYPESCRIPT_ES" == "true" ]]; then if [[ $VALIDATE_TYPESCRIPT_ES == "true" ]]; then
PRINT_ARRAY+=("- Validating [TYPESCRIPT(eslint)] files in code base...") PRINT_ARRAY+=("- Validating [TYPESCRIPT(eslint)] files in code base...")
else else
PRINT_ARRAY+=("- Excluding [TYPESCRIPT(eslint)] files in code base...") PRINT_ARRAY+=("- Excluding [TYPESCRIPT(eslint)] files in code base...")
fi fi
if [[ "$VALIDATE_TYPESCRIPT_STANDARD" == "true" ]]; then if [[ $VALIDATE_TYPESCRIPT_STANDARD == "true" ]]; then
PRINT_ARRAY+=("- Validating [TYPESCRIPT(standard)] files in code base...") PRINT_ARRAY+=("- Validating [TYPESCRIPT(standard)] files in code base...")
else else
PRINT_ARRAY+=("- Excluding [TYPESCRIPT(standard)] files in code base...") PRINT_ARRAY+=("- Excluding [TYPESCRIPT(standard)] files in code base...")
fi fi
if [[ "$VALIDATE_DOCKER" == "true" ]]; then if [[ $VALIDATE_DOCKER == "true" ]]; then
PRINT_ARRAY+=("- Validating [DOCKER] files in code base...") PRINT_ARRAY+=("- Validating [DOCKER] files in code base...")
else else
PRINT_ARRAY+=("- Excluding [DOCKER] files in code base...") PRINT_ARRAY+=("- Excluding [DOCKER] files in code base...")
fi fi
if [[ "$VALIDATE_GO" == "true" ]]; then if [[ $VALIDATE_GO == "true" ]]; then
PRINT_ARRAY+=("- Validating [GOLANG] files in code base...") PRINT_ARRAY+=("- Validating [GOLANG] files in code base...")
else else
PRINT_ARRAY+=("- Excluding [GOLANG] files in code base...") PRINT_ARRAY+=("- Excluding [GOLANG] files in code base...")
fi fi
if [[ "$VALIDATE_TERRAFORM" == "true" ]]; then if [[ $VALIDATE_TERRAFORM == "true" ]]; then
PRINT_ARRAY+=("- Validating [TERRAFORM] files in code base...") PRINT_ARRAY+=("- Validating [TERRAFORM] files in code base...")
else else
PRINT_ARRAY+=("- Excluding [TERRAFORM] files in code base...") PRINT_ARRAY+=("- Excluding [TERRAFORM] files in code base...")
fi fi
if [[ "$VALIDATE_POWERSHELL" == "true" ]]; then if [[ $VALIDATE_POWERSHELL == "true" ]]; then
PRINT_ARRAY+=("- Validating [POWERSHELL] files in code base...") PRINT_ARRAY+=("- Validating [POWERSHELL] files in code base...")
else else
PRINT_ARRAY+=("- Excluding [POWERSHELL] files in code base...") PRINT_ARRAY+=("- Excluding [POWERSHELL] files in code base...")
fi fi
if [[ "$VALIDATE_ARM" == "true" ]]; then if [[ $VALIDATE_ARM == "true" ]]; then
PRINT_ARRAY+=("- Validating [ARM] files in code base...") PRINT_ARRAY+=("- Validating [ARM] files in code base...")
else else
PRINT_ARRAY+=("- Excluding [ARM] files in code base...") PRINT_ARRAY+=("- Excluding [ARM] files in code base...")
fi fi
if [[ "$VALIDATE_CSS" == "true" ]]; then if [[ $VALIDATE_CSS == "true" ]]; then
PRINT_ARRAY+=("- Validating [CSS] files in code base...") PRINT_ARRAY+=("- Validating [CSS] files in code base...")
else else
PRINT_ARRAY+=("- Excluding [CSS] files in code base...") PRINT_ARRAY+=("- Excluding [CSS] files in code base...")
fi fi
if [[ "$VALIDATE_CLOJURE" == "true" ]]; then if [[ $VALIDATE_CLOJURE == "true" ]]; then
PRINT_ARRAY+=("- Validating [CLOJURE] files in code base...") PRINT_ARRAY+=("- Validating [CLOJURE] files in code base...")
else else
PRINT_ARRAY+=("- Excluding [CLOJURE] files in code base...") PRINT_ARRAY+=("- Excluding [CLOJURE] files in code base...")
fi fi
if [[ "$VALIDATE_ENV" == "true" ]]; then if [[ $VALIDATE_ENV == "true" ]]; then
PRINT_ARRAY+=("- Validating [ENV] files in code base...") PRINT_ARRAY+=("- Validating [ENV] files in code base...")
else else
PRINT_ARRAY+=("- Excluding [ENV] files in code base...") PRINT_ARRAY+=("- Excluding [ENV] files in code base...")
fi fi
if [[ "$VALIDATE_KOTLIN" == "true" ]]; then if [[ $VALIDATE_KOTLIN == "true" ]]; then
PRINT_ARRAY+=("- Validating [KOTLIN] files in code base...") PRINT_ARRAY+=("- Validating [KOTLIN] files in code base...")
else else
PRINT_ARRAY+=("- Excluding [KOTLIN] files in code base...") PRINT_ARRAY+=("- Excluding [KOTLIN] files in code base...")
fi fi
if [[ "$VALIDATE_OPENAPI" == "true" ]]; then if [[ $VALIDATE_OPENAPI == "true" ]]; then
PRINT_ARRAY+=("- Validating [OPENAPI] files in code base...") PRINT_ARRAY+=("- Validating [OPENAPI] files in code base...")
else else
PRINT_ARRAY+=("- Excluding [OPENAPI] files in code base...") PRINT_ARRAY+=("- Excluding [OPENAPI] files in code base...")
fi fi
if [[ "$VALIDATE_PROTOBUF" == "true" ]]; then if [[ $VALIDATE_PROTOBUF == "true" ]]; then
PRINT_ARRAY+=("- Validating [PROTOBUF] files in code base...") PRINT_ARRAY+=("- Validating [PROTOBUF] files in code base...")
else else
PRINT_ARRAY+=("- Excluding [PROTOBUF] files in code base...") PRINT_ARRAY+=("- Excluding [PROTOBUF] files in code base...")
@ -670,12 +669,11 @@ function GetValidationInfo()
################### ###################
# Debug on runner # # Debug on runner #
################### ###################
if [[ "$ACTIONS_RUNNER_DEBUG" == "true" ]]; then if [[ $ACTIONS_RUNNER_DEBUG == "true" ]]; then
########################### ###########################
# Print the validate info # # Print the validate info #
########################### ###########################
for LINE in "${PRINT_ARRAY[@]}" for LINE in "${PRINT_ARRAY[@]}"; do
do
echo "$LINE" echo "$LINE"
done done

View file

@ -9,8 +9,7 @@
################################################################################ ################################################################################
################################################################################ ################################################################################
#### Function LintCodebase ##################################################### #### Function LintCodebase #####################################################
function LintCodebase() function LintCodebase() {
{
#################### ####################
# Pull in the vars # # Pull in the vars #
#################### ####################
@ -50,13 +49,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
@ -119,8 +118,7 @@ function LintCodebase()
###################### ######################
# Print Header array # # Print Header array #
###################### ######################
for LINE in "${PRINT_ARRAY[@]}" for LINE in "${PRINT_ARRAY[@]}"; do
do
######################### #########################
# Print the header info # # Print the header info #
######################### #########################
@ -130,8 +128,7 @@ function LintCodebase()
################## ##################
# Lint the files # # Lint the files #
################## ##################
for FILE in "${LIST_FILES[@]}" for FILE in "${LIST_FILES[@]}"; do
do
##################### #####################
# Get the file name # # Get the file name #
##################### #####################
@ -164,17 +161,24 @@ function LintCodebase()
# - PowerShell (PSScriptAnalyzer) # # - PowerShell (PSScriptAnalyzer) #
# - ARM (arm-ttk) # # - ARM (arm-ttk) #
#################################### ####################################
if [[ "$FILE_TYPE" == "POWERSHELL" ]] || [[ "$FILE_TYPE" == "ARM" ]]; then if [[ $FILE_TYPE == "POWERSHELL" ]] || [[ $FILE_TYPE == "ARM" ]]; then
################################ ################################
# Lint the file with the rules # # Lint the file with the rules #
################################ ################################
# Need to run PowerShell commands using pwsh -c, also exit with exit code from inner subshell # Need to run PowerShell commands using pwsh -c, also exit with exit code from inner subshell
LINT_CMD=$(cd "$GITHUB_WORKSPACE" || exit; pwsh -NoProfile -NoLogo -Command "$LINTER_COMMAND $FILE; if (\$Error.Count) { exit 1 }"; exit $? 2>&1) LINT_CMD=$(
cd "$GITHUB_WORKSPACE" || exit
pwsh -NoProfile -NoLogo -Command "$LINTER_COMMAND $FILE; if (\$Error.Count) { exit 1 }"
exit $? 2>&1
)
else else
################################ ################################
# Lint the file with the rules # # Lint the file with the rules #
################################ ################################
LINT_CMD=$(cd "$GITHUB_WORKSPACE" || exit; $LINTER_COMMAND "$FILE" 2>&1) LINT_CMD=$(
cd "$GITHUB_WORKSPACE" || exit
$LINTER_COMMAND "$FILE" 2>&1
)
fi fi
####################### #######################
@ -189,23 +193,22 @@ 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
} }
################################################################################ ################################################################################
#### Function TestCodebase ##################################################### #### Function TestCodebase #####################################################
function TestCodebase() function TestCodebase() {
{
#################### ####################
# Pull in the vars # # Pull in the vars #
#################### ####################
@ -242,12 +245,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
@ -264,8 +267,7 @@ function TestCodebase()
################## ##################
# Lint the files # # Lint the files #
################## ##################
for FILE in "${LIST_FILES[@]}" for FILE in "${LIST_FILES[@]}"; do
do
##################### #####################
# Get the file name # # Get the file name #
##################### #####################
@ -280,7 +282,7 @@ function TestCodebase()
######################################################### #########################################################
# If not found, assume it should be linted successfully # # If not found, assume it should be linted successfully #
######################################################### #########################################################
if [ -z "$FILE_STATUS" ] || [[ "$FILE" == *"README"* ]]; then if [ -z "$FILE_STATUS" ] || [[ $FILE == *"README"* ]]; then
################################## ##################################
# Set to good for proper linting # # Set to good for proper linting #
################################## ##################################
@ -301,8 +303,8 @@ function TestCodebase()
####################################### #######################################
# Check if docker and get folder name # # Check if docker and get folder name #
####################################### #######################################
if [[ "$FILE_TYPE" == "DOCKER" ]]; then if [[ $FILE_TYPE == "DOCKER" ]]; then
if [[ "$FILE" == *"good"* ]]; then if [[ $FILE == *"good"* ]]; then
############# #############
# Good file # # Good file #
############# #############
@ -318,7 +320,7 @@ function TestCodebase()
##################### #####################
# Check for ansible # # Check for ansible #
##################### #####################
if [[ "$FILE_TYPE" == "ANSIBLE" ]]; then if [[ $FILE_TYPE == "ANSIBLE" ]]; then
######################################## ########################################
# Make sure we dont lint certain files # # Make sure we dont lint certain files #
######################################## ########################################
@ -330,18 +332,28 @@ function TestCodebase()
################################ ################################
# Lint the file with the rules # # Lint the file with the rules #
################################ ################################
LINT_CMD=$(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER/$INDVIDUAL_TEST_FOLDER" || exit; $LINTER_COMMAND "$FILE" 2>&1) LINT_CMD=$(
elif [[ "$FILE_TYPE" == "POWERSHELL" ]]; then cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER/$INDVIDUAL_TEST_FOLDER" || exit
$LINTER_COMMAND "$FILE" 2>&1
)
elif [[ $FILE_TYPE == "POWERSHELL" ]]; then
################################ ################################
# Lint the file with the rules # # Lint the file with the rules #
################################ ################################
# Need to run PowerShell commands using pwsh -c, also exit with exit code from inner subshell # Need to run PowerShell commands using pwsh -c, also exit with exit code from inner subshell
LINT_CMD=$(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; pwsh -c "($LINTER_COMMAND $FILE)"; exit $? 2>&1) LINT_CMD=$(
cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit
pwsh -c "($LINTER_COMMAND $FILE)"
exit $? 2>&1
)
else else
################################ ################################
# Lint the file with the rules # # Lint the file with the rules #
################################ ################################
LINT_CMD=$(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; $LINTER_COMMAND "$FILE" 2>&1) LINT_CMD=$(
cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit
$LINTER_COMMAND "$FILE" 2>&1
)
fi fi
####################### #######################
@ -352,7 +364,7 @@ function TestCodebase()
######################################## ########################################
# Check for if it was supposed to pass # # Check for if it was supposed to pass #
######################################## ########################################
if [[ "$FILE_STATUS" == "good" ]]; then if [[ $FILE_STATUS == "good" ]]; then
############################## ##############################
# Check the shell for errors # # Check the shell for errors #
############################## ##############################
@ -360,9 +372,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
@ -371,7 +383,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
@ -386,10 +398,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
@ -398,7 +410,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
@ -412,15 +424,14 @@ 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
} }
################################################################################ ################################################################################
#### Function RunTestCases ##################################################### #### Function RunTestCases #####################################################
function RunTestCases() function RunTestCases() {
{
# This loop will run the test cases and exclude user code # This loop will run the test cases and exclude user code
# This is called from the automation process to validate new code # This is called from the automation process to validate new code
# When a PR is opened, the new code is validated with the default branch # When a PR is opened, the new code is validated with the default branch
@ -446,7 +457,7 @@ function RunTestCases()
TestCodebase "JSON" "jsonlint" "jsonlint" ".*\.\(json\)\$" "json" TestCodebase "JSON" "jsonlint" "jsonlint" ".*\.\(json\)\$" "json"
TestCodebase "XML" "xmllint" "xmllint" ".*\.\(xml\)\$" "xml" TestCodebase "XML" "xmllint" "xmllint" ".*\.\(xml\)\$" "xml"
TestCodebase "MARKDOWN" "markdownlint" "markdownlint -c $MD_LINTER_RULES" ".*\.\(md\)\$" "markdown" TestCodebase "MARKDOWN" "markdownlint" "markdownlint -c $MD_LINTER_RULES" ".*\.\(md\)\$" "markdown"
TestCodebase "BASH" "shellcheck" "shellcheck" ".*\.\(sh\)\$" "shell" TestCodebase "BASH" "shellcheck" "shellcheck --color" ".*\.\(sh\)\$" "shell"
TestCodebase "PYTHON" "pylint" "pylint --rcfile $PYTHON_LINTER_RULES" ".*\.\(py\)\$" "python" TestCodebase "PYTHON" "pylint" "pylint --rcfile $PYTHON_LINTER_RULES" ".*\.\(py\)\$" "python"
TestCodebase "PERL" "perl" "perl -Mstrict -cw" ".*\.\(pl\)\$" "perl" TestCodebase "PERL" "perl" "perl -Mstrict -cw" ".*\.\(pl\)\$" "perl"
TestCodebase "PHP" "php" "php -l" ".*\.\(php\)\$" "php" TestCodebase "PHP" "php" "php -l" ".*\.\(php\)\$" "php"
@ -479,8 +490,7 @@ function RunTestCases()
} }
################################################################################ ################################################################################
#### Function LintAnsibleFiles ################################################# #### Function LintAnsibleFiles #################################################
function LintAnsibleFiles() function LintAnsibleFiles() {
{
###################### ######################
# Create Print Array # # Create Print Array #
###################### ######################
@ -516,14 +526,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
@ -571,8 +581,7 @@ function LintAnsibleFiles()
# Check if we have data to look at # # Check if we have data to look at #
#################################### ####################################
if [ $SKIP_FLAG -eq 0 ]; then if [ $SKIP_FLAG -eq 0 ]; then
for LINE in "${PRINT_ARRAY[@]}" for LINE in "${PRINT_ARRAY[@]}"; do
do
######################### #########################
# Print the header line # # Print the header line #
######################### #########################
@ -583,8 +592,7 @@ function LintAnsibleFiles()
################## ##################
# Lint the files # # Lint the files #
################## ##################
for FILE in "${LIST_FILES[@]}" for FILE in "${LIST_FILES[@]}"; do
do
######################################## ########################################
# Make sure we dont lint certain files # # Make sure we dont lint certain files #
@ -622,26 +630,26 @@ 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
############################### ###############################
# Check to see if debug is on # # Check to see if debug is on #
############################### ###############################
if [[ "$ACTIONS_RUNNER_DEBUG" == "true" ]]; then if [[ $ACTIONS_RUNNER_DEBUG == "true" ]]; then
######################## ########################
# 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