mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-22 06:01:05 -05:00
commit
d0c3b77253
11 changed files with 613 additions and 661 deletions
|
@ -13,6 +13,12 @@
|
||||||
# - System with Docker installed
|
# - System with Docker installed
|
||||||
# - Global variables met
|
# - Global variables met
|
||||||
|
|
||||||
|
#########################
|
||||||
|
# Source Function Files #
|
||||||
|
#########################
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
source /action/lib/log.sh # Source the function script(s)
|
||||||
|
|
||||||
###########
|
###########
|
||||||
# Globals #
|
# Globals #
|
||||||
###########
|
###########
|
||||||
|
@ -29,11 +35,9 @@ DOCKERFILE_PATH="${DOCKERFILE_PATH}" # Path to the Dockerfile to be uploaded
|
||||||
################################################################################
|
################################################################################
|
||||||
#### Function Header ###########################################################
|
#### Function Header ###########################################################
|
||||||
Header() {
|
Header() {
|
||||||
echo ""
|
info "-------------------------------------------------------"
|
||||||
echo "-------------------------------------------------------"
|
info "----- GitHub Actions remove image from DockerHub ------"
|
||||||
echo "----- GitHub Actions remove image from DockerHub ------"
|
info "-------------------------------------------------------"
|
||||||
echo "-------------------------------------------------------"
|
|
||||||
echo ""
|
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
#### Function ValidateInput ####################################################
|
#### Function ValidateInput ####################################################
|
||||||
|
@ -42,21 +46,18 @@ ValidateInput() {
|
||||||
################
|
################
|
||||||
# Print header #
|
# Print header #
|
||||||
################
|
################
|
||||||
echo ""
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
info "Gathering variables..."
|
||||||
echo "Gathering variables..."
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
############################
|
############################
|
||||||
# Validate GITHUB_WORKSPACE #
|
# Validate GITHUB_WORKSPACE #
|
||||||
############################
|
############################
|
||||||
if [ -z "${GITHUB_WORKSPACE}" ]; then
|
if [ -z "${GITHUB_WORKSPACE}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_WORKSPACE]!${NC}"
|
error "Failed to get [GITHUB_WORKSPACE]!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_WORKSPACE}]${NC}"
|
fatal "[${GITHUB_WORKSPACE}]"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo "Successfully found:[GITHUB_WORKSPACE], value:[${GITHUB_WORKSPACE}]"
|
info "Successfully found:[GITHUB_WORKSPACE], value:[${GITHUB_WORKSPACE}]"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
|
@ -64,15 +65,14 @@ ValidateInput() {
|
||||||
#######################
|
#######################
|
||||||
if [ -z "${IMAGE_REPO}" ]; then
|
if [ -z "${IMAGE_REPO}" ]; then
|
||||||
# No repo was pulled
|
# No repo was pulled
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [IMAGE_REPO]!${NC}"
|
error "Failed to get [IMAGE_REPO]!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${IMAGE_REPO}]${NC}"
|
fatal "[${IMAGE_REPO}]"
|
||||||
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}]"
|
info "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 -e "${NC}${F[Y]}WARN!${NC} No image to cleanup as this is a forked branch, and not being built with current automation!${NC}"
|
warn "No image to cleanup as this is a forked branch, and not being built with current automation!"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -80,33 +80,30 @@ ValidateInput() {
|
||||||
# Validate IMAGE_VERSION #
|
# Validate IMAGE_VERSION #
|
||||||
##########################
|
##########################
|
||||||
if [ -z "${IMAGE_VERSION}" ]; then
|
if [ -z "${IMAGE_VERSION}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [IMAGE_VERSION]!${NC}"
|
error "Failed to get [IMAGE_VERSION]!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${IMAGE_VERSION}]${NC}"
|
fatal "[${IMAGE_VERSION}]"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo "Successfully found:[IMAGE_VERSION], value:[${IMAGE_VERSION}]"
|
info "Successfully found:[IMAGE_VERSION], value:[${IMAGE_VERSION}]"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
############################
|
############################
|
||||||
# Validate DOCKER_USERNAME #
|
# Validate DOCKER_USERNAME #
|
||||||
############################
|
############################
|
||||||
if [ -z "${DOCKER_USERNAME}" ]; then
|
if [ -z "${DOCKER_USERNAME}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_USERNAME]!${NC}"
|
error "Failed to get [DOCKER_USERNAME]!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${DOCKER_USERNAME}]${NC}"
|
fatal "[${DOCKER_USERNAME}]"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo "Successfully found:[DOCKER_USERNAME], value:[${DOCKER_USERNAME}]"
|
info "Successfully found:[DOCKER_USERNAME], value:[${DOCKER_USERNAME}]"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
############################
|
############################
|
||||||
# Validate DOCKER_PASSWORD #
|
# Validate DOCKER_PASSWORD #
|
||||||
############################
|
############################
|
||||||
if [ -z "${DOCKER_PASSWORD}" ]; then
|
if [ -z "${DOCKER_PASSWORD}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_PASSWORD]!${NC}"
|
error "Failed to get [DOCKER_PASSWORD]!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${DOCKER_PASSWORD}]${NC}"
|
fatal "[${DOCKER_PASSWORD}]"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo "Successfully found:[DOCKER_PASSWORD], value:[********]"
|
info "Successfully found:[DOCKER_PASSWORD], value:[********]"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##################################################
|
##################################################
|
||||||
|
@ -121,10 +118,9 @@ ValidateInput() {
|
||||||
#############################################
|
#############################################
|
||||||
# Image is 'latest' and we will not destroy #
|
# Image is 'latest' and we will not destroy #
|
||||||
#############################################
|
#############################################
|
||||||
echo "Image Tag is set to:[latest]..."
|
error "Image Tag is set to:[latest]..."
|
||||||
echo "We will never destroy latest..."
|
error "We will never destroy latest..."
|
||||||
echo "Bye!"
|
fatal "Bye!"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -133,11 +129,9 @@ LoginToDocker() {
|
||||||
################
|
################
|
||||||
# Print header #
|
# Print header #
|
||||||
################
|
################
|
||||||
echo ""
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
info "Login to DockerHub..."
|
||||||
echo "Login to DockerHub..."
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
######################
|
######################
|
||||||
# Login to DockerHub #
|
# Login to DockerHub #
|
||||||
|
@ -154,12 +148,11 @@ LoginToDocker() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# ERROR
|
# ERROR
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to authenticate to DockerHub!${NC}"
|
error "Failed to authenticate to DockerHub!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${LOGIN_CMD}]${NC}"
|
fatal "[${LOGIN_CMD}]"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
# SUCCESS
|
# SUCCESS
|
||||||
echo "Successfully authenticated to DockerHub!"
|
info "Successfully authenticated to DockerHub!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -168,11 +161,9 @@ RemoveImage() {
|
||||||
################
|
################
|
||||||
# Print header #
|
# Print header #
|
||||||
################
|
################
|
||||||
echo ""
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
info "Removing the DockerFile image:[${IMAGE_REPO}:${IMAGE_VERSION}]"
|
||||||
echo "Removing the DockerFile image:[${IMAGE_REPO}:${IMAGE_VERSION}]"
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
# Create Token to auth to DockerHub #
|
# Create Token to auth to DockerHub #
|
||||||
|
@ -193,12 +184,11 @@ RemoveImage() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# ERROR
|
# ERROR
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to gain token from DockerHub!${NC}"
|
error "Failed to gain token from DockerHub!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${TOKEN}]${NC}"
|
fatal "[${TOKEN}]"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
# SUCCESS
|
# SUCCESS
|
||||||
echo "Successfully gained auth token from DockerHub!"
|
info "Successfully gained auth token from DockerHub!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#################################
|
#################################
|
||||||
|
@ -218,22 +208,19 @@ RemoveImage() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# ERROR
|
# ERROR
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to remove tag from DockerHub!${NC}"
|
error "Failed to remove tag from DockerHub!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${REMOVE_CMD}]${NC}"
|
fatal "[${REMOVE_CMD}]"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
# SUCCESS
|
# SUCCESS
|
||||||
echo "Successfully [removed] Docker image tag:[${IMAGE_VERSION}] from DockerHub!"
|
info "Successfully [removed] Docker image tag:[${IMAGE_VERSION}] from DockerHub!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
#### Function Footer ###########################################################
|
#### Function Footer ###########################################################
|
||||||
Footer() {
|
Footer() {
|
||||||
echo ""
|
info "-------------------------------------------------------"
|
||||||
echo "-------------------------------------------------------"
|
info "The step has completed"
|
||||||
echo "The step has completed"
|
info "-------------------------------------------------------"
|
||||||
echo "-------------------------------------------------------"
|
|
||||||
echo ""
|
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
################################## MAIN ########################################
|
################################## MAIN ########################################
|
||||||
|
|
|
@ -28,17 +28,17 @@ CheckGHEPid()
|
||||||
##################################
|
##################################
|
||||||
if [ ${PID_CHECK} -gt ${PID_CHECK_LIMIT} ]; then
|
if [ ${PID_CHECK} -gt ${PID_CHECK_LIMIT} ]; then
|
||||||
# Over the limit, move on
|
# Over the limit, move on
|
||||||
echo "We have checked the pid ${PID_CHECK} times, moving on..."
|
info "We have checked the pid ${PID_CHECK} times, moving on..."
|
||||||
else
|
else
|
||||||
################################################
|
################################################
|
||||||
# Check to see if the PID is alive and running #
|
# Check to see if the PID is alive and running #
|
||||||
################################################
|
################################################
|
||||||
if [ ! -f "${GHE_CONFIG_PID}" ]; then
|
if [ ! -f "${GHE_CONFIG_PID}" ]; then
|
||||||
# File not found
|
# File not found
|
||||||
echo "We're good to move forward, no .pid file found at:[${GHE_CONFIG_PID}]"
|
info "We're good to move forward, no .pid file found at:[${GHE_CONFIG_PID}]"
|
||||||
else
|
else
|
||||||
# Found the pid running, need to sleep
|
# Found the pid running, need to sleep
|
||||||
echo "Current PID found, sleeping ${SLEEP_SECONDS} seconds before next check..."
|
info "Current PID found, sleeping ${SLEEP_SECONDS} seconds before next check..."
|
||||||
################
|
################
|
||||||
# Sleep it off #
|
# Sleep it off #
|
||||||
################
|
################
|
||||||
|
@ -53,9 +53,9 @@ CheckGHEPid()
|
||||||
# Check the shell for errors #
|
# Check the shell for errors #
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to sleep!${NC}"
|
error "Failed to sleep!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${SLEEP_CMD}]${NC}"
|
error "[${SLEEP_CMD}]"
|
||||||
echo "Will try to call apply as last effort..."
|
info "Will try to call apply as last effort..."
|
||||||
####################################
|
####################################
|
||||||
# Call config apply as last effort #
|
# Call config apply as last effort #
|
||||||
####################################
|
####################################
|
||||||
|
@ -82,7 +82,7 @@ CheckGHEProcess()
|
||||||
##################################
|
##################################
|
||||||
if [ ${PROCESS_CHECK} -gt ${PROCESS_CHECK_LIMIT} ]; then
|
if [ ${PROCESS_CHECK} -gt ${PROCESS_CHECK_LIMIT} ]; then
|
||||||
# Over the limit, move on
|
# Over the limit, move on
|
||||||
echo "We have checked the process ${PROCESS_CHECK} times, moving on..."
|
info "We have checked the process ${PROCESS_CHECK} times, moving on..."
|
||||||
else
|
else
|
||||||
####################################################
|
####################################################
|
||||||
# Check to see if the process is alive and running #
|
# Check to see if the process is alive and running #
|
||||||
|
@ -99,10 +99,10 @@ CheckGHEProcess()
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# No process running on the system
|
# No process running on the system
|
||||||
echo "Were good to move forward, no process like:[${GHE_APPLY_COMMAND}] running currently on the system"
|
info "Were good to move forward, no process like:[${GHE_APPLY_COMMAND}] running currently on the system"
|
||||||
else
|
else
|
||||||
# Found the process running, need to sleep
|
# Found the process running, need to sleep
|
||||||
echo "Current process alive:[${CHECK_PROCESS_CMD}], sleeping ${SLEEP_SECONDS} seconds before next check..."
|
info "Current process alive:[${CHECK_PROCESS_CMD}], sleeping ${SLEEP_SECONDS} seconds before next check..."
|
||||||
################
|
################
|
||||||
# Sleep it off #
|
# Sleep it off #
|
||||||
################
|
################
|
||||||
|
@ -117,9 +117,9 @@ CheckGHEProcess()
|
||||||
# Check the shell for errors #
|
# Check the shell for errors #
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to sleep!${NC}"
|
error "Failed to sleep!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${SLEEP_CMD}]${NC}"
|
error "[${SLEEP_CMD}]"
|
||||||
echo "Will try to call apply as last effort..."
|
info "Will try to call apply as last effort..."
|
||||||
####################################
|
####################################
|
||||||
# Call config apply as last effort #
|
# Call config apply as last effort #
|
||||||
####################################
|
####################################
|
||||||
|
@ -144,7 +144,7 @@ RunConfigApply()
|
||||||
##########
|
##########
|
||||||
# Header #
|
# Header #
|
||||||
##########
|
##########
|
||||||
echo "Running ${GHE_APPLY_COMMAND} to the server..."
|
info "Running ${GHE_APPLY_COMMAND} to the server..."
|
||||||
|
|
||||||
##############################################
|
##############################################
|
||||||
# Run the command to apply changes to server #
|
# Run the command to apply changes to server #
|
||||||
|
@ -161,12 +161,11 @@ RunConfigApply()
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# Errors
|
# Errors
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to run config apply command!${NC}"
|
error "Failed to run config apply command!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${APPLY_CMD}]${NC}"
|
fatal "[${APPLY_CMD}]"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
# Success
|
# Success
|
||||||
echo -e "${NC}${F[B]}Successfully ran ${F[C]}${GHE_APPLY_COMMAND}${NC}"
|
info "Successfully ran ${F[C]}${GHE_APPLY_COMMAND}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
|
@ -14,6 +14,12 @@
|
||||||
# - System with Docker installed
|
# - System with Docker installed
|
||||||
# - Global variables met
|
# - Global variables met
|
||||||
|
|
||||||
|
#########################
|
||||||
|
# Source Function Files #
|
||||||
|
#########################
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
source /action/lib/log.sh # Source the function script(s)
|
||||||
|
|
||||||
###########
|
###########
|
||||||
# Globals #
|
# Globals #
|
||||||
###########
|
###########
|
||||||
|
@ -35,11 +41,9 @@ UPDATE_MAJOR_TAG=0 # Flag to deploy the major tag version as
|
||||||
################################################################################
|
################################################################################
|
||||||
#### Function Header ###########################################################
|
#### Function Header ###########################################################
|
||||||
Header() {
|
Header() {
|
||||||
echo ""
|
info "-------------------------------------------------------"
|
||||||
echo "-------------------------------------------------------"
|
info "---- GitHub Actions Upload image to [${REGISTRY}] ----"
|
||||||
echo "---- GitHub Actions Upload image to [${REGISTRY}] ----"
|
info "-------------------------------------------------------"
|
||||||
echo "-------------------------------------------------------"
|
|
||||||
echo ""
|
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
#### Function ValidateInput ####################################################
|
#### Function ValidateInput ####################################################
|
||||||
|
@ -48,32 +52,28 @@ ValidateInput() {
|
||||||
################
|
################
|
||||||
# Print header #
|
# Print header #
|
||||||
################
|
################
|
||||||
echo ""
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
info "Gathering variables..."
|
||||||
echo "Gathering variables..."
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
#############################
|
#############################
|
||||||
# Validate GITHUB_WORKSPACE #
|
# Validate GITHUB_WORKSPACE #
|
||||||
#############################
|
#############################
|
||||||
if [ -z "${GITHUB_WORKSPACE}" ]; then
|
if [ -z "${GITHUB_WORKSPACE}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_WORKSPACE]!${NC}"
|
error "Failed to get [GITHUB_WORKSPACE]!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_WORKSPACE}]${NC}"
|
fatal "[${GITHUB_WORKSPACE}]"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[${GITHUB_WORKSPACE}]${NC}"
|
info "Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[${GITHUB_WORKSPACE}]"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#####################
|
#####################
|
||||||
# Validate REGISTRY #
|
# Validate REGISTRY #
|
||||||
#####################
|
#####################
|
||||||
if [ -z "${REGISTRY}" ]; then
|
if [ -z "${REGISTRY}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [REGISTRY]!${NC}"
|
error "Failed to get [REGISTRY]!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${REGISTRY}]${NC}"
|
fatal "[${REGISTRY}]"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[REGISTRY]${F[B]}, value:${F[W]}[${REGISTRY}]${NC}"
|
info "Successfully found:${F[W]}[REGISTRY]${F[B]}, value:${F[W]}[${REGISTRY}]"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#####################################################
|
#####################################################
|
||||||
|
@ -84,22 +84,20 @@ ValidateInput() {
|
||||||
# Validate GPR_USERNAME #
|
# Validate GPR_USERNAME #
|
||||||
#########################
|
#########################
|
||||||
if [ -z "${GPR_USERNAME}" ]; then
|
if [ -z "${GPR_USERNAME}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GPR_USERNAME]!${NC}"
|
error "Failed to get [GPR_USERNAME]!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GPR_USERNAME}]${NC}"
|
fatal "[${GPR_USERNAME}]"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GPR_USERNAME]${F[B]}, value:${F[W]}[${GPR_USERNAME}]${NC}"
|
info "Successfully found:${F[W]}[GPR_USERNAME]${F[B]}, value:${F[W]}[${GPR_USERNAME}]"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
######################
|
######################
|
||||||
# Validate GPR_TOKEN #
|
# Validate GPR_TOKEN #
|
||||||
######################
|
######################
|
||||||
if [ -z "${GPR_TOKEN}" ]; then
|
if [ -z "${GPR_TOKEN}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GPR_TOKEN]!${NC}"
|
error "Failed to get [GPR_TOKEN]!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GPR_TOKEN}]${NC}"
|
fatal "[${GPR_TOKEN}]"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GPR_TOKEN]${F[B]}, value:${F[W]}[********]${NC}"
|
info "Successfully found:${F[W]}[GPR_TOKEN]${F[B]}, value:${F[W]}[********]"
|
||||||
fi
|
fi
|
||||||
########################################
|
########################################
|
||||||
# See if we need values for Ducker hub #
|
# See if we need values for Ducker hub #
|
||||||
|
@ -109,48 +107,44 @@ ValidateInput() {
|
||||||
# Validate DOCKER_USERNAME #
|
# Validate DOCKER_USERNAME #
|
||||||
############################
|
############################
|
||||||
if [ -z "${DOCKER_USERNAME}" ]; then
|
if [ -z "${DOCKER_USERNAME}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_USERNAME]!${NC}"
|
error "Failed to get [DOCKER_USERNAME]!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${DOCKER_USERNAME}]${NC}"
|
fatal "[${DOCKER_USERNAME}]"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[DOCKER_USERNAME]${F[B]}, value:${F[W]}[${DOCKER_USERNAME}]${NC}"
|
info "Successfully found:${F[W]}[DOCKER_USERNAME]${F[B]}, value:${F[W]}[${DOCKER_USERNAME}]"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
############################
|
############################
|
||||||
# Validate DOCKER_PASSWORD #
|
# Validate DOCKER_PASSWORD #
|
||||||
############################
|
############################
|
||||||
if [ -z "${DOCKER_PASSWORD}" ]; then
|
if [ -z "${DOCKER_PASSWORD}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_PASSWORD]!${NC}"
|
error "Failed to get [DOCKER_PASSWORD]!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${DOCKER_PASSWORD}]${NC}"
|
fatal "[${DOCKER_PASSWORD}]"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[DOCKER_PASSWORD]${F[B]}, value:${F[B]}[********]${NC}"
|
info "Successfully found:${F[W]}[DOCKER_PASSWORD]${F[B]}, value:${F[B]}[********]"
|
||||||
fi
|
fi
|
||||||
###########################################
|
###########################################
|
||||||
# We were not passed a registry to update #
|
# We were not passed a registry to update #
|
||||||
###########################################
|
###########################################
|
||||||
else
|
else
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find a valid registry!${NC}"
|
error "Failed to find a valid registry!"
|
||||||
echo "Registry:[${REGISTRY}]"
|
fatal "Registry:[${REGISTRY}]"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# Validate IMAGE_REPO #
|
# Validate IMAGE_REPO #
|
||||||
#######################
|
#######################
|
||||||
if [ -z "${IMAGE_REPO}" ]; then
|
if [ -z "${IMAGE_REPO}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [IMAGE_REPO]!${NC}"
|
error "Failed to get [IMAGE_REPO]!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${IMAGE_REPO}]${NC}"
|
fatal "[${IMAGE_REPO}]"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[IMAGE_REPO]${F[B]}, value:${F[W]}[${IMAGE_REPO}]${NC}"
|
info "Successfully found:${F[W]}[IMAGE_REPO]${F[B]}, value:${F[W]}[${IMAGE_REPO}]"
|
||||||
###############################################
|
###############################################
|
||||||
# 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"
|
info "Updated [IMAGE_REPO] to:[${IMAGE_REPO}] for GPR"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -158,8 +152,8 @@ ValidateInput() {
|
||||||
# Validate IMAGE_VERSION #
|
# Validate IMAGE_VERSION #
|
||||||
##########################
|
##########################
|
||||||
if [ -z "${IMAGE_VERSION}" ]; then
|
if [ -z "${IMAGE_VERSION}" ]; then
|
||||||
echo -e "${NC}${F[Y]}WARN!${NC} Failed to get [IMAGE_VERSION]!${NC}"
|
warn "Failed to get [IMAGE_VERSION]!"
|
||||||
echo "Pulling from Branch Name..."
|
info "Pulling from Branch Name..."
|
||||||
##############################
|
##############################
|
||||||
# Get the name of the branch #
|
# Get the name of the branch #
|
||||||
##############################
|
##############################
|
||||||
|
@ -174,9 +168,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 -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get branch name!${NC}"
|
error "Failed to get branch name!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${BRANCH_NAME}]${NC}"
|
fatal "[${BRANCH_NAME}]"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##################################
|
##################################
|
||||||
|
@ -188,9 +181,9 @@ ValidateInput() {
|
||||||
# Set the IMAGE_VERSION to the BRANCH_NAME #
|
# Set the IMAGE_VERSION to the BRANCH_NAME #
|
||||||
############################################
|
############################################
|
||||||
IMAGE_VERSION="${BRANCH_NAME}"
|
IMAGE_VERSION="${BRANCH_NAME}"
|
||||||
echo "Tag:[${IMAGE_VERSION}]"
|
info "Tag:[${IMAGE_VERSION}]"
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[IMAGE_VERSION]${F[B]}, value:${F[W]}[${IMAGE_VERSION}]${NC}"
|
info "Successfully found:${F[W]}[IMAGE_VERSION]${F[B]}, value:${F[W]}[${IMAGE_VERSION}]"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##################################
|
##################################
|
||||||
|
@ -214,18 +207,17 @@ ValidateInput() {
|
||||||
###################################
|
###################################
|
||||||
UPDATE_MAJOR_TAG=1
|
UPDATE_MAJOR_TAG=1
|
||||||
|
|
||||||
echo "- Also deploying a major tag of:[${MAJOR_TAG}]"
|
info "- Also deploying a major tag of:[${MAJOR_TAG}]"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
############################
|
############################
|
||||||
# Validate DOCKERFILE_PATH #
|
# Validate DOCKERFILE_PATH #
|
||||||
############################
|
############################
|
||||||
if [ -z "${DOCKERFILE_PATH}" ]; then
|
if [ -z "${DOCKERFILE_PATH}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKERFILE_PATH]!${NC}"
|
error "Failed to get [DOCKERFILE_PATH]!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${DOCKERFILE_PATH}]${NC}"
|
fatal "[${DOCKERFILE_PATH}]"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[DOCKERFILE_PATH]${F[B]}, value:${F[W]}[${DOCKERFILE_PATH}]${NC}"
|
info "Successfully found:${F[W]}[DOCKERFILE_PATH]${F[B]}, value:${F[W]}[${DOCKERFILE_PATH}]"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -242,11 +234,9 @@ Authenticate() {
|
||||||
################
|
################
|
||||||
# Print header #
|
# Print header #
|
||||||
################
|
################
|
||||||
echo ""
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
info "Login to ${NAME}..."
|
||||||
echo "Login to ${NAME}..."
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# Auth to service #
|
# Auth to service #
|
||||||
|
@ -263,12 +253,11 @@ Authenticate() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# ERROR
|
# ERROR
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to authenticate to ${NAME}!${NC}"
|
error "Failed to authenticate to ${NAME}!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${LOGIN_CMD}]${NC}"
|
fatal "[${LOGIN_CMD}]"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
# SUCCESS
|
# SUCCESS
|
||||||
echo -e "${NC}${F[B]}Successfully authenticated to ${F[C]}${NAME}${F[B]}!${NC}"
|
info "Successfully authenticated to ${F[C]}${NAME}${F[B]}!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -277,21 +266,18 @@ BuildImage() {
|
||||||
################
|
################
|
||||||
# Print header #
|
# Print header #
|
||||||
################
|
################
|
||||||
echo ""
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
info "Building the DockerFile image..."
|
||||||
echo "Building the DockerFile image..."
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
################################
|
################################
|
||||||
# Validate the DOCKERFILE_PATH #
|
# Validate the DOCKERFILE_PATH #
|
||||||
################################
|
################################
|
||||||
if [ ! -f "${DOCKERFILE_PATH}" ]; then
|
if [ ! -f "${DOCKERFILE_PATH}" ]; then
|
||||||
# No file found
|
# No file found
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to find Dockerfile at:[${DOCKERFILE_PATH}]${NC}"
|
error "failed to find Dockerfile at:[${DOCKERFILE_PATH}]"
|
||||||
echo "Please make sure you give full path!"
|
error "Please make sure you give full path!"
|
||||||
echo "Example:[/configs/Dockerfile] or [Dockerfile] if at root directory"
|
fatal "Example:[/configs/Dockerfile] or [Dockerfile] if at root directory"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###################
|
###################
|
||||||
|
@ -309,11 +295,10 @@ BuildImage() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# ERROR
|
# ERROR
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [build] Dockerfile!${NC}"
|
fatal "failed to [build] Dockerfile!"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
# SUCCESS
|
# SUCCESS
|
||||||
echo -e "${NC}${F[B]}Successfully Built image!${NC}"
|
info "Successfully Built image!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
########################################################
|
########################################################
|
||||||
|
@ -333,11 +318,10 @@ BuildImage() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# ERROR
|
# ERROR
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [tag] Dockerfile!${NC}"
|
fatal "failed to [tag] Dockerfile!"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
# SUCCESS
|
# SUCCESS
|
||||||
echo -e "${NC}${F[B]}Successfully tagged image!${NC}"
|
info "Successfully tagged image!"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -347,11 +331,9 @@ UploadImage() {
|
||||||
################
|
################
|
||||||
# Print header #
|
# Print header #
|
||||||
################
|
################
|
||||||
echo ""
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
info "Uploading the DockerFile image to ${REGISTRY}..."
|
||||||
echo "Uploading the DockerFile image to ${REGISTRY}..."
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
############################################
|
############################################
|
||||||
# Upload the docker image that was created #
|
# Upload the docker image that was created #
|
||||||
|
@ -368,11 +350,10 @@ UploadImage() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# ERROR
|
# ERROR
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [upload] Dockerfile!${NC}"
|
fatal "failed to [upload] Dockerfile!"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
# SUCCESS
|
# SUCCESS
|
||||||
echo -e "${NC}${F[B]}Successfully Uploaded Docker image:${F[W]}[${IMAGE_VERSION}]${F[B]} to ${F[C]}${REGISTRY}${F[B]}!${NC}"
|
info "Successfully Uploaded Docker image:${F[W]}[${IMAGE_VERSION}]${F[B]} to ${F[C]}${REGISTRY}${F[B]}!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
|
@ -391,9 +372,8 @@ UploadImage() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# ERROR
|
# ERROR
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get information about built Image!${NC}"
|
error "Failed to get information about built Image!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GET_INFO_CMD}]${NC}"
|
fatal "[${GET_INFO_CMD}]"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
################
|
################
|
||||||
# Get the data #
|
# Get the data #
|
||||||
|
@ -406,13 +386,13 @@ UploadImage() {
|
||||||
###################
|
###################
|
||||||
# Print the goods #
|
# Print the goods #
|
||||||
###################
|
###################
|
||||||
echo "----------------------------------------------"
|
info "----------------------------------------------"
|
||||||
echo "Docker Image Details:"
|
info "Docker Image Details:"
|
||||||
echo "Repository:[${REPO}]"
|
info "Repository:[${REPO}]"
|
||||||
echo "Tag:[${TAG}]"
|
info "Tag:[${TAG}]"
|
||||||
echo "Image_ID:[${IMAGE_ID}]"
|
info "Image_ID:[${IMAGE_ID}]"
|
||||||
echo "Size:[${SIZE}]"
|
info "Size:[${SIZE}]"
|
||||||
echo "----------------------------------------------"
|
info "----------------------------------------------"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###############################################################
|
###############################################################
|
||||||
|
@ -434,22 +414,19 @@ UploadImage() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# ERROR
|
# ERROR
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [upload] MAJOR_TAG:[${MAJOR_TAG}] Dockerfile!${NC}"
|
fatal "failed to [upload] MAJOR_TAG:[${MAJOR_TAG}] Dockerfile!"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
# SUCCESS
|
# SUCCESS
|
||||||
echo -e "${NC}${F[B]}Successfully Uploaded TAG:${F[W]}[${MAJOR_TAG}]${F[B]} of Docker image to ${F[C]}${REGISTRY}${F[B]}!${NC}"
|
info "Successfully Uploaded TAG:${F[W]}[${MAJOR_TAG}]${F[B]} of Docker image to ${F[C]}${REGISTRY}${F[B]}!"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
#### Function Footer ###########################################################
|
#### Function Footer ###########################################################
|
||||||
Footer() {
|
Footer() {
|
||||||
echo ""
|
info "-------------------------------------------------------"
|
||||||
echo "-------------------------------------------------------"
|
info "The step has completed"
|
||||||
echo "The step has completed"
|
info "-------------------------------------------------------"
|
||||||
echo "-------------------------------------------------------"
|
|
||||||
echo ""
|
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
################################## MAIN ########################################
|
################################## MAIN ########################################
|
||||||
|
@ -488,9 +465,8 @@ else
|
||||||
#########
|
#########
|
||||||
# ERROR #
|
# ERROR #
|
||||||
#########
|
#########
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Registry not set correctly!${NC}"
|
error "Registry not set correctly!"
|
||||||
echo "Registry:[${REGISTRY}]"
|
fatal "Registry:[${REGISTRY}]"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
####################
|
####################
|
||||||
|
|
|
@ -228,6 +228,8 @@ ENV ACTIONS_RUNNER_DEBUG=${ACTIONS_RUNNER_DEBUG} \
|
||||||
GITHUB_TOKEN=${GITHUB_TOKEN} \
|
GITHUB_TOKEN=${GITHUB_TOKEN} \
|
||||||
GITHUB_WORKSPACE=${GITHUB_WORKSPACE} \
|
GITHUB_WORKSPACE=${GITHUB_WORKSPACE} \
|
||||||
LINTER_RULES_PATH=${LINTER_RULES_PATH} \
|
LINTER_RULES_PATH=${LINTER_RULES_PATH} \
|
||||||
|
LOG_FILE=${LOG_FILE} \
|
||||||
|
LOG_LEVEL=${LOG_LEVEL} \
|
||||||
OUTPUT_DETAILS=${OUTPUT_DETAILS} \
|
OUTPUT_DETAILS=${OUTPUT_DETAILS} \
|
||||||
OUTPUT_FOLDER=${OUTPUT_FOLDER} \
|
OUTPUT_FOLDER=${OUTPUT_FOLDER} \
|
||||||
OUTPUT_FORMAT=${OUTPUT_FORMAT} \
|
OUTPUT_FORMAT=${OUTPUT_FORMAT} \
|
||||||
|
|
71
README.md
71
README.md
|
@ -41,39 +41,39 @@ The design of the **Super-Linter** is currently to allow linting to occur in **G
|
||||||
|
|
||||||
Developers on **GitHub** can call the **GitHub Action** to lint their code base with the following list of linters:
|
Developers on **GitHub** can call the **GitHub Action** to lint their code base with the following list of linters:
|
||||||
|
|
||||||
| _Language_ | _Linter_ |
|
| _Language_ | _Linter_ |
|
||||||
| -------------------------------- | ------------------------------------------------------------------------------------ |
|
| -------------------------------- | -------------------------------------------------------------------------------------------------------- |
|
||||||
| **Ansible** | [ansible-lint](https://github.com/ansible/ansible-lint) |
|
| **Ansible** | [ansible-lint](https://github.com/ansible/ansible-lint) |
|
||||||
| **Azure Resource Manager (ARM)** | [arm-ttk](https://github.com/azure/arm-ttk) |
|
| **Azure Resource Manager (ARM)** | [arm-ttk](https://github.com/azure/arm-ttk) |
|
||||||
| **AWS CloudFormation templates** | [cfn-lint](https://github.com/aws-cloudformation/cfn-python-lint/) |
|
| **AWS CloudFormation templates** | [cfn-lint](https://github.com/aws-cloudformation/cfn-python-lint/) |
|
||||||
| **CSS** | [stylelint](https://stylelint.io/) |
|
| **CSS** | [stylelint](https://stylelint.io/) |
|
||||||
| **Clojure** | [clj-kondo](https://github.com/borkdude/clj-kondo) |
|
| **Clojure** | [clj-kondo](https://github.com/borkdude/clj-kondo) |
|
||||||
| **CoffeeScript** | [coffeelint](https://coffeelint.github.io/) |
|
| **CoffeeScript** | [coffeelint](https://coffeelint.github.io/) |
|
||||||
| **Dart** | [dartanalyzer](https://dart.dev/guides/language/analysis-options) |
|
| **Dart** | [dartanalyzer](https://dart.dev/guides/language/analysis-options) |
|
||||||
| **Dockerfile** | [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git) |
|
| **Dockerfile** | [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git) |
|
||||||
| **EDITORCONFIG** | [editorconfig-checker](https://github.com/editorconfig-checker/editorconfig-checker) |
|
| **EDITORCONFIG** | [editorconfig-checker](https://github.com/editorconfig-checker/editorconfig-checker) |
|
||||||
| **ENV** | [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter) |
|
| **ENV** | [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter) |
|
||||||
| **Golang** | [golangci-lint](https://github.com/golangci/golangci-lint) |
|
| **Golang** | [golangci-lint](https://github.com/golangci/golangci-lint) |
|
||||||
| **Groovy** | [npm-groovy-lint](https://github.com/nvuillam/npm-groovy-lint) |
|
| **Groovy** | [npm-groovy-lint](https://github.com/nvuillam/npm-groovy-lint) |
|
||||||
| **HTMLHint** | [HTMLHint](https://github.com/htmlhint/HTMLHint) |
|
| **HTMLHint** | [HTMLHint](https://github.com/htmlhint/HTMLHint) |
|
||||||
| **JavaScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) |
|
| **JavaScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) |
|
||||||
| **JSON** | [jsonlint](https://github.com/zaach/jsonlint) |
|
| **JSON** | [jsonlint](https://github.com/zaach/jsonlint) |
|
||||||
| **Kotlin** | [ktlint](https://github.com/pinterest/ktlint) |
|
| **Kotlin** | [ktlint](https://github.com/pinterest/ktlint) |
|
||||||
| **Lua** | [luacheck](https://github.com/luarocks/luacheck) |
|
| **Lua** | [luacheck](https://github.com/luarocks/luacheck) |
|
||||||
| **Markdown** | [markdownlint](https://github.com/igorshubovych/markdownlint-cli#readme) |
|
| **Markdown** | [markdownlint](https://github.com/igorshubovych/markdownlint-cli#readme) |
|
||||||
| **OpenAPI** | [spectral](https://github.com/stoplightio/spectral) |
|
| **OpenAPI** | [spectral](https://github.com/stoplightio/spectral) |
|
||||||
| **Perl** | [perl](https://pkgs.alpinelinux.org/package/edge/main/x86/perl) |
|
| **Perl** | [perl](https://pkgs.alpinelinux.org/package/edge/main/x86/perl) |
|
||||||
| **PHP** | [PHP](https://www.php.net/) |
|
| **PHP** | [PHP](https://www.php.net/) |
|
||||||
| **PowerShell** | [PSScriptAnalyzer](https://github.com/PowerShell/Psscriptanalyzer) |
|
| **PowerShell** | [PSScriptAnalyzer](https://github.com/PowerShell/Psscriptanalyzer) |
|
||||||
| **Protocol Buffers** | [protolint](https://github.com/yoheimuta/protolint) |
|
| **Protocol Buffers** | [protolint](https://github.com/yoheimuta/protolint) |
|
||||||
| **Python3** | [pylint](https://www.pylint.org/) [flake8](https://flake8.pycqa.org/en/latest/) |
|
| **Python3** | [pylint](https://www.pylint.org/) [flake8](https://flake8.pycqa.org/en/latest/) |
|
||||||
| **Raku** | [raku](https://raku.org) |
|
| **Raku** | [raku](https://raku.org) |
|
||||||
| **Ruby** | [RuboCop](https://github.com/rubocop-hq/rubocop) |
|
| **Ruby** | [RuboCop](https://github.com/rubocop-hq/rubocop) |
|
||||||
| **Shell** | [Shellcheck](https://github.com/koalaman/shellcheck) |
|
| **Shell** | [Shellcheck](https://github.com/koalaman/shellcheck) |
|
||||||
| **Terraform** | [tflint](https://github.com/terraform-linters/tflint) [terrascan](https://github.com/accurics/terrascan) |
|
| **Terraform** | [tflint](https://github.com/terraform-linters/tflint) [terrascan](https://github.com/accurics/terrascan) |
|
||||||
| **TypeScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) |
|
| **TypeScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) |
|
||||||
| **XML** | [LibXML](http://xmlsoft.org/) |
|
| **XML** | [LibXML](http://xmlsoft.org/) |
|
||||||
| **YAML** | [YamlLint](https://github.com/adrienverge/yamllint) |
|
| **YAML** | [YamlLint](https://github.com/adrienverge/yamllint) |
|
||||||
|
|
||||||
## How to use
|
## How to use
|
||||||
|
|
||||||
|
@ -176,6 +176,8 @@ and won't run anything unexpected.
|
||||||
| **DISABLE_ERRORS** | `false` | Flag to have the linter complete with exit code 0 even if errors were detected. |
|
| **DISABLE_ERRORS** | `false` | Flag to have the linter complete with exit code 0 even if errors were detected. |
|
||||||
| **JAVASCRIPT_ES_CONFIG_FILE** | `.eslintrc.yml` | Filename for [eslint configuration](https://eslint.org/docs/user-guide/configuring#configuration-file-formats) (ex: `.eslintrc.yml`, `.eslintrc.json`) |
|
| **JAVASCRIPT_ES_CONFIG_FILE** | `.eslintrc.yml` | Filename for [eslint configuration](https://eslint.org/docs/user-guide/configuring#configuration-file-formats) (ex: `.eslintrc.yml`, `.eslintrc.json`) |
|
||||||
| **LINTER_RULES_PATH** | `.github/linters` | Directory for all linter configuration rules. |
|
| **LINTER_RULES_PATH** | `.github/linters` | Directory for all linter configuration rules. |
|
||||||
|
| **LOG_FILE** | `super-linter.log` | The file name for outputting logs. All output is sent to the log file regardless of `LOG_LEVEL`. |
|
||||||
|
| **LOG_LEVEL** | `VERBOSE` | How much output the script will generate to the console. One of `VERBOSE`, `DEBUG` or `TRACE`. |
|
||||||
| **MULTI_STATUS** | `true` | A status API is made for each language that is linted to make visual parsing easier. |
|
| **MULTI_STATUS** | `true` | A status API is made for each language that is linted to make visual parsing easier. |
|
||||||
| **OUTPUT_FORMAT** | `none` | The report format to be generated, besides the stdout one. Output format of tap is currently using v13 of the specification. Supported formats: tap |
|
| **OUTPUT_FORMAT** | `none` | The report format to be generated, besides the stdout one. Output format of tap is currently using v13 of the specification. Supported formats: tap |
|
||||||
| **OUTPUT_FOLDER** | `super-linter.report` | The location where the output reporting will be generated to. Output folder must not previously exist. |
|
| **OUTPUT_FOLDER** | `super-linter.report` | The location where the output reporting will be generated to. Output folder must not previously exist. |
|
||||||
|
@ -219,7 +221,7 @@ and won't run anything unexpected.
|
||||||
| **VALIDATE_RUBY** | `true` | Flag to enable or disable the linting process of the Ruby language. |
|
| **VALIDATE_RUBY** | `true` | Flag to enable or disable the linting process of the Ruby language. |
|
||||||
| **VALIDATE_STATES** | `true` | Flag to enable or disable the linting process for AWS States Language. |
|
| **VALIDATE_STATES** | `true` | Flag to enable or disable the linting process for AWS States Language. |
|
||||||
| **VALIDATE_TERRAFORM** | `true` | Flag to enable or disable the linting process of the Terraform language. |
|
| **VALIDATE_TERRAFORM** | `true` | Flag to enable or disable the linting process of the Terraform language. |
|
||||||
| **VALIDATE_TERRAFORM_TERRASCAN** | `false` | Flag to enable or disable the linting process of the Terraform language for security related issues. |
|
| **VALIDATE_TERRAFORM_TERRASCAN** | `false` | Flag to enable or disable the linting process of the Terraform language for security related issues. |
|
||||||
| **VALIDATE_TSX** | `true` | Flag to enable or disable the linting process for tsx files (Utilizing: eslint) |
|
| **VALIDATE_TSX** | `true` | Flag to enable or disable the linting process for tsx files (Utilizing: eslint) |
|
||||||
| **VALIDATE_TYPESCRIPT_ES** | `true` | Flag to enable or disable the linting process of the Typescript language. (Utilizing: eslint) |
|
| **VALIDATE_TYPESCRIPT_ES** | `true` | Flag to enable or disable the linting process of the Typescript language. (Utilizing: eslint) |
|
||||||
| **VALIDATE_TYPESCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the Typescript language. (Utilizing: standard) |
|
| **VALIDATE_TYPESCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the Typescript language. (Utilizing: standard) |
|
||||||
|
@ -227,7 +229,6 @@ and won't run anything unexpected.
|
||||||
| **VALIDATE_YAML** | `true` | Flag to enable or disable the linting process of the YAML language. |
|
| **VALIDATE_YAML** | `true` | Flag to enable or disable the linting process of the YAML language. |
|
||||||
| **YAML_CONFIG_FILE** | `.yaml-lint.yml` | Filename for [Yamllint configuration](https://yamllint.readthedocs.io/en/stable/configuration.html) (ex: `.yaml-lint.yml`, `.yamllint.yml`) |
|
| **YAML_CONFIG_FILE** | `.yaml-lint.yml` | Filename for [Yamllint configuration](https://yamllint.readthedocs.io/en/stable/configuration.html) (ex: `.yaml-lint.yml`, `.yamllint.yml`) |
|
||||||
|
|
||||||
|
|
||||||
### Template rules files
|
### Template rules files
|
||||||
|
|
||||||
You can use the **GitHub** **Super-Linter** _with_ or _without_ your own personal rules sets. This allows for greater flexibility for each individual code base. The Template rules all try to follow the standards we believe should be enabled at the basic level.
|
You can use the **GitHub** **Super-Linter** _with_ or _without_ your own personal rules sets. This allows for greater flexibility for each individual code base. The Template rules all try to follow the standards we believe should be enabled at the basic level.
|
||||||
|
|
|
@ -16,11 +16,8 @@ function BuildFileList() {
|
||||||
################
|
################
|
||||||
# print header #
|
# print header #
|
||||||
################
|
################
|
||||||
if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then
|
debug "----------------------------------------------"
|
||||||
echo ""
|
debug "Pulling in code history and branches..."
|
||||||
echo "----------------------------------------------"
|
|
||||||
echo "Pulling in code history and branches..."
|
|
||||||
fi
|
|
||||||
|
|
||||||
#################################################################################
|
#################################################################################
|
||||||
# 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 #
|
||||||
|
@ -40,19 +37,15 @@ 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!"
|
info "Failed to switch to ${DEFAULT_BRANCH} branch to get files changed!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${SWITCH_CMD}]${NC}"
|
fatal "[${SWITCH_CMD}]"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
################
|
################
|
||||||
# print header #
|
# print header #
|
||||||
################
|
################
|
||||||
if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then
|
debug "----------------------------------------------"
|
||||||
echo ""
|
debug "Generating Diff with:[git diff --name-only '${DEFAULT_BRANCH}..${GITHUB_SHA}' --diff-filter=d]"
|
||||||
echo "----------------------------------------------"
|
|
||||||
echo "Generating Diff with:[git diff --name-only '${DEFAULT_BRANCH}..${GITHUB_SHA}' --diff-filter=d]"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#################################################
|
#################################################
|
||||||
# Get the Array of files changed in the commits #
|
# Get the Array of files changed in the commits #
|
||||||
|
@ -69,17 +62,15 @@ function BuildFileList() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# Error
|
# Error
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to gain a list of all files changed!${NC}"
|
error "Failed to gain a list of all files changed!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${RAW_FILE_ARRAY[*]}]${NC}"
|
fatal "[${RAW_FILE_ARRAY[*]}]"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
# Iterate through the array of all files found #
|
# Iterate through the array of all files found #
|
||||||
################################################
|
################################################
|
||||||
echo ""
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
info "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[@]}"; do
|
for FILE in "${RAW_FILE_ARRAY[@]}"; do
|
||||||
###########################
|
###########################
|
||||||
# Get the files extension #
|
# Get the files extension #
|
||||||
|
@ -92,12 +83,12 @@ function BuildFileList() {
|
||||||
##############
|
##############
|
||||||
# Print file #
|
# Print file #
|
||||||
##############
|
##############
|
||||||
echo "File:[${FILE}], File_type:[${FILE_TYPE}]"
|
info "File:[${FILE}], File_type:[${FILE_TYPE}]"
|
||||||
|
|
||||||
#########
|
#########
|
||||||
# DEBUG #
|
# DEBUG #
|
||||||
#########
|
#########
|
||||||
#echo "FILE_TYPE:[${FILE_TYPE}]"
|
debug "FILE_TYPE:[${FILE_TYPE}]"
|
||||||
|
|
||||||
################################
|
################################
|
||||||
# Get the CLOUDFORMATION files #
|
# Get the CLOUDFORMATION files #
|
||||||
|
@ -221,9 +212,9 @@ function BuildFileList() {
|
||||||
######################
|
######################
|
||||||
# Get the RAKU files #
|
# Get the RAKU files #
|
||||||
######################
|
######################
|
||||||
elif [ "${FILE_TYPE}" == "raku" ] || [ "${FILE_TYPE}" == "rakumod" ] \
|
elif [ "${FILE_TYPE}" == "raku" ] || [ "${FILE_TYPE}" == "rakumod" ] ||
|
||||||
|| [ "${FILE_TYPE}" == "rakutest" ] || [ "${FILE_TYPE}" == "pm6" ] \
|
[ "${FILE_TYPE}" == "rakutest" ] || [ "${FILE_TYPE}" == "pm6" ] ||
|
||||||
|| [ "${FILE_TYPE}" == "pl6" ] || [ "${FILE_TYPE}" == "p6" ] ; then
|
[ "${FILE_TYPE}" == "pl6" ] || [ "${FILE_TYPE}" == "p6" ]; then
|
||||||
################################
|
################################
|
||||||
# Append the file to the array #
|
# Append the file to the array #
|
||||||
################################
|
################################
|
||||||
|
@ -395,7 +386,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_TYPE" == "lua" ]; then
|
elif [ "$FILE_TYPE" == "lua" ]; then
|
||||||
################################
|
################################
|
||||||
# Append the file to the array #
|
# Append the file to the array #
|
||||||
################################
|
################################
|
||||||
|
@ -474,8 +465,8 @@ function BuildFileList() {
|
||||||
#######################
|
#######################
|
||||||
# It is a bash script #
|
# It is a bash script #
|
||||||
#######################
|
#######################
|
||||||
echo -e "${NC}${F[Y]}WARN!${NC} Found bash script without extension:[.sh]${NC}"
|
warn "Found bash script without extension:[.sh]"
|
||||||
echo "Please update file with proper extensions."
|
info "Please update file with proper extensions."
|
||||||
################################
|
################################
|
||||||
# Append the file to the array #
|
# Append the file to the array #
|
||||||
################################
|
################################
|
||||||
|
@ -488,8 +479,8 @@ function BuildFileList() {
|
||||||
#######################
|
#######################
|
||||||
# It is a Ruby script #
|
# It is a Ruby script #
|
||||||
#######################
|
#######################
|
||||||
echo -e "${NC}${F[Y]}WARN!${NC} Found ruby script without extension:[.rb]${NC}"
|
warn "Found ruby script without extension:[.rb]"
|
||||||
echo "Please update file with proper extensions."
|
info "Please update file with proper extensions."
|
||||||
################################
|
################################
|
||||||
# Append the file to the array #
|
# Append the file to the array #
|
||||||
################################
|
################################
|
||||||
|
@ -502,7 +493,7 @@ function BuildFileList() {
|
||||||
############################
|
############################
|
||||||
# Extension was not found! #
|
# Extension was not found! #
|
||||||
############################
|
############################
|
||||||
echo -e "${NC}${F[Y]} - WARN!${NC} Failed to get filetype for:[${FILE}]!${NC}"
|
warn "Failed to get filetype for:[${FILE}]!"
|
||||||
##########################################################
|
##########################################################
|
||||||
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
|
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
|
||||||
##########################################################
|
##########################################################
|
||||||
|
@ -511,7 +502,7 @@ function BuildFileList() {
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo ${READ_ONLY_CHANGE_FLAG} > /dev/null 2>&1 || true # Workaround SC2034
|
export READ_ONLY_CHANGE_FLAG # Workaround SC2034
|
||||||
|
|
||||||
#########################################
|
#########################################
|
||||||
# Need to switch back to branch of code #
|
# Need to switch back to branch of code #
|
||||||
|
@ -528,15 +519,13 @@ function BuildFileList() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# Error
|
# Error
|
||||||
echo "Failed to switch back to branch!"
|
error "Failed to switch back to branch!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${SWITCH2_CMD}]${NC}"
|
fatal "[${SWITCH2_CMD}]"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
################
|
################
|
||||||
# Footer print #
|
# Footer print #
|
||||||
################
|
################
|
||||||
echo ""
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
info "Successfully gathered list of files..."
|
||||||
echo -e "${NC}${F[B]}Successfully gathered list of files...${NC}"
|
|
||||||
}
|
}
|
||||||
|
|
493
lib/linter.sh
493
lib/linter.sh
|
@ -10,7 +10,7 @@
|
||||||
# Source Function Files #
|
# Source Function Files #
|
||||||
#########################
|
#########################
|
||||||
# shellcheck source=/dev/null
|
# shellcheck source=/dev/null
|
||||||
source /action/lib/termColors.sh # Source the function script(s)
|
source /action/lib/log.sh # Source the function script(s)
|
||||||
# shellcheck source=/dev/null
|
# 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
|
||||||
|
@ -22,85 +22,85 @@ source /action/lib/worker.sh # Source the function script(s)
|
||||||
# GLOBALS #
|
# GLOBALS #
|
||||||
###########
|
###########
|
||||||
# Default Vars
|
# Default Vars
|
||||||
DEFAULT_RULES_LOCATION='/action/lib/.automation' # Default rules files location
|
DEFAULT_RULES_LOCATION='/action/lib/.automation' # Default rules files location
|
||||||
# Ansible Vars
|
# Ansible Vars
|
||||||
ANSIBLE_FILE_NAME='.ansible-lint.yml' # Name of the file
|
ANSIBLE_FILE_NAME='.ansible-lint.yml' # Name of the file
|
||||||
ANSIBLE_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${ANSIBLE_FILE_NAME}" # Path to the Ansible lint rules
|
ANSIBLE_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${ANSIBLE_FILE_NAME}" # Path to the Ansible lint rules
|
||||||
# Azure Resource Manager Vars
|
# Azure Resource Manager Vars
|
||||||
ARM_FILE_NAME='.arm-ttk.psd1' # Name of the file
|
ARM_FILE_NAME='.arm-ttk.psd1' # Name of the file
|
||||||
ARM_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${ARM_FILE_NAME}" # Path to the ARM lint rules
|
ARM_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${ARM_FILE_NAME}" # Path to the ARM lint rules
|
||||||
# Cloudformation Vars
|
# Cloudformation Vars
|
||||||
CLOUDFORMATION_FILE_NAME='.cfnlintrc.yml' # Name of the file
|
CLOUDFORMATION_FILE_NAME='.cfnlintrc.yml' # Name of the file
|
||||||
CLOUDFORMATION_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CLOUDFORMATION_FILE_NAME}" # Path to the cloudformation lint rules
|
CLOUDFORMATION_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CLOUDFORMATION_FILE_NAME}" # Path to the cloudformation lint rules
|
||||||
# Clojure Vars
|
# Clojure Vars
|
||||||
CLOJURE_FILE_NAME='.clj-kondo/config.edn' # Name of the file
|
CLOJURE_FILE_NAME='.clj-kondo/config.edn' # Name of the file
|
||||||
CLOJURE_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CLOJURE_FILE_NAME}" # Path to the Clojure lint rules
|
CLOJURE_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CLOJURE_FILE_NAME}" # Path to the Clojure lint rules
|
||||||
# Coffee Vars
|
# Coffee Vars
|
||||||
COFFEE_FILE_NAME='.coffee-lint.json' # Name of the file
|
COFFEE_FILE_NAME='.coffee-lint.json' # Name of the file
|
||||||
COFFEESCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${COFFEE_FILE_NAME}" # Path to the coffeescript lint rules
|
COFFEESCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${COFFEE_FILE_NAME}" # Path to the coffeescript lint rules
|
||||||
# CSS Vars
|
# CSS Vars
|
||||||
CSS_FILE_NAME='.stylelintrc.json' # Name of the file
|
CSS_FILE_NAME='.stylelintrc.json' # Name of the file
|
||||||
CSS_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CSS_FILE_NAME}" # Path to the CSS lint rules
|
CSS_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CSS_FILE_NAME}" # Path to the CSS lint rules
|
||||||
# Dart Vars
|
# Dart Vars
|
||||||
DART_FILE_NAME='analysis_options.yaml' # Name of the file
|
DART_FILE_NAME='analysis_options.yaml' # Name of the file
|
||||||
DART_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DART_FILE_NAME}" # Path to the DART lint rules
|
DART_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DART_FILE_NAME}" # Path to the DART lint rules
|
||||||
# Docker Vars
|
# Docker Vars
|
||||||
DOCKER_FILE_NAME='.dockerfilelintrc' # Name of the file
|
DOCKER_FILE_NAME='.dockerfilelintrc' # Name of the file
|
||||||
DOCKER_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DOCKER_FILE_NAME}" # Path to the Docker lint rules
|
DOCKER_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DOCKER_FILE_NAME}" # Path to the Docker lint rules
|
||||||
# Golang Vars
|
# Golang Vars
|
||||||
GO_FILE_NAME='.golangci.yml' # Name of the file
|
GO_FILE_NAME='.golangci.yml' # Name of the file
|
||||||
GO_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${GO_FILE_NAME}" # Path to the Go lint rules
|
GO_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${GO_FILE_NAME}" # Path to the Go lint rules
|
||||||
# Groovy Vars
|
# Groovy Vars
|
||||||
GROOVY_FILE_NAME='.groovylintrc.json' # Name of the file
|
GROOVY_FILE_NAME='.groovylintrc.json' # Name of the file
|
||||||
GROOVY_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${GROOVY_FILE_NAME}" # Path to the Groovy lint rules
|
GROOVY_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${GROOVY_FILE_NAME}" # Path to the Groovy lint rules
|
||||||
# HTML Vars
|
# HTML Vars
|
||||||
HTML_FILE_NAME='.htmlhintrc' # Name of the file
|
HTML_FILE_NAME='.htmlhintrc' # Name of the file
|
||||||
HTML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${HTML_FILE_NAME}" # Path to the CSS lint rules
|
HTML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${HTML_FILE_NAME}" # Path to the CSS lint rules
|
||||||
# Javascript Vars
|
# Javascript Vars
|
||||||
JAVASCRIPT_FILE_NAME="${JAVASCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file
|
JAVASCRIPT_FILE_NAME="${JAVASCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file
|
||||||
JAVASCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${JAVASCRIPT_FILE_NAME}" # Path to the Javascript lint rules
|
JAVASCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${JAVASCRIPT_FILE_NAME}" # Path to the Javascript lint rules
|
||||||
JAVASCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard
|
JAVASCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard
|
||||||
# Default linter path
|
# Default linter path
|
||||||
LINTER_RULES_PATH="${LINTER_RULES_PATH:-.github/linters}" # Linter Path Directory
|
LINTER_RULES_PATH="${LINTER_RULES_PATH:-.github/linters}" # Linter Path Directory
|
||||||
# Lua Vars
|
# Lua Vars
|
||||||
LUA_FILE_NAME='.luacheckrc' # Name of the file
|
LUA_FILE_NAME='.luacheckrc' # Name of the file
|
||||||
LUA_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${LUA_FILE_NAME}" # Path to the Lua lint rules
|
LUA_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${LUA_FILE_NAME}" # Path to the Lua lint rules
|
||||||
# MD Vars
|
# MD Vars
|
||||||
MARKDOWN_FILE_NAME='.markdown-lint.yml' # Name of the file
|
MARKDOWN_FILE_NAME='.markdown-lint.yml' # Name of the file
|
||||||
MARKDOWN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${MARKDOWN_FILE_NAME}" # Path to the markdown lint rules
|
MARKDOWN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${MARKDOWN_FILE_NAME}" # Path to the markdown lint rules
|
||||||
# OpenAPI Vars
|
# OpenAPI Vars
|
||||||
OPENAPI_FILE_NAME='.openapirc.yml' # Name of the file
|
OPENAPI_FILE_NAME='.openapirc.yml' # Name of the file
|
||||||
OPENAPI_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${OPENAPI_FILE_NAME}" # Path to the OpenAPI lint rules
|
OPENAPI_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${OPENAPI_FILE_NAME}" # Path to the OpenAPI lint rules
|
||||||
# PHP Vars
|
# PHP Vars
|
||||||
PHPSTAN_FILE_NAME='phpstan.neon' # Name of the file
|
PHPSTAN_FILE_NAME='phpstan.neon' # Name of the file
|
||||||
PHPSTAN_LINTER_RULES="${GITHUB_WORKSPACE}/${PHPSTAN_FILE_NAME}" # Path to the PHPStan lint rules in the repository
|
PHPSTAN_LINTER_RULES="${GITHUB_WORKSPACE}/${PHPSTAN_FILE_NAME}" # Path to the PHPStan lint rules in the repository
|
||||||
if [ ! -f "$PHPSTAN_LINTER_RULES" ]; then
|
if [ ! -f "$PHPSTAN_LINTER_RULES" ]; then
|
||||||
PHPSTAN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PHPSTAN_FILE_NAME}" # Path to the PHPStan lint rules
|
PHPSTAN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PHPSTAN_FILE_NAME}" # Path to the PHPStan lint rules
|
||||||
fi
|
fi
|
||||||
# Powershell Vars
|
# Powershell Vars
|
||||||
POWERSHELL_FILE_NAME='.powershell-psscriptanalyzer.psd1' # Name of the file
|
POWERSHELL_FILE_NAME='.powershell-psscriptanalyzer.psd1' # Name of the file
|
||||||
POWERSHELL_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${POWERSHELL_FILE_NAME}" # Path to the Powershell lint rules
|
POWERSHELL_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${POWERSHELL_FILE_NAME}" # Path to the Powershell lint rules
|
||||||
# Protocol Buffers Vars
|
# Protocol Buffers Vars
|
||||||
PROTOBUF_FILE_NAME='.protolintrc.yml' # Name of the file
|
PROTOBUF_FILE_NAME='.protolintrc.yml' # Name of the file
|
||||||
PROTOBUF_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PROTOBUF_FILE_NAME}" # Path to the Protocol Buffers lint rules
|
PROTOBUF_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PROTOBUF_FILE_NAME}" # Path to the Protocol Buffers lint rules
|
||||||
# Python Vars
|
# Python Vars
|
||||||
PYTHON_PYLINT_FILE_NAME="${PYTHON_PYLINT_CONFIG_FILE:-.python-lint}" # Name of the file
|
PYTHON_PYLINT_FILE_NAME="${PYTHON_PYLINT_CONFIG_FILE:-.python-lint}" # Name of the file
|
||||||
PYTHON_PYLINT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PYTHON_PYLINT_FILE_NAME}" # Path to the python lint rules
|
PYTHON_PYLINT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PYTHON_PYLINT_FILE_NAME}" # Path to the python lint rules
|
||||||
PYTHON_FLAKE8_FILE_NAME="${PYTHON_FLAKE8_CONFIG_FILE:-.flake8}" # Name of the file
|
PYTHON_FLAKE8_FILE_NAME="${PYTHON_FLAKE8_CONFIG_FILE:-.flake8}" # Name of the file
|
||||||
PYTHON_FLAKE8_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PYTHON_FLAKE8_FILE_NAME}" # Path to the python lint rules
|
PYTHON_FLAKE8_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PYTHON_FLAKE8_FILE_NAME}" # Path to the python lint rules
|
||||||
# Ruby Vars
|
# Ruby Vars
|
||||||
RUBY_FILE_NAME="${RUBY_CONFIG_FILE:-.ruby-lint.yml}" # Name of the file
|
RUBY_FILE_NAME="${RUBY_CONFIG_FILE:-.ruby-lint.yml}" # Name of the file
|
||||||
RUBY_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${RUBY_FILE_NAME}" # Path to the ruby lint rules
|
RUBY_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${RUBY_FILE_NAME}" # Path to the ruby lint rules
|
||||||
# Terraform Vars
|
# Terraform Vars
|
||||||
TERRAFORM_FILE_NAME='.tflint.hcl' # Name of the file
|
TERRAFORM_FILE_NAME='.tflint.hcl' # Name of the file
|
||||||
TERRAFORM_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${TERRAFORM_FILE_NAME}" # Path to the Terraform lint rules
|
TERRAFORM_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${TERRAFORM_FILE_NAME}" # Path to the Terraform lint rules
|
||||||
# Typescript Vars
|
# Typescript Vars
|
||||||
TYPESCRIPT_FILE_NAME="${TYPESCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file
|
TYPESCRIPT_FILE_NAME="${TYPESCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file
|
||||||
TYPESCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${TYPESCRIPT_FILE_NAME}" # Path to the Typescript lint rules
|
TYPESCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${TYPESCRIPT_FILE_NAME}" # Path to the Typescript lint rules
|
||||||
TYPESCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard
|
TYPESCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard
|
||||||
# YAML Vars
|
# YAML Vars
|
||||||
YAML_FILE_NAME="${YAML_CONFIG_FILE:-.yaml-lint.yml}" # Name of the file
|
YAML_FILE_NAME="${YAML_CONFIG_FILE:-.yaml-lint.yml}" # Name of the file
|
||||||
YAML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${YAML_FILE_NAME}" # Path to the yaml lint rules
|
YAML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${YAML_FILE_NAME}" # Path to the yaml lint rules
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# Linter array for information prints #
|
# Linter array for information prints #
|
||||||
|
@ -117,7 +117,7 @@ LINTER_ARRAY=('ansible-lint' 'arm-ttk' 'asl-validator' 'cfn-lint' 'clj-kondo' 'c
|
||||||
LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT' 'CSS'
|
LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT' 'CSS'
|
||||||
'DART' 'DOCKER' 'ENV' 'GO' 'GROOVY' 'HTML' 'JAVASCRIPT_ES' 'JAVASCRIPT_STANDARD'
|
'DART' 'DOCKER' 'ENV' 'GO' 'GROOVY' 'HTML' 'JAVASCRIPT_ES' 'JAVASCRIPT_STANDARD'
|
||||||
'JSON' 'JSX' 'KOTLIN' 'LUA' 'MARKDOWN' 'OPENAPI' 'PERL' 'PHP' 'PHP_PHPSTAN' 'POWERSHELL'
|
'JSON' 'JSX' 'KOTLIN' 'LUA' 'MARKDOWN' 'OPENAPI' 'PERL' 'PHP' 'PHP_PHPSTAN' 'POWERSHELL'
|
||||||
'PROTOBUF' 'PYTHON_PYLINT' 'PYTHON_FLAKE8' 'RAKU' 'RUBY' 'STATES' 'TERRAFORM'
|
'PROTOBUF' 'PYTHON_PYLINT' 'PYTHON_FLAKE8' 'RAKU' 'RUBY' 'STATES' 'TERRAFORM'
|
||||||
'TERRAFORM_TERRASCAN' 'TSX' 'TYPESCRIPT_ES' 'TYPESCRIPT_STANDARD' 'XML' 'YML')
|
'TERRAFORM_TERRASCAN' 'TSX' 'TYPESCRIPT_ES' 'TYPESCRIPT_STANDARD' 'XML' 'YML')
|
||||||
|
|
||||||
############################################
|
############################################
|
||||||
|
@ -128,56 +128,58 @@ LINTED_LANGUAGES_ARRAY=() # Will be filled at run time with all languages that w
|
||||||
###################
|
###################
|
||||||
# GitHub ENV Vars #
|
# GitHub ENV Vars #
|
||||||
###################
|
###################
|
||||||
ANSIBLE_DIRECTORY="${ANSIBLE_DIRECTORY}" # Ansible Directory
|
ANSIBLE_DIRECTORY="${ANSIBLE_DIRECTORY}" # Ansible Directory
|
||||||
DEFAULT_BRANCH="${DEFAULT_BRANCH:-master}" # Default Git Branch to use (master by default)
|
DEFAULT_BRANCH="${DEFAULT_BRANCH:-master}" # Default Git Branch to use (master by default)
|
||||||
DISABLE_ERRORS="${DISABLE_ERRORS}" # Boolean to enable warning-only output without throwing errors
|
DISABLE_ERRORS="${DISABLE_ERRORS}" # Boolean to enable warning-only output without throwing errors
|
||||||
GITHUB_EVENT_PATH="${GITHUB_EVENT_PATH}" # Github Event Path
|
GITHUB_EVENT_PATH="${GITHUB_EVENT_PATH}" # Github Event Path
|
||||||
GITHUB_REPOSITORY="${GITHUB_REPOSITORY}" # GitHub Org/Repo passed from system
|
GITHUB_REPOSITORY="${GITHUB_REPOSITORY}" # GitHub Org/Repo passed from system
|
||||||
GITHUB_RUN_ID="${GITHUB_RUN_ID}" # GitHub RUn ID to point to logs
|
GITHUB_RUN_ID="${GITHUB_RUN_ID}" # GitHub RUn ID to point to logs
|
||||||
GITHUB_SHA="${GITHUB_SHA}" # GitHub sha from the commit
|
GITHUB_SHA="${GITHUB_SHA}" # GitHub sha from the commit
|
||||||
GITHUB_TOKEN="${GITHUB_TOKEN}" # GitHub Token passed from environment
|
GITHUB_TOKEN="${GITHUB_TOKEN}" # GitHub Token passed from environment
|
||||||
GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # Github Workspace
|
GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # Github Workspace
|
||||||
MULTI_STATUS="${MULTI_STATUS:-true}" # Multiple status are created for each check ran
|
LOG_FILE="${LOG_FILE:-super-linter.log}" # Default log file name (located in GITHUB_WORKSPACE folder)
|
||||||
TEST_CASE_RUN="${TEST_CASE_RUN}" # Boolean to validate only test cases
|
LOG_LEVEL="${LOG_LEVEL:-VERBOSE}" # Default log level (VERBOSE, DEBUG, TRACE)
|
||||||
VALIDATE_ALL_CODEBASE="${VALIDATE_ALL_CODEBASE}" # Boolean to validate all files
|
MULTI_STATUS="${MULTI_STATUS:-true}" # Multiple status are created for each check ran
|
||||||
VALIDATE_ANSIBLE="${VALIDATE_ANSIBLE}" # Boolean to validate language
|
TEST_CASE_RUN="${TEST_CASE_RUN}" # Boolean to validate only test cases
|
||||||
VALIDATE_ARM="${VALIDATE_ARM}" # Boolean to validate language
|
VALIDATE_ALL_CODEBASE="${VALIDATE_ALL_CODEBASE}" # Boolean to validate all files
|
||||||
VALIDATE_BASH="${VALIDATE_BASH}" # Boolean to validate language
|
VALIDATE_ANSIBLE="${VALIDATE_ANSIBLE}" # Boolean to validate language
|
||||||
VALIDATE_CLOUDFORMATION="${VALIDATE_CLOUDFORMATION}" # Boolean to validate language
|
VALIDATE_ARM="${VALIDATE_ARM}" # Boolean to validate language
|
||||||
VALIDATE_CLOJURE="${VALIDATE_CLOJURE}" # Boolean to validate language
|
VALIDATE_BASH="${VALIDATE_BASH}" # Boolean to validate language
|
||||||
VALIDATE_COFFEE="${VALIDATE_COFFEE}" # Boolean to validate language
|
VALIDATE_CLOUDFORMATION="${VALIDATE_CLOUDFORMATION}" # Boolean to validate language
|
||||||
VALIDATE_CSS="${VALIDATE_CSS}" # Boolean to validate language
|
VALIDATE_CLOJURE="${VALIDATE_CLOJURE}" # Boolean to validate language
|
||||||
VALIDATE_DART="${VALIDATE_DART}" # Boolean to validate language
|
VALIDATE_COFFEE="${VALIDATE_COFFEE}" # Boolean to validate language
|
||||||
VALIDATE_DOCKER="${VALIDATE_DOCKER}" # Boolean to validate language
|
VALIDATE_CSS="${VALIDATE_CSS}" # Boolean to validate language
|
||||||
VALIDATE_EDITORCONFIG="${VALIDATE_EDITORCONFIG}" # Boolean to validate files with editorconfig
|
VALIDATE_DART="${VALIDATE_DART}" # Boolean to validate language
|
||||||
VALIDATE_ENV="${VALIDATE_ENV}" # Boolean to validate language
|
VALIDATE_DOCKER="${VALIDATE_DOCKER}" # Boolean to validate language
|
||||||
VALIDATE_GO="${VALIDATE_GO}" # Boolean to validate language
|
VALIDATE_EDITORCONFIG="${VALIDATE_EDITORCONFIG}" # Boolean to validate files with editorconfig
|
||||||
VALIDATE_GROOVY="${VALIDATE_GROOVY}" # Boolean to validate language
|
VALIDATE_ENV="${VALIDATE_ENV}" # Boolean to validate language
|
||||||
VALIDATE_HTML="${VALIDATE_HTML}" # Boolean to validate language
|
VALIDATE_GO="${VALIDATE_GO}" # Boolean to validate language
|
||||||
VALIDATE_JAVASCRIPT_ES="${VALIDATE_JAVASCRIPT_ES}" # Boolean to validate language
|
VALIDATE_GROOVY="${VALIDATE_GROOVY}" # Boolean to validate language
|
||||||
VALIDATE_JAVASCRIPT_STANDARD="${VALIDATE_JAVASCRIPT_STANDARD}" # Boolean to validate language
|
VALIDATE_HTML="${VALIDATE_HTML}" # Boolean to validate language
|
||||||
VALIDATE_JSON="${VALIDATE_JSON}" # Boolean to validate language
|
VALIDATE_JAVASCRIPT_ES="${VALIDATE_JAVASCRIPT_ES}" # Boolean to validate language
|
||||||
VALIDATE_JSX="${VALIDATE_JSX}" # Boolean to validate language
|
VALIDATE_JAVASCRIPT_STANDARD="${VALIDATE_JAVASCRIPT_STANDARD}" # Boolean to validate language
|
||||||
VALIDATE_KOTLIN="${VALIDATE_KOTLIN}" # Boolean to validate language
|
VALIDATE_JSON="${VALIDATE_JSON}" # Boolean to validate language
|
||||||
VALIDATE_LUA="${VALIDATE_LUA}" # Boolean to validate language
|
VALIDATE_JSX="${VALIDATE_JSX}" # Boolean to validate language
|
||||||
VALIDATE_MARKDOWN="${VALIDATE_MD:-}" # Boolean to validate language
|
VALIDATE_KOTLIN="${VALIDATE_KOTLIN}" # Boolean to validate language
|
||||||
VALIDATE_OPENAPI="${VALIDATE_OPENAPI}" # Boolean to validate language
|
VALIDATE_LUA="${VALIDATE_LUA}" # Boolean to validate language
|
||||||
VALIDATE_PERL="${VALIDATE_PERL}" # Boolean to validate language
|
VALIDATE_MARKDOWN="${VALIDATE_MD:-}" # Boolean to validate language
|
||||||
VALIDATE_PHP="${VALIDATE_PHP}" # Boolean to validate language
|
VALIDATE_OPENAPI="${VALIDATE_OPENAPI}" # Boolean to validate language
|
||||||
VALIDATE_PHP_PHPSTAN="${VALIDATE_PHP_PHPSTAN}" # Boolean to validate language
|
VALIDATE_PERL="${VALIDATE_PERL}" # Boolean to validate language
|
||||||
VALIDATE_POWERSHELL="${VALIDATE_POWERSHELL}" # Boolean to validate language
|
VALIDATE_PHP="${VALIDATE_PHP}" # Boolean to validate language
|
||||||
VALIDATE_PYTHON_PYLINT="${VALIDATE_PYTHON:-$VALIDATE_PYTHON_PYLINT}" # Boolean to validate language
|
VALIDATE_PHP_PHPSTAN="${VALIDATE_PHP_PHPSTAN}" # Boolean to validate language
|
||||||
VALIDATE_PYTHON_FLAKE8="${VALIDATE_PYTHON_FLAKE8}" # Boolean to validate language
|
VALIDATE_POWERSHELL="${VALIDATE_POWERSHELL}" # Boolean to validate language
|
||||||
VALIDATE_RAKU="${VALIDATE_RAKU}" # Boolean to validate language
|
VALIDATE_PYTHON_PYLINT="${VALIDATE_PYTHON:-$VALIDATE_PYTHON_PYLINT}" # Boolean to validate language
|
||||||
VALIDATE_RUBY="${VALIDATE_RUBY}" # Boolean to validate language
|
VALIDATE_PYTHON_FLAKE8="${VALIDATE_PYTHON_FLAKE8}" # Boolean to validate language
|
||||||
VALIDATE_STATES="${VALIDATE_STATES}" # Boolean to validate language
|
VALIDATE_RAKU="${VALIDATE_RAKU}" # Boolean to validate language
|
||||||
VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM}" # Boolean to validate language
|
VALIDATE_RUBY="${VALIDATE_RUBY}" # Boolean to validate language
|
||||||
VALIDATE_TERRAFORM_TERRASCAN="${VALIDATE_TERRAFORM_TERRASCAN}" # Boolean to validate language
|
VALIDATE_STATES="${VALIDATE_STATES}" # Boolean to validate language
|
||||||
VALIDATE_TSX="${VALIDATE_TSX}" # Boolean to validate language
|
VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM}" # Boolean to validate language
|
||||||
VALIDATE_TYPESCRIPT_ES="${VALIDATE_TYPESCRIPT_ES}" # Boolean to validate language
|
VALIDATE_TERRAFORM_TERRASCAN="${VALIDATE_TERRAFORM_TERRASCAN}" # Boolean to validate language
|
||||||
VALIDATE_TYPESCRIPT_STANDARD="${VALIDATE_TYPESCRIPT_STANDARD}" # Boolean to validate language
|
VALIDATE_TSX="${VALIDATE_TSX}" # Boolean to validate language
|
||||||
VALIDATE_XML="${VALIDATE_XML}" # Boolean to validate language
|
VALIDATE_TYPESCRIPT_ES="${VALIDATE_TYPESCRIPT_ES}" # Boolean to validate language
|
||||||
VALIDATE_YAML="${VALIDATE_YAML}" # Boolean to validate language
|
VALIDATE_TYPESCRIPT_STANDARD="${VALIDATE_TYPESCRIPT_STANDARD}" # Boolean to validate language
|
||||||
|
VALIDATE_XML="${VALIDATE_XML}" # Boolean to validate language
|
||||||
|
VALIDATE_YAML="${VALIDATE_YAML}" # Boolean to validate language
|
||||||
|
|
||||||
##############
|
##############
|
||||||
# Debug Vars #
|
# Debug Vars #
|
||||||
|
@ -185,30 +187,44 @@ VALIDATE_YAML="${VALIDATE_YAML}" # Boolean
|
||||||
RUN_LOCAL="${RUN_LOCAL}" # Boolean to see if we are running locally
|
RUN_LOCAL="${RUN_LOCAL}" # Boolean to see if we are running locally
|
||||||
ACTIONS_RUNNER_DEBUG="${ACTIONS_RUNNER_DEBUG:-false}" # Boolean to see even more info (debug)
|
ACTIONS_RUNNER_DEBUG="${ACTIONS_RUNNER_DEBUG:-false}" # Boolean to see even more info (debug)
|
||||||
|
|
||||||
|
############
|
||||||
|
# Log Vars #
|
||||||
|
############
|
||||||
|
if [[ ${ACTIONS_RUNNER_DEBUG} == true ]]; then LOG_LEVEL="DEBUG"; fi
|
||||||
|
# Boolean to see trace logs
|
||||||
|
LOG_TRACE=$(if [[ ${LOG_LEVEL} == "TRACE" ]]; then echo "true"; fi)
|
||||||
|
export LOG_TRACE
|
||||||
|
# Boolean to see debug logs
|
||||||
|
LOG_DEBUG=$(if [[ ${LOG_LEVEL} == "DEBUG" || ${LOG_LEVEL} == "TRACE" ]]; then echo "true"; fi)
|
||||||
|
export LOG_DEBUG
|
||||||
|
# Boolean to see verbose logs (info function)
|
||||||
|
LOG_VERBOSE=$(if [[ ${LOG_LEVEL} == "VERBOSE" || ${LOG_LEVEL} == "DEBUG" || ${LOG_LEVEL} == "TRACE" ]]; then echo "true"; fi)
|
||||||
|
export LOG_VERBOSE
|
||||||
|
|
||||||
################
|
################
|
||||||
# Default Vars #
|
# Default Vars #
|
||||||
################
|
################
|
||||||
DEFAULT_VALIDATE_ALL_CODEBASE='true' # Default value for validate all files
|
DEFAULT_VALIDATE_ALL_CODEBASE='true' # Default value for validate all files
|
||||||
DEFAULT_WORKSPACE="${DEFAULT_WORKSPACE:-/tmp/lint}" # Default workspace if running locally
|
DEFAULT_WORKSPACE="${DEFAULT_WORKSPACE:-/tmp/lint}" # Default workspace if running locally
|
||||||
DEFAULT_RUN_LOCAL='false' # Default value for debugging locally
|
DEFAULT_RUN_LOCAL='false' # Default value for debugging locally
|
||||||
DEFAULT_TEST_CASE_RUN='false' # Flag to tell code to run only test cases
|
DEFAULT_TEST_CASE_RUN='false' # Flag to tell code to run only test cases
|
||||||
DEFAULT_IFS="${IFS}" # Get the Default IFS for updating
|
DEFAULT_IFS="${IFS}" # Get the Default IFS for updating
|
||||||
|
|
||||||
###############################################################
|
###############################################################
|
||||||
# Default Vars that are called in Subs and need to be ignored #
|
# Default Vars that are called in Subs and need to be ignored #
|
||||||
###############################################################
|
###############################################################
|
||||||
DEFAULT_DISABLE_ERRORS='false' # Default to enabling errors
|
DEFAULT_DISABLE_ERRORS='false' # Default to enabling errors
|
||||||
echo "${DEFAULT_DISABLE_ERRORS}" > /dev/null 2>&1 || true # Workaround SC2034
|
export DEFAULT_DISABLE_ERRORS # Workaround SC2034
|
||||||
RAW_FILE_ARRAY=() # Array of all files that were changed
|
RAW_FILE_ARRAY=() # Array of all files that were changed
|
||||||
echo "${RAW_FILE_ARRAY[*]}" > /dev/null 2>&1 || true # Workaround SC2034
|
export RAW_FILE_ARRAY # Workaround SC2034
|
||||||
READ_ONLY_CHANGE_FLAG=0 # Flag set to 1 if files changed are not txt or md
|
READ_ONLY_CHANGE_FLAG=0 # Flag set to 1 if files changed are not txt or md
|
||||||
echo "${READ_ONLY_CHANGE_FLAG}" > /dev/null 2>&1 || true # Workaround SC2034
|
export READ_ONLY_CHANGE_FLAG # Workaround SC2034
|
||||||
TEST_CASE_FOLDER='.automation/test' # Folder for test cases we should always ignore
|
TEST_CASE_FOLDER='.automation/test' # Folder for test cases we should always ignore
|
||||||
echo "${TEST_CASE_FOLDER}" > /dev/null 2>&1 || true # Workaround SC2034
|
export TEST_CASE_FOLDER # Workaround SC2034
|
||||||
DEFAULT_ANSIBLE_DIRECTORY="${GITHUB_WORKSPACE}/ansible" # Default Ansible Directory
|
DEFAULT_ANSIBLE_DIRECTORY="${GITHUB_WORKSPACE}/ansible" # Default Ansible Directory
|
||||||
echo "${DEFAULT_ANSIBLE_DIRECTORY}" > /dev/null 2>&1 || true # Workaround SC2034
|
export DEFAULT_ANSIBLE_DIRECTORY # Workaround SC2034
|
||||||
WARNING_ARRAY_TEST=() # Array of warning linters that did not have an expected test result.
|
WARNING_ARRAY_TEST=() # Array of warning linters that did not have an expected test result.
|
||||||
echo "${WARNING_ARRAY_TEST[*]}" > /dev/null 2>&1 || true # Workaround SC2034
|
export WARNING_ARRAY_TEST # Workaround SC2034
|
||||||
|
|
||||||
##############
|
##############
|
||||||
# Format #
|
# Format #
|
||||||
|
@ -352,15 +368,13 @@ Header() {
|
||||||
##########
|
##########
|
||||||
# Prints #
|
# Prints #
|
||||||
##########
|
##########
|
||||||
echo ""
|
info "---------------------------------------------"
|
||||||
echo "---------------------------------------------"
|
info "--- GitHub Actions Multi Language Linter ----"
|
||||||
echo "--- GitHub Actions Multi Language Linter ----"
|
info "---------------------------------------------"
|
||||||
echo "---------------------------------------------"
|
info "---------------------------------------------"
|
||||||
echo ""
|
info "The Super-Linter source code can be found at:"
|
||||||
echo "---------------------------------------------"
|
info " - https://github.com/github/super-linter"
|
||||||
echo "The Super-Linter source code can be found at:"
|
info "---------------------------------------------"
|
||||||
echo " - https://github.com/github/super-linter"
|
|
||||||
echo "---------------------------------------------"
|
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
#### Function GetLinterVersions ################################################
|
#### Function GetLinterVersions ################################################
|
||||||
|
@ -368,9 +382,8 @@ GetLinterVersions() {
|
||||||
#########################
|
#########################
|
||||||
# Print version headers #
|
# Print version headers #
|
||||||
#########################
|
#########################
|
||||||
echo ""
|
debug "---------------------------------------------"
|
||||||
echo "---------------------------------------------"
|
debug "Linter Version Info:"
|
||||||
echo "Linter Version Info:"
|
|
||||||
|
|
||||||
##########################################################
|
##########################################################
|
||||||
# Go through the array of linters and print version info #
|
# Go through the array of linters and print version info #
|
||||||
|
@ -379,10 +392,10 @@ GetLinterVersions() {
|
||||||
####################
|
####################
|
||||||
# Get the versions #
|
# Get the versions #
|
||||||
####################
|
####################
|
||||||
if [[ "${LINTER}" == "arm-ttk" ]]; then
|
if [[ ${LINTER} == "arm-ttk" ]]; then
|
||||||
# Need specific command for ARM
|
# Need specific command for ARM
|
||||||
mapfile -t GET_VERSION_CMD < <(grep -iE 'version' "${ARM_TTK_PSD1}" | xargs 2>&1)
|
mapfile -t GET_VERSION_CMD < <(grep -iE 'version' "${ARM_TTK_PSD1}" | xargs 2>&1)
|
||||||
elif [[ "${LINTER}" == "protolint" ]]; then
|
elif [[ ${LINTER} == "protolint" ]]; then
|
||||||
# Need specific command for Protolint
|
# Need specific command for Protolint
|
||||||
mapfile -t GET_VERSION_CMD < <(echo "--version not supported")
|
mapfile -t GET_VERSION_CMD < <(echo "--version not supported")
|
||||||
else
|
else
|
||||||
|
@ -399,20 +412,19 @@ 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 -e "${NC}[${LINTER}]: ${F[Y]}WARN!${NC} Failed to get version info for:${NC}"
|
warn "[${LINTER}]: Failed to get version info for:"
|
||||||
else
|
else
|
||||||
##########################
|
##########################
|
||||||
# Print the version info #
|
# Print the version info #
|
||||||
##########################
|
##########################
|
||||||
echo -e "${NC}${F[B]}Successfully found version for ${F[W]}[${LINTER}]${F[B]}: ${F[W]}${GET_VERSION_CMD[*]}${NC}"
|
debug "Successfully found version for ${F[W]}[${LINTER}]${F[B]}: ${F[W]}${GET_VERSION_CMD[*]}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
# Print version footers #
|
# Print version footers #
|
||||||
#########################
|
#########################
|
||||||
echo "---------------------------------------------"
|
debug "---------------------------------------------"
|
||||||
echo ""
|
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
#### Function GetLinterRules ###################################################
|
#### Function GetLinterRules ###################################################
|
||||||
|
@ -434,8 +446,8 @@ GetLinterRules() {
|
||||||
# Validate we have the linter rules #
|
# Validate we have the linter rules #
|
||||||
#####################################
|
#####################################
|
||||||
if [ -f "${GITHUB_WORKSPACE}/${LINTER_RULES_PATH}/${!LANGUAGE_FILE_NAME}" ]; then
|
if [ -f "${GITHUB_WORKSPACE}/${LINTER_RULES_PATH}/${!LANGUAGE_FILE_NAME}" ]; then
|
||||||
echo "----------------------------------------------"
|
info "----------------------------------------------"
|
||||||
echo "User provided file:[${!LANGUAGE_FILE_NAME}], setting rules file..."
|
info "User provided file:[${!LANGUAGE_FILE_NAME}], setting rules file..."
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
# Update the path to the file location #
|
# Update the path to the file location #
|
||||||
|
@ -445,9 +457,7 @@ GetLinterRules() {
|
||||||
########################################################
|
########################################################
|
||||||
# No user default provided, using the template default #
|
# No user default provided, using the template default #
|
||||||
########################################################
|
########################################################
|
||||||
if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then
|
debug " -> Codebase does NOT have file:[${LINTER_RULES_PATH}/${!LANGUAGE_FILE_NAME}], using Default rules at:[${!LANGUAGE_LINTER_RULES}]"
|
||||||
echo " -> Codebase does NOT have file:[${LINTER_RULES_PATH}/${!LANGUAGE_FILE_NAME}], using Default rules at:[${!LANGUAGE_LINTER_RULES}]"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -487,9 +497,8 @@ GetStandardRules() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# ERROR
|
# ERROR
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to gain list of ENV vars to load!${NC}"
|
error "Failed to gain list of ENV vars to load!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GET_ENV_ARRAY[*]}]${NC}"
|
fatal "[${GET_ENV_ARRAY[*]}]"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
|
@ -515,7 +524,7 @@ GetStandardRules() {
|
||||||
# Get the env to add to string #
|
# Get the env to add to string #
|
||||||
################################
|
################################
|
||||||
ENV="$(echo "${ENV}" | cut -d'"' -f2)"
|
ENV="$(echo "${ENV}" | cut -d'"' -f2)"
|
||||||
# echo "ENV:[${ENV}]"
|
debug "ENV:[${ENV}]"
|
||||||
ENV_STRING+="--env ${ENV} "
|
ENV_STRING+="--env ${ENV} "
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -653,8 +662,8 @@ GetGitHubVars() {
|
||||||
##########
|
##########
|
||||||
# Prints #
|
# Prints #
|
||||||
##########
|
##########
|
||||||
echo "--------------------------------------------"
|
info "--------------------------------------------"
|
||||||
echo "Gathering GitHub information..."
|
info "Gathering GitHub information..."
|
||||||
|
|
||||||
###############################
|
###############################
|
||||||
# Get the Run test cases flag #
|
# Get the Run test cases flag #
|
||||||
|
@ -693,8 +702,8 @@ GetGitHubVars() {
|
||||||
##########################################
|
##########################################
|
||||||
# We are running locally for a debug run #
|
# We are running locally for a debug run #
|
||||||
##########################################
|
##########################################
|
||||||
echo "NOTE: ENV VAR [RUN_LOCAL] has been set to:[true]"
|
info "NOTE: ENV VAR [RUN_LOCAL] has been set to:[true]"
|
||||||
echo "bypassing GitHub Actions variables..."
|
info "bypassing GitHub Actions variables..."
|
||||||
|
|
||||||
############################
|
############################
|
||||||
# Set the GITHUB_WORKSPACE #
|
# Set the GITHUB_WORKSPACE #
|
||||||
|
@ -704,11 +713,10 @@ GetGitHubVars() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d "${GITHUB_WORKSPACE}" ]; then
|
if [ ! -d "${GITHUB_WORKSPACE}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC} Provided volume is not a directory!${NC}"
|
fatal "Provided volume is not a directory!"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Linting all files in mapped directory:[${DEFAULT_WORKSPACE}]"
|
info "Linting all files in mapped directory:[${DEFAULT_WORKSPACE}]"
|
||||||
|
|
||||||
# No need to touch or set the GITHUB_SHA
|
# No need to touch or set the GITHUB_SHA
|
||||||
# No need to touch or set the GITHUB_EVENT_PATH
|
# No need to touch or set the GITHUB_EVENT_PATH
|
||||||
|
@ -724,33 +732,30 @@ GetGitHubVars() {
|
||||||
# Validate we have a value #
|
# Validate we have a value #
|
||||||
############################
|
############################
|
||||||
if [ -z "${GITHUB_SHA}" ]; then
|
if [ -z "${GITHUB_SHA}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_SHA]!${NC}"
|
error "Failed to get [GITHUB_SHA]!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_SHA}]${NC}"
|
fatal "[${GITHUB_SHA}]"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_SHA]${F[B]}, value:${F[W]}[${GITHUB_SHA}]${NC}"
|
info "Successfully found:${F[W]}[GITHUB_SHA]${F[B]}, value:${F[W]}[${GITHUB_SHA}]"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
############################
|
############################
|
||||||
# Validate we have a value #
|
# Validate we have a value #
|
||||||
############################
|
############################
|
||||||
if [ -z "${GITHUB_WORKSPACE}" ]; then
|
if [ -z "${GITHUB_WORKSPACE}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_WORKSPACE]!${NC}"
|
error "Failed to get [GITHUB_WORKSPACE]!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_WORKSPACE}]${NC}"
|
fatal "[${GITHUB_WORKSPACE}]"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[${GITHUB_WORKSPACE}]${NC}"
|
info "Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[${GITHUB_WORKSPACE}]"
|
||||||
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 -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_EVENT_PATH]!${NC}"
|
error "Failed to get [GITHUB_EVENT_PATH]!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_EVENT_PATH}]${NC}"
|
fatal "[${GITHUB_EVENT_PATH}]"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_EVENT_PATH]${F[B]}, value:${F[W]}[${GITHUB_EVENT_PATH}]${F[B]}${NC}"
|
info "Successfully found:${F[W]}[GITHUB_EVENT_PATH]${F[B]}, value:${F[W]}[${GITHUB_EVENT_PATH}]${F[B]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##################################################
|
##################################################
|
||||||
|
@ -766,11 +771,10 @@ GetGitHubVars() {
|
||||||
# Validate we have a value #
|
# Validate we have a value #
|
||||||
############################
|
############################
|
||||||
if [ -z "${GITHUB_ORG}" ]; then
|
if [ -z "${GITHUB_ORG}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_ORG]!${NC}"
|
error "Failed to get [GITHUB_ORG]!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_ORG}]${NC}"
|
fatal "[${GITHUB_ORG}]"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_ORG]${F[B]}, value:${F[W]}[${GITHUB_ORG}]${NC}"
|
info "Successfully found:${F[W]}[GITHUB_ORG]${F[B]}, value:${F[W]}[${GITHUB_ORG}]"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
|
@ -782,11 +786,10 @@ GetGitHubVars() {
|
||||||
# Validate we have a value #
|
# Validate we have a value #
|
||||||
############################
|
############################
|
||||||
if [ -z "${GITHUB_REPO}" ]; then
|
if [ -z "${GITHUB_REPO}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_REPO]!${NC}"
|
error "Failed to get [GITHUB_REPO]!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_REPO}]${NC}"
|
fatal "[${GITHUB_REPO}]"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_REPO]${F[B]}, value:${F[W]}[${GITHUB_REPO}]${NC}"
|
info "Successfully found:${F[W]}[GITHUB_REPO]${F[B]}, value:${F[W]}[${GITHUB_REPO}]"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -794,16 +797,16 @@ GetGitHubVars() {
|
||||||
# Validate we have a value #
|
# Validate we have a value #
|
||||||
############################
|
############################
|
||||||
if [ -z "${GITHUB_TOKEN}" ] && [[ ${RUN_LOCAL} == "false" ]]; then
|
if [ -z "${GITHUB_TOKEN}" ] && [[ ${RUN_LOCAL} == "false" ]]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_TOKEN]!${NC}"
|
error "Failed to get [GITHUB_TOKEN]!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_TOKEN}]${NC}"
|
error "[${GITHUB_TOKEN}]"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Please set a [GITHUB_TOKEN] from the main workflow environment to take advantage of multiple status reports!${NC}"
|
error "Please set a [GITHUB_TOKEN] from the main workflow environment to take advantage of multiple status reports!"
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Need to set MULTI_STATUS to false as we cant hit API endpoints without token #
|
# Need to set MULTI_STATUS to false as we cant hit API endpoints without token #
|
||||||
################################################################################
|
################################################################################
|
||||||
MULTI_STATUS='false'
|
MULTI_STATUS='false'
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_TOKEN]${NC}"
|
info "Successfully found:${F[W]}[GITHUB_TOKEN]"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###############################
|
###############################
|
||||||
|
@ -819,22 +822,20 @@ GetGitHubVars() {
|
||||||
# Validate we have a value #
|
# Validate we have a value #
|
||||||
############################
|
############################
|
||||||
if [ -z "${GITHUB_REPOSITORY}" ]; then
|
if [ -z "${GITHUB_REPOSITORY}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_REPOSITORY]!${NC}"
|
error "Failed to get [GITHUB_REPOSITORY]!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_REPOSITORY}]${NC}"
|
fatal "[${GITHUB_REPOSITORY}]"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_REPOSITORY]${F[B]}, value:${F[W]}[${GITHUB_REPOSITORY}]${NC}"
|
info "Successfully found:${F[W]}[GITHUB_REPOSITORY]${F[B]}, value:${F[W]}[${GITHUB_REPOSITORY}]"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
############################
|
############################
|
||||||
# Validate we have a value #
|
# Validate we have a value #
|
||||||
############################
|
############################
|
||||||
if [ -z "${GITHUB_RUN_ID}" ]; then
|
if [ -z "${GITHUB_RUN_ID}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_RUN_ID]!${NC}"
|
error "Failed to get [GITHUB_RUN_ID]!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_RUN_ID}]${NC}"
|
fatal "[${GITHUB_RUN_ID}]"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_RUN_ID]${F[B]}, value:${F[W]}[${GITHUB_RUN_ID}]${NC}"
|
info "Successfully found:${F[W]}[GITHUB_RUN_ID]${F[B]}, value:${F[W]}[${GITHUB_RUN_ID}]"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -846,16 +847,14 @@ function ValidatePowershellModules() {
|
||||||
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
|
fatal "Failed to find module."
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#########################################
|
#########################################
|
||||||
# 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
|
fatal "Failed to find module."
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
|
@ -868,15 +867,12 @@ function ValidatePowershellModules() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# Failed
|
# Failed
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed find module [PSScriptAnalyzer] for [${LINTER_NAME}] in system!${NC}"
|
error "Failed find module [PSScriptAnalyzer] for [${LINTER_NAME}] in system!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[PSSA_MODULE ${VALIDATE_PSSA_MODULE}] [PSSA_CMD ${VALIDATE_PSSA_CMD}]${NC}"
|
fatal "[PSSA_MODULE ${VALIDATE_PSSA_MODULE}] [PSSA_CMD ${VALIDATE_PSSA_CMD}]"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
# Success
|
# Success
|
||||||
if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then
|
debug "Successfully found module ${F[W]}[${VALIDATE_PSSA_MODULE}]${F[B]} in system"
|
||||||
echo -e "${NC}${F[B]}Successfully found module ${F[W]}[${VALIDATE_PSSA_MODULE}]${F[B]} in system${NC}"
|
debug "Successfully found command ${F[W]}[${VALIDATE_PSSA_CMD}]${F[B]} in system"
|
||||||
echo -e "${NC}${F[B]}Successfully found command ${F[W]}[${VALIDATE_PSSA_CMD}]${F[B]} in system${NC}"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -885,11 +881,11 @@ CallStatusAPI() {
|
||||||
####################
|
####################
|
||||||
# Pull in the vars #
|
# Pull in the vars #
|
||||||
####################
|
####################
|
||||||
LANGUAGE="${1}" # langauge that was validated
|
LANGUAGE="${1}" # langauge that was validated
|
||||||
STATUS="${2}" # success | error
|
STATUS="${2}" # success | error
|
||||||
SUCCESS_MSG='No errors were found in the linting process'
|
SUCCESS_MSG='No errors were found in the linting process'
|
||||||
FAIL_MSG='Errors were detected, please view logs'
|
FAIL_MSG='Errors were detected, please view logs'
|
||||||
MESSAGE='' # Message to send to status API
|
MESSAGE='' # Message to send to status API
|
||||||
|
|
||||||
######################################
|
######################################
|
||||||
# Check the status to create message #
|
# Check the status to create message #
|
||||||
|
@ -929,8 +925,8 @@ CallStatusAPI() {
|
||||||
##############################
|
##############################
|
||||||
if [ "${ERROR_CODE}" -ne 0 ]; then
|
if [ "${ERROR_CODE}" -ne 0 ]; then
|
||||||
# ERROR
|
# ERROR
|
||||||
echo "ERROR! Failed to call GitHub Status API!"
|
info "ERROR! Failed to call GitHub Status API!"
|
||||||
echo "ERROR:[${SEND_STATUS_CMD}]"
|
info "ERROR:[${SEND_STATUS_CMD}]"
|
||||||
# Not going to fail the script on this yet...
|
# Not going to fail the script on this yet...
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -938,39 +934,35 @@ CallStatusAPI() {
|
||||||
################################################################################
|
################################################################################
|
||||||
#### Function Reports ##########################################################
|
#### Function Reports ##########################################################
|
||||||
Reports() {
|
Reports() {
|
||||||
echo ""
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
info "Generated reports:"
|
||||||
echo "Generated reports:"
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
###################################
|
###################################
|
||||||
# Prints output report if enabled #
|
# Prints output report if enabled #
|
||||||
###################################
|
###################################
|
||||||
if [ -z "${FORMAT_REPORT}" ] ; then
|
if [ -z "${FORMAT_REPORT}" ]; then
|
||||||
echo "Reports generated in folder ${REPORT_OUTPUT_FOLDER}"
|
info "Reports generated in folder ${REPORT_OUTPUT_FOLDER}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
################################
|
################################
|
||||||
# Prints for warnings if found #
|
# Prints for warnings if found #
|
||||||
################################
|
################################
|
||||||
for TEST in "${WARNING_ARRAY_TEST[@]}"; do
|
for TEST in "${WARNING_ARRAY_TEST[@]}"; do
|
||||||
echo -e "${NC}${F[Y]}WARN!${NC} Expected file to compare with was not found for ${TEST}${NC}"
|
warn "Expected file to compare with was not found for ${TEST}"
|
||||||
done
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
#### Function Footer ###########################################################
|
#### Function Footer ###########################################################
|
||||||
Footer() {
|
Footer() {
|
||||||
echo ""
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
info "The script has completed"
|
||||||
echo "The script has completed"
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
####################################################
|
####################################################
|
||||||
# Need to clean up the lanuage array of duplicates #
|
# Need to clean up the lanuage array of duplicates #
|
||||||
|
@ -989,12 +981,12 @@ Footer() {
|
||||||
##################
|
##################
|
||||||
# Print if not 0 #
|
# Print if not 0 #
|
||||||
##################
|
##################
|
||||||
if [[ "${!ERROR_COUNTER}" -ne 0 ]]; then
|
if [[ ${!ERROR_COUNTER} -ne 0 ]]; then
|
||||||
# We found errors in the language
|
# We found errors in the language
|
||||||
###################
|
###################
|
||||||
# Print the goods #
|
# Print the goods #
|
||||||
###################
|
###################
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERRORS FOUND${NC} in ${LANGUAGE}:[${!ERROR_COUNTER}]${NC}"
|
error "ERRORS FOUND${NC} in ${LANGUAGE}:[${!ERROR_COUNTER}]"
|
||||||
|
|
||||||
#########################################
|
#########################################
|
||||||
# Create status API for Failed language #
|
# Create status API for Failed language #
|
||||||
|
@ -1003,7 +995,7 @@ Footer() {
|
||||||
######################################
|
######################################
|
||||||
# Check if we validated the langauge #
|
# Check if we validated the langauge #
|
||||||
######################################
|
######################################
|
||||||
elif [[ "${!ERROR_COUNTER}" -eq 0 ]] && [[ "${UNIQUE_LINTED_ARRAY[*]}" =~ ${LANGUAGE} ]]; then
|
elif [[ ${!ERROR_COUNTER} -eq 0 ]] && [[ ${UNIQUE_LINTED_ARRAY[*]} =~ ${LANGUAGE} ]]; then
|
||||||
# No errors found when linting the language
|
# No errors found when linting the language
|
||||||
CallStatusAPI "${LANGUAGE}" "success"
|
CallStatusAPI "${LANGUAGE}" "success"
|
||||||
fi
|
fi
|
||||||
|
@ -1013,7 +1005,7 @@ Footer() {
|
||||||
# Exit with 0 if errors disabled #
|
# Exit with 0 if errors disabled #
|
||||||
##################################
|
##################################
|
||||||
if [ "${DISABLE_ERRORS}" == "true" ]; then
|
if [ "${DISABLE_ERRORS}" == "true" ]; then
|
||||||
echo -e "${NC}${F[Y]}WARN!${NC} Exiting with exit code:[0] as:[DISABLE_ERRORS] was set to:[${DISABLE_ERRORS}]${NC}"
|
warn "Exiting with exit code:[0] as:[DISABLE_ERRORS] was set to:[${DISABLE_ERRORS}]"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -1025,24 +1017,33 @@ Footer() {
|
||||||
# build the variable
|
# build the variable
|
||||||
ERRORS_FOUND_LANGUAGE="ERRORS_FOUND_${LANGUAGE}"
|
ERRORS_FOUND_LANGUAGE="ERRORS_FOUND_${LANGUAGE}"
|
||||||
# Check if error was found
|
# Check if error was found
|
||||||
if [[ "${!ERRORS_FOUND_LANGUAGE}" -ne 0 ]]; then
|
if [[ ${!ERRORS_FOUND_LANGUAGE} -ne 0 ]]; then
|
||||||
# Failed exit
|
# Failed exit
|
||||||
echo -e "${NC}${F[R]}Exiting with errors found!${NC}"
|
fatal "Exiting with errors found!"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
########################
|
########################
|
||||||
# Footer prints Exit 0 #
|
# Footer prints Exit 0 #
|
||||||
########################
|
########################
|
||||||
echo ""
|
notice "All file(s) linted successfully with no errors detected"
|
||||||
echo -e "${NC}${F[G]}All file(s) linted successfully with no errors detected${NC}"
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
|
||||||
echo ""
|
|
||||||
# Successful exit
|
# Successful exit
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#### Function Cleanup ##########################################################
|
||||||
|
cleanup() {
|
||||||
|
local -ri EXIT_CODE=$?
|
||||||
|
|
||||||
|
sh -c "cat ${LOG_TEMP} >> ${GITHUB_WORKSPACE}/${LOG_FILE}" || true
|
||||||
|
|
||||||
|
exit ${EXIT_CODE}
|
||||||
|
trap - 0 1 2 3 6 14 15
|
||||||
|
}
|
||||||
|
trap 'cleanup' 0 1 2 3 6 14 15
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
############################### MAIN ###########################################
|
############################### MAIN ###########################################
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -1056,10 +1057,9 @@ Header
|
||||||
# check flag for validating the report folder does not exist #
|
# check flag for validating the report folder does not exist #
|
||||||
##############################################################
|
##############################################################
|
||||||
if [ -n "${OUTPUT_FORMAT}" ]; then
|
if [ -n "${OUTPUT_FORMAT}" ]; then
|
||||||
if [ -d "${REPORT_OUTPUT_FOLDER}" ] ; then
|
if [ -d "${REPORT_OUTPUT_FOLDER}" ]; then
|
||||||
echo "ERROR! Found ${REPORT_OUTPUT_FOLDER}"
|
error "ERROR! Found ${REPORT_OUTPUT_FOLDER}"
|
||||||
echo "Please remove the folder and try again."
|
fatal "Please remove the folder and try again."
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -1119,15 +1119,10 @@ GetLinterRules "TYPESCRIPT"
|
||||||
# Get YAML rules
|
# Get YAML rules
|
||||||
GetLinterRules "YAML"
|
GetLinterRules "YAML"
|
||||||
|
|
||||||
#################################
|
##################################
|
||||||
# Check if were in verbose mode #
|
# Get and print all version info #
|
||||||
#################################
|
##################################
|
||||||
if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then
|
GetLinterVersions
|
||||||
##################################
|
|
||||||
# Get and print all version info #
|
|
||||||
##################################
|
|
||||||
GetLinterVersions
|
|
||||||
fi
|
|
||||||
|
|
||||||
###########################################
|
###########################################
|
||||||
# Check to see if this is a test case run #
|
# Check to see if this is a test case run #
|
||||||
|
@ -1563,10 +1558,10 @@ if [ "${VALIDATE_RAKU}" == "true" ]; then
|
||||||
#######################
|
#######################
|
||||||
# Lint the raku files #
|
# Lint the raku files #
|
||||||
#######################
|
#######################
|
||||||
echo "${GITHUB_WORKSPACE}/META6.json"
|
info "${GITHUB_WORKSPACE}/META6.json"
|
||||||
if [ -e "${GITHUB_WORKSPACE}/META6.json" ]; then
|
if [ -e "${GITHUB_WORKSPACE}/META6.json" ]; then
|
||||||
cd "${GITHUB_WORKSPACE}" && zef install --deps-only --/test .
|
cd "${GITHUB_WORKSPACE}" && zef install --deps-only --/test .
|
||||||
fi
|
fi
|
||||||
# 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 "RAKU" "raku" "raku -I ${GITHUB_WORKSPACE}/lib -c" ".*\.\(raku\|rakumod\|rakutest\|pm6\|pl6\|p6\)\$" "${FILE_ARRAY_RAKU[@]}"
|
LintCodebase "RAKU" "raku" "raku -I ${GITHUB_WORKSPACE}/lib -c" ".*\.\(raku\|rakumod\|rakutest\|pm6\|pl6\|p6\)\$" "${FILE_ARRAY_RAKU[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
53
lib/log.sh
Normal file
53
lib/log.sh
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
#!/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
|
||||||
|
|
||||||
|
# Log Functions
|
||||||
|
LOG_TEMP=$(mktemp) || echo "Failed to create temporary log file."
|
||||||
|
export LOG_TEMP
|
||||||
|
echo "super-linter Log" > "${LOG_TEMP}"
|
||||||
|
log() {
|
||||||
|
local TOTERM=${1:-}
|
||||||
|
local MESSAGE=${2:-}
|
||||||
|
echo -e "${MESSAGE:-}" | (
|
||||||
|
if [[ -n ${TOTERM} ]]; then
|
||||||
|
tee -a "${LOG_TEMP}" >&2
|
||||||
|
else
|
||||||
|
cat >> "${LOG_TEMP}" 2>&1
|
||||||
|
fi
|
||||||
|
)
|
||||||
|
}
|
||||||
|
trace() { log "${LOG_TRACE:-}" "${NC}$(date +"%F %T") ${F[B]}[TRACE ]${NC} $*${NC}"; }
|
||||||
|
debug() { log "${LOG_DEBUG:-}" "${NC}$(date +"%F %T") ${F[B]}[DEBUG ]${NC} $*${NC}"; }
|
||||||
|
info() { log "${LOG_VERBOSE:-}" "${NC}$(date +"%F %T") ${F[B]}[INFO ]${NC} $*${NC}"; }
|
||||||
|
notice() { log "true" "${NC}$(date +"%F %T") ${F[G]}[NOTICE]${NC} $*${NC}"; }
|
||||||
|
warn() { log "true" "${NC}$(date +"%F %T") ${F[Y]}[WARN ]${NC} $*${NC}"; }
|
||||||
|
error() { log "true" "${NC}$(date +"%F %T") ${F[R]}[ERROR ]${NC} $*${NC}"; }
|
||||||
|
fatal() {
|
||||||
|
log "true" "${NC}$(date +"%F %T") ${B[R]}${F[W]}[FATAL ]${NC} $*${NC}"
|
||||||
|
exit 1
|
||||||
|
}
|
|
@ -1,27 +0,0 @@
|
||||||
#!/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
|
|
|
@ -13,9 +13,8 @@ function GetValidationInfo() {
|
||||||
############################################
|
############################################
|
||||||
# Print headers for user provided env vars #
|
# Print headers for user provided env vars #
|
||||||
############################################
|
############################################
|
||||||
echo ""
|
info "--------------------------------------------"
|
||||||
echo "--------------------------------------------"
|
info "Gathering user validation information..."
|
||||||
echo "Gathering user validation information..."
|
|
||||||
|
|
||||||
###########################################
|
###########################################
|
||||||
# Skip validation if were running locally #
|
# Skip validation if were running locally #
|
||||||
|
@ -31,10 +30,10 @@ function GetValidationInfo() {
|
||||||
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..."
|
info "- Validating ALL files in code base..."
|
||||||
else
|
else
|
||||||
# Its false
|
# Its false
|
||||||
echo "- Only validating [new], or [edited] files in code base..."
|
info "- Only validating [new], or [edited] files in code base..."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -167,23 +166,19 @@ function GetValidationInfo() {
|
||||||
ACTIONS_RUNNER_DEBUG="true"
|
ACTIONS_RUNNER_DEBUG="true"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###################
|
###########################
|
||||||
# Debug on runner #
|
# Print the validate info #
|
||||||
###################
|
###########################
|
||||||
if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then
|
for LINE in "${PRINT_ARRAY[@]}"; do
|
||||||
###########################
|
debug "${LINE}"
|
||||||
# Print the validate info #
|
done
|
||||||
###########################
|
|
||||||
for LINE in "${PRINT_ARRAY[@]}"; do
|
|
||||||
echo "${LINE}"
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "--- DEBUG INFO ---"
|
debug "--- DEBUG INFO ---"
|
||||||
echo "---------------------------------------------"
|
debug "---------------------------------------------"
|
||||||
RUNNER=$(whoami)
|
RUNNER=$(whoami)
|
||||||
echo "Runner:[${RUNNER}]"
|
debug "Runner:[${RUNNER}]"
|
||||||
echo "ENV:"
|
PRINTENV=$(printenv)
|
||||||
printenv
|
debug "ENV:"
|
||||||
echo "---------------------------------------------"
|
debug "${PRINTENV}"
|
||||||
fi
|
debug "---------------------------------------------"
|
||||||
}
|
}
|
||||||
|
|
190
lib/worker.sh
190
lib/worker.sh
|
@ -17,7 +17,7 @@ function LintCodebase() {
|
||||||
LINTER_NAME="${1}" && shift # Pull the variable and remove from array path (Example: jsonlint)
|
LINTER_NAME="${1}" && shift # Pull the variable and remove from array path (Example: jsonlint)
|
||||||
LINTER_COMMAND="${1}" && shift # Pull the variable and remove from array path (Example: jsonlint -c ConfigFile /path/to/file)
|
LINTER_COMMAND="${1}" && shift # Pull the variable and remove from array path (Example: jsonlint -c ConfigFile /path/to/file)
|
||||||
FILE_EXTENSIONS="${1}" && shift # Pull the variable and remove from array path (Example: *.json)
|
FILE_EXTENSIONS="${1}" && shift # Pull the variable and remove from array path (Example: *.json)
|
||||||
FILE_ARRAY=("$@") # Array of files to validate (Example: ${FILE_ARRAY_JSON})
|
FILE_ARRAY=("$@") # Array of files to validate (Example: ${FILE_ARRAY_JSON})
|
||||||
|
|
||||||
######################
|
######################
|
||||||
# Create Print Array #
|
# Create Print Array #
|
||||||
|
@ -49,14 +49,11 @@ function LintCodebase() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# Failed
|
# Failed
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find [${LINTER_NAME}] in system!${NC}"
|
error "Failed to find [${LINTER_NAME}] in system!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${VALIDATE_INSTALL_CMD}]${NC}"
|
fatal "[${VALIDATE_INSTALL_CMD}]"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
# Success
|
# Success
|
||||||
if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then
|
debug "Successfully found binary for ${F[W]}[${LINTER_NAME}]${F[B]} in system location: ${F[W]}[${VALIDATE_INSTALL_CMD}]"
|
||||||
echo -e "${NC}${F[B]}Successfully found binary for ${F[W]}[${LINTER_NAME}]${F[B]} in system location: ${F[W]}[${VALIDATE_INSTALL_CMD}]${NC}"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
|
@ -75,7 +72,7 @@ function LintCodebase() {
|
||||||
if [ ${#FILE_ARRAY[@]} -eq 0 ] && [ "${VALIDATE_ALL_CODEBASE}" == "false" ]; then
|
if [ ${#FILE_ARRAY[@]} -eq 0 ] && [ "${VALIDATE_ALL_CODEBASE}" == "false" ]; then
|
||||||
# No files found in commit and user has asked to not validate code base
|
# No files found in commit and user has asked to not validate code base
|
||||||
SKIP_FLAG=1
|
SKIP_FLAG=1
|
||||||
# echo " - No files found in changeset to lint for language:[${FILE_TYPE}]"
|
debug " - No files found in changeset to lint for language:[${FILE_TYPE}]"
|
||||||
elif [ ${#FILE_ARRAY[@]} -ne 0 ]; then
|
elif [ ${#FILE_ARRAY[@]} -ne 0 ]; then
|
||||||
# We have files added to array of files to check
|
# We have files added to array of files to check
|
||||||
LIST_FILES=("${FILE_ARRAY[@]}") # Copy the array into list
|
LIST_FILES=("${FILE_ARRAY[@]}") # Copy the array into list
|
||||||
|
@ -121,13 +118,13 @@ function LintCodebase() {
|
||||||
#########################
|
#########################
|
||||||
# Print the header info #
|
# Print the header info #
|
||||||
#########################
|
#########################
|
||||||
echo "${LINE}"
|
info "${LINE}"
|
||||||
done
|
done
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
# Prepare context if TAP format output #
|
# Prepare context if TAP format output #
|
||||||
########################################
|
########################################
|
||||||
if IsTAP ; then
|
if IsTAP; then
|
||||||
TMPFILE=$(mktemp -q "/tmp/super-linter-${FILE_TYPE}.XXXXXX")
|
TMPFILE=$(mktemp -q "/tmp/super-linter-${FILE_TYPE}.XXXXXX")
|
||||||
INDEX=0
|
INDEX=0
|
||||||
mkdir -p "${REPORT_OUTPUT_FOLDER}"
|
mkdir -p "${REPORT_OUTPUT_FOLDER}"
|
||||||
|
@ -166,8 +163,8 @@ function LintCodebase() {
|
||||||
##############
|
##############
|
||||||
# File print #
|
# File print #
|
||||||
##############
|
##############
|
||||||
echo "---------------------------"
|
info "---------------------------"
|
||||||
echo "File:[${FILE}]"
|
info "File:[${FILE}]"
|
||||||
|
|
||||||
#################################
|
#################################
|
||||||
# Add the language to the array #
|
# Add the language to the array #
|
||||||
|
@ -226,16 +223,16 @@ function LintCodebase() {
|
||||||
#########
|
#########
|
||||||
# Error #
|
# Error #
|
||||||
#########
|
#########
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [${LINTER_NAME}] linter!${NC}"
|
error "Found errors in [${LINTER_NAME}] linter!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${LINT_CMD}]${NC}"
|
error "[${LINT_CMD}]"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC} Linter CMD:[${LINTER_COMMAND} ${FILE}]${NC}"
|
error "Linter CMD:[${LINTER_COMMAND} ${FILE}]"
|
||||||
# Increment the error count
|
# Increment the error count
|
||||||
(("ERRORS_FOUND_${FILE_TYPE}++"))
|
(("ERRORS_FOUND_${FILE_TYPE}++"))
|
||||||
|
|
||||||
#######################################################
|
#######################################################
|
||||||
# Store the linting as a temporary file in TAP format #
|
# Store the linting as a temporary file in TAP format #
|
||||||
#######################################################
|
#######################################################
|
||||||
if IsTAP ; then
|
if IsTAP; then
|
||||||
NotOkTap "${INDEX}" "${FILE}" "${TMPFILE}"
|
NotOkTap "${INDEX}" "${FILE}" "${TMPFILE}"
|
||||||
AddDetailedMessageIfEnabled "${LINT_CMD}" "${TMPFILE}"
|
AddDetailedMessageIfEnabled "${LINT_CMD}" "${TMPFILE}"
|
||||||
fi
|
fi
|
||||||
|
@ -243,12 +240,12 @@ function LintCodebase() {
|
||||||
###########
|
###########
|
||||||
# Success #
|
# Success #
|
||||||
###########
|
###########
|
||||||
echo -e "${NC}${F[B]} - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully${NC}"
|
info " - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully"
|
||||||
|
|
||||||
#######################################################
|
#######################################################
|
||||||
# Store the linting as a temporary file in TAP format #
|
# Store the linting as a temporary file in TAP format #
|
||||||
#######################################################
|
#######################################################
|
||||||
if IsTAP ; then
|
if IsTAP; then
|
||||||
OkTap "${INDEX}" "${FILE}" "${TMPFILE}"
|
OkTap "${INDEX}" "${FILE}" "${TMPFILE}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -257,7 +254,7 @@ function LintCodebase() {
|
||||||
#################################
|
#################################
|
||||||
# Generate report in TAP format #
|
# Generate report in TAP format #
|
||||||
#################################
|
#################################
|
||||||
if IsTAP && [ ${INDEX} -gt 0 ] ; then
|
if IsTAP && [ ${INDEX} -gt 0 ]; then
|
||||||
HeaderTap "${INDEX}" "${REPORT_OUTPUT_FILE}"
|
HeaderTap "${INDEX}" "${REPORT_OUTPUT_FILE}"
|
||||||
cat "${TMPFILE}" >> "${REPORT_OUTPUT_FILE}"
|
cat "${TMPFILE}" >> "${REPORT_OUTPUT_FILE}"
|
||||||
fi
|
fi
|
||||||
|
@ -274,18 +271,16 @@ function TestCodebase() {
|
||||||
LINTER_COMMAND="${3}" # Pull the variable and remove from array path (Example: jsonlint -c ConfigFile /path/to/file)
|
LINTER_COMMAND="${3}" # Pull the variable and remove from array path (Example: jsonlint -c ConfigFile /path/to/file)
|
||||||
FILE_EXTENSIONS="${4}" # Pull the variable and remove from array path (Example: *.json)
|
FILE_EXTENSIONS="${4}" # Pull the variable and remove from array path (Example: *.json)
|
||||||
INDVIDUAL_TEST_FOLDER="${5}" # Folder for specific tests
|
INDVIDUAL_TEST_FOLDER="${5}" # Folder for specific tests
|
||||||
TESTS_RAN=0 # Incremented when tests are ran, this will help find failed finds
|
TESTS_RAN=0 # Incremented when tests are ran, this will help find failed finds
|
||||||
|
|
||||||
################
|
################
|
||||||
# print header #
|
# print header #
|
||||||
################
|
################
|
||||||
echo ""
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
info "Testing Codebase [${FILE_TYPE}] files..."
|
||||||
echo "Testing Codebase [${FILE_TYPE}] files..."
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
# Validate we have linter installed #
|
# Validate we have linter installed #
|
||||||
|
@ -302,12 +297,11 @@ function TestCodebase() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# Failed
|
# Failed
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find [${LINTER_NAME}] in system!${NC}"
|
error "Failed to find [${LINTER_NAME}] in system!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${VALIDATE_INSTALL_CMD}]${NC}"
|
fatal "[${VALIDATE_INSTALL_CMD}]"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
# Success
|
# Success
|
||||||
echo -e "${NC}${F[B]}Successfully found binary for ${F[W]}[${LINTER_NAME}]${F[B]} in system location: ${F[W]}[${VALIDATE_INSTALL_CMD}]${NC}"
|
info "Successfully found binary for ${F[W]}[${LINTER_NAME}]${F[B]} in system location: ${F[W]}[${VALIDATE_INSTALL_CMD}]"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
|
@ -323,7 +317,7 @@ function TestCodebase() {
|
||||||
########################################
|
########################################
|
||||||
# Prepare context if TAP output format #
|
# Prepare context if TAP output format #
|
||||||
########################################
|
########################################
|
||||||
if IsTAP ; then
|
if IsTAP; then
|
||||||
TMPFILE=$(mktemp -q "/tmp/super-linter-${FILE_TYPE}.XXXXXX")
|
TMPFILE=$(mktemp -q "/tmp/super-linter-${FILE_TYPE}.XXXXXX")
|
||||||
mkdir -p "${REPORT_OUTPUT_FOLDER}"
|
mkdir -p "${REPORT_OUTPUT_FOLDER}"
|
||||||
REPORT_OUTPUT_FILE="${REPORT_OUTPUT_FOLDER}/super-linter-${FILE_TYPE}.${OUTPUT_FORMAT}"
|
REPORT_OUTPUT_FILE="${REPORT_OUTPUT_FOLDER}/super-linter-${FILE_TYPE}.${OUTPUT_FORMAT}"
|
||||||
|
@ -358,8 +352,8 @@ function TestCodebase() {
|
||||||
##############
|
##############
|
||||||
# File print #
|
# File print #
|
||||||
##############
|
##############
|
||||||
echo "---------------------------"
|
info "---------------------------"
|
||||||
echo "File:[${FILE}]"
|
info "File:[${FILE}]"
|
||||||
|
|
||||||
########################
|
########################
|
||||||
# Set the lint command #
|
# Set the lint command #
|
||||||
|
@ -454,21 +448,21 @@ function TestCodebase() {
|
||||||
#########
|
#########
|
||||||
# Error #
|
# Error #
|
||||||
#########
|
#########
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [${LINTER_NAME}] linter!${NC}"
|
error "Found errors in [${LINTER_NAME}] linter!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${LINT_CMD}]${NC}"
|
error "[${LINT_CMD}]"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC} Linter CMD:[${LINTER_COMMAND} ${FILE}]${NC}"
|
error "Linter CMD:[${LINTER_COMMAND} ${FILE}]"
|
||||||
# Increment the error count
|
# Increment the error count
|
||||||
(("ERRORS_FOUND_${FILE_TYPE}++"))
|
(("ERRORS_FOUND_${FILE_TYPE}++"))
|
||||||
else
|
else
|
||||||
###########
|
###########
|
||||||
# Success #
|
# Success #
|
||||||
###########
|
###########
|
||||||
echo -e "${NC}${F[B]} - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully${NC}"
|
info " - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully"
|
||||||
fi
|
fi
|
||||||
#######################################################
|
#######################################################
|
||||||
# Store the linting as a temporary file in TAP format #
|
# Store the linting as a temporary file in TAP format #
|
||||||
#######################################################
|
#######################################################
|
||||||
if IsTAP ; then
|
if IsTAP; then
|
||||||
OkTap "${TESTS_RAN}" "${FILE_NAME}" "${TMPFILE}"
|
OkTap "${TESTS_RAN}" "${FILE_NAME}" "${TMPFILE}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
@ -482,23 +476,23 @@ function TestCodebase() {
|
||||||
#########
|
#########
|
||||||
# Error #
|
# Error #
|
||||||
#########
|
#########
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [${LINTER_NAME}] linter!${NC}"
|
error "Found errors in [${LINTER_NAME}] linter!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} This file should have failed test case!${NC}"
|
error "This file should have failed test case!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}Command run:${NC}[\$${LINT_CMD}]${NC}"
|
error "Command run:${NC}[\$${LINT_CMD}]"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${LINT_CMD}]${NC}"
|
error "[${LINT_CMD}]"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC} Linter CMD:[${LINTER_COMMAND} ${FILE}]${NC}"
|
error "Linter CMD:[${LINTER_COMMAND} ${FILE}]"
|
||||||
# Increment the error count
|
# Increment the error count
|
||||||
(("ERRORS_FOUND_${FILE_TYPE}++"))
|
(("ERRORS_FOUND_${FILE_TYPE}++"))
|
||||||
else
|
else
|
||||||
###########
|
###########
|
||||||
# Success #
|
# Success #
|
||||||
###########
|
###########
|
||||||
echo -e "${NC}${F[B]} - File:${F[W]}[${FILE_NAME}]${F[B]} failed test case with ${F[W]}[${LINTER_NAME}]${F[B]} successfully${NC}"
|
info " - File:${F[W]}[${FILE_NAME}]${F[B]} failed test case with ${F[W]}[${LINTER_NAME}]${F[B]} successfully"
|
||||||
fi
|
fi
|
||||||
#######################################################
|
#######################################################
|
||||||
# Store the linting as a temporary file in TAP format #
|
# Store the linting as a temporary file in TAP format #
|
||||||
#######################################################
|
#######################################################
|
||||||
if IsTAP ; then
|
if IsTAP; then
|
||||||
NotOkTap "${TESTS_RAN}" "${FILE_NAME}" "${TMPFILE}"
|
NotOkTap "${TESTS_RAN}" "${FILE_NAME}" "${TMPFILE}"
|
||||||
AddDetailedMessageIfEnabled "${LINT_CMD}" "${TMPFILE}"
|
AddDetailedMessageIfEnabled "${LINT_CMD}" "${TMPFILE}"
|
||||||
fi
|
fi
|
||||||
|
@ -508,7 +502,7 @@ function TestCodebase() {
|
||||||
###########################################################################
|
###########################################################################
|
||||||
# Generate report in TAP format and validate with the expected TAP output #
|
# Generate report in TAP format and validate with the expected TAP output #
|
||||||
###########################################################################
|
###########################################################################
|
||||||
if IsTAP && [ ${TESTS_RAN} -gt 0 ] ; then
|
if IsTAP && [ ${TESTS_RAN} -gt 0 ]; then
|
||||||
HeaderTap "${TESTS_RAN}" "${REPORT_OUTPUT_FILE}"
|
HeaderTap "${TESTS_RAN}" "${REPORT_OUTPUT_FILE}"
|
||||||
cat "${TMPFILE}" >> "${REPORT_OUTPUT_FILE}"
|
cat "${TMPFILE}" >> "${REPORT_OUTPUT_FILE}"
|
||||||
|
|
||||||
|
@ -516,24 +510,24 @@ function TestCodebase() {
|
||||||
# If expected TAP report exists then compare with the generated report #
|
# If expected TAP report exists then compare with the generated report #
|
||||||
########################################################################
|
########################################################################
|
||||||
EXPECTED_FILE="${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}/${INDVIDUAL_TEST_FOLDER}/reports/expected-${FILE_TYPE}.tap"
|
EXPECTED_FILE="${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}/${INDVIDUAL_TEST_FOLDER}/reports/expected-${FILE_TYPE}.tap"
|
||||||
if [ -e "${EXPECTED_FILE}" ] ; then
|
if [ -e "${EXPECTED_FILE}" ]; then
|
||||||
TMPFILE=$(mktemp -q "/tmp/diff-${FILE_TYPE}.XXXXXX")
|
TMPFILE=$(mktemp -q "/tmp/diff-${FILE_TYPE}.XXXXXX")
|
||||||
## Ignore white spaces, case sensitive
|
## Ignore white spaces, case sensitive
|
||||||
if ! diff -a -w -i "${EXPECTED_FILE}" "${REPORT_OUTPUT_FILE}" > "${TMPFILE}" 2>&1; then
|
if ! diff -a -w -i "${EXPECTED_FILE}" "${REPORT_OUTPUT_FILE}" > "${TMPFILE}" 2>&1; then
|
||||||
#############################################
|
#############################################
|
||||||
# We failed to compare the reporting output #
|
# We failed to compare the reporting output #
|
||||||
#############################################
|
#############################################
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to assert TAP output:[${LINTER_NAME}]${NC}"!
|
error "Failed to assert TAP output:[${LINTER_NAME}]"!
|
||||||
echo "Please validate the asserts!"
|
info "Please validate the asserts!"
|
||||||
cat "${TMPFILE}"
|
cat "${TMPFILE}"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
# Success
|
# Success
|
||||||
echo -e "${NC}${F[B]}Successfully validation in the expected TAP format for ${F[W]}[${LINTER_NAME}]${NC}"
|
info "Successfully validation in the expected TAP format for ${F[W]}[${LINTER_NAME}]"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[Y]}WARN!${NC} No TAP expected file found at:[${EXPECTED_FILE}]${NC}"
|
warn "No TAP expected file found at:[${EXPECTED_FILE}]"
|
||||||
echo "skipping report assertions"
|
info "skipping report assertions"
|
||||||
#####################################
|
#####################################
|
||||||
# Append the file type to the array #
|
# Append the file type to the array #
|
||||||
#####################################
|
#####################################
|
||||||
|
@ -548,9 +542,8 @@ function TestCodebase() {
|
||||||
#################################################
|
#################################################
|
||||||
# We failed to find files and no tests were ran #
|
# We failed to find files and no tests were ran #
|
||||||
#################################################
|
#################################################
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find any tests ran for the Linter:[${LINTER_NAME}]${NC}"!
|
error "Failed to find any tests ran for the Linter:[${LINTER_NAME}]"!
|
||||||
echo "Please validate logic or that tests exist!"
|
fatal "Please validate logic or that tests exist!"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -567,11 +560,9 @@ function RunTestCases() {
|
||||||
#################
|
#################
|
||||||
# Header prints #
|
# Header prints #
|
||||||
#################
|
#################
|
||||||
echo ""
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
info "-------------- TEST CASE RUN -----------------"
|
||||||
echo "-------------- TEST CASE RUN -----------------"
|
info "----------------------------------------------"
|
||||||
echo "----------------------------------------------"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# Test case languages #
|
# Test case languages #
|
||||||
|
@ -660,16 +651,12 @@ function LintAnsibleFiles() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# Failed
|
# Failed
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find ${LINTER_NAME} in system!${NC}"
|
error "Failed to find ${LINTER_NAME} in system!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${VALIDATE_INSTALL_CMD}]${NC}"
|
fatal "[${VALIDATE_INSTALL_CMD}]"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
# Success
|
# Success
|
||||||
if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then
|
debug "Successfully found binary in system"
|
||||||
# Success
|
debug "Location:[${VALIDATE_INSTALL_CMD}]"
|
||||||
echo -e "${NC}${F[B]}Successfully found binary in system${NC}"
|
|
||||||
echo "Location:[${VALIDATE_INSTALL_CMD}]"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
|
@ -704,7 +691,7 @@ function LintAnsibleFiles() {
|
||||||
###################################
|
###################################
|
||||||
# Send message that were skipping #
|
# Send message that were skipping #
|
||||||
###################################
|
###################################
|
||||||
#echo "- Skipping Ansible lint run as file(s) that were modified were read only..."
|
debug "- Skipping Ansible lint run as file(s) that were modified were read only..."
|
||||||
############################
|
############################
|
||||||
# Create flag to skip loop #
|
# Create flag to skip loop #
|
||||||
############################
|
############################
|
||||||
|
@ -719,14 +706,14 @@ function LintAnsibleFiles() {
|
||||||
#########################
|
#########################
|
||||||
# Print the header line #
|
# Print the header line #
|
||||||
#########################
|
#########################
|
||||||
echo "${LINE}"
|
info "${LINE}"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
# Prepare context if TAP output format #
|
# Prepare context if TAP output format #
|
||||||
########################################
|
########################################
|
||||||
if IsTAP ; then
|
if IsTAP; then
|
||||||
TMPFILE=$(mktemp -q "/tmp/super-linter-${FILE_TYPE}.XXXXXX")
|
TMPFILE=$(mktemp -q "/tmp/super-linter-${FILE_TYPE}.XXXXXX")
|
||||||
INDEX=0
|
INDEX=0
|
||||||
mkdir -p "${REPORT_OUTPUT_FOLDER}"
|
mkdir -p "${REPORT_OUTPUT_FOLDER}"
|
||||||
|
@ -759,8 +746,8 @@ function LintAnsibleFiles() {
|
||||||
##############
|
##############
|
||||||
# File print #
|
# File print #
|
||||||
##############
|
##############
|
||||||
echo "---------------------------"
|
info "---------------------------"
|
||||||
echo "File:[${FILE}]"
|
info "File:[${FILE}]"
|
||||||
|
|
||||||
################################
|
################################
|
||||||
# Lint the file with the rules #
|
# Lint the file with the rules #
|
||||||
|
@ -779,15 +766,15 @@ function LintAnsibleFiles() {
|
||||||
#########
|
#########
|
||||||
# Error #
|
# Error #
|
||||||
#########
|
#########
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [${LINTER_NAME}] linter!${NC}"
|
error "Found errors in [${LINTER_NAME}] linter!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${LINT_CMD}]${NC}"
|
error "[${LINT_CMD}]"
|
||||||
# Increment error count
|
# Increment error count
|
||||||
((ERRORS_FOUND_ANSIBLE++))
|
((ERRORS_FOUND_ANSIBLE++))
|
||||||
|
|
||||||
#######################################################
|
#######################################################
|
||||||
# Store the linting as a temporary file in TAP format #
|
# Store the linting as a temporary file in TAP format #
|
||||||
#######################################################
|
#######################################################
|
||||||
if IsTAP ; then
|
if IsTAP; then
|
||||||
NotOkTap "${INDEX}" "${FILE}" "${TMPFILE}"
|
NotOkTap "${INDEX}" "${FILE}" "${TMPFILE}"
|
||||||
AddDetailedMessageIfEnabled "${LINT_CMD}" "${TMPFILE}"
|
AddDetailedMessageIfEnabled "${LINT_CMD}" "${TMPFILE}"
|
||||||
fi
|
fi
|
||||||
|
@ -796,12 +783,12 @@ function LintAnsibleFiles() {
|
||||||
###########
|
###########
|
||||||
# Success #
|
# Success #
|
||||||
###########
|
###########
|
||||||
echo -e "${NC}${F[B]} - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully${NC}"
|
info " - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully"
|
||||||
|
|
||||||
#######################################################
|
#######################################################
|
||||||
# Store the linting as a temporary file in TAP format #
|
# Store the linting as a temporary file in TAP format #
|
||||||
#######################################################
|
#######################################################
|
||||||
if IsTAP ; then
|
if IsTAP; then
|
||||||
OkTap "${INDEX}" "${FILE}" "${TMPFILE}"
|
OkTap "${INDEX}" "${FILE}" "${TMPFILE}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -810,27 +797,22 @@ function LintAnsibleFiles() {
|
||||||
#################################
|
#################################
|
||||||
# Generate report in TAP format #
|
# Generate report in TAP format #
|
||||||
#################################
|
#################################
|
||||||
if IsTAP && [ ${INDEX} -gt 0 ] ; then
|
if IsTAP && [ ${INDEX} -gt 0 ]; then
|
||||||
HeaderTap "${INDEX}" "${REPORT_OUTPUT_FILE}"
|
HeaderTap "${INDEX}" "${REPORT_OUTPUT_FILE}"
|
||||||
cat "${TMPFILE}" >> "${REPORT_OUTPUT_FILE}"
|
cat "${TMPFILE}" >> "${REPORT_OUTPUT_FILE}"
|
||||||
fi
|
fi
|
||||||
else # No ansible directory found in path
|
else
|
||||||
###############################
|
########################
|
||||||
# Check to see if debug is on #
|
# No Ansible dir found #
|
||||||
###############################
|
########################
|
||||||
if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then
|
warn "No Ansible base directory found at:[${ANSIBLE_DIRECTORY}]"
|
||||||
########################
|
debug "skipping ansible lint"
|
||||||
# No Ansible dir found #
|
|
||||||
########################
|
|
||||||
echo -e "${NC}${F[Y]}WARN!${NC} No Ansible base directory found at:[${ANSIBLE_DIRECTORY}]${NC}"
|
|
||||||
echo "skipping ansible lint"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
#### Function IsTap ############################################################
|
#### Function IsTap ############################################################
|
||||||
function IsTAP() {
|
function IsTAP() {
|
||||||
if [ "${OUTPUT_FORMAT}" == "tap" ] ; then
|
if [ "${OUTPUT_FORMAT}" == "tap" ]; then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
return 1
|
return 1
|
||||||
|
@ -840,7 +822,7 @@ function IsTAP() {
|
||||||
#### Function TransformTAPDetails ##############################################
|
#### Function TransformTAPDetails ##############################################
|
||||||
function TransformTAPDetails() {
|
function TransformTAPDetails() {
|
||||||
DATA=${1}
|
DATA=${1}
|
||||||
if [ -n "${DATA}" ] && [ "${OUTPUT_DETAILS}" == "detailed" ] ; then
|
if [ -n "${DATA}" ] && [ "${OUTPUT_DETAILS}" == "detailed" ]; then
|
||||||
#########################################################
|
#########################################################
|
||||||
# Transform new lines to \\n, remove colours and colons #
|
# Transform new lines to \\n, remove colours and colons #
|
||||||
#########################################################
|
#########################################################
|
||||||
|
@ -853,8 +835,8 @@ function HeaderTap() {
|
||||||
################
|
################
|
||||||
# Pull in Vars #
|
# Pull in Vars #
|
||||||
################
|
################
|
||||||
INDEX="${1}" # File being validated
|
INDEX="${1}" # File being validated
|
||||||
OUTPUT_FILE="${2}" # Output location
|
OUTPUT_FILE="${2}" # Output location
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# Print the goods #
|
# Print the goods #
|
||||||
|
@ -867,9 +849,9 @@ function OkTap() {
|
||||||
################
|
################
|
||||||
# Pull in Vars #
|
# Pull in Vars #
|
||||||
################
|
################
|
||||||
INDEX="${1}" # Location
|
INDEX="${1}" # Location
|
||||||
FILE="${2}" # File being validated
|
FILE="${2}" # File being validated
|
||||||
TEMP_FILE="${3}" # Temp file location
|
TEMP_FILE="${3}" # Temp file location
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# Print the goods #
|
# Print the goods #
|
||||||
|
@ -882,9 +864,9 @@ function NotOkTap() {
|
||||||
################
|
################
|
||||||
# Pull in Vars #
|
# Pull in Vars #
|
||||||
################
|
################
|
||||||
INDEX="${1}" # Location
|
INDEX="${1}" # Location
|
||||||
FILE="${2}" # File being validated
|
FILE="${2}" # File being validated
|
||||||
TEMP_FILE="${3}" # Temp file location
|
TEMP_FILE="${3}" # Temp file location
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# Print the goods #
|
# Print the goods #
|
||||||
|
@ -897,14 +879,14 @@ function AddDetailedMessageIfEnabled() {
|
||||||
################
|
################
|
||||||
# Pull in Vars #
|
# Pull in Vars #
|
||||||
################
|
################
|
||||||
LINT_CMD="${1}" # Linter command
|
LINT_CMD="${1}" # Linter command
|
||||||
TEMP_FILE="${2}" # Temp file
|
TEMP_FILE="${2}" # Temp file
|
||||||
|
|
||||||
####################
|
####################
|
||||||
# Check the return #
|
# Check the return #
|
||||||
####################
|
####################
|
||||||
DETAILED_MSG=$(TransformTAPDetails "${LINT_CMD}")
|
DETAILED_MSG=$(TransformTAPDetails "${LINT_CMD}")
|
||||||
if [ -n "${DETAILED_MSG}" ] ; then
|
if [ -n "${DETAILED_MSG}" ]; then
|
||||||
printf " ---\n message: %s\n ...\n" "${DETAILED_MSG}" >> "${TEMP_FILE}"
|
printf " ---\n message: %s\n ...\n" "${DETAILED_MSG}" >> "${TEMP_FILE}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue