2019-10-23 11:42:28 -04:00
|
|
|
#!/bin/bash
|
2019-10-21 10:12:50 -04:00
|
|
|
|
|
|
|
################################################################################
|
2019-10-21 12:05:55 -04:00
|
|
|
########### EntryPoint for Super-Linter @AdmiralAwkbar #########################
|
2019-10-21 10:12:50 -04:00
|
|
|
################################################################################
|
|
|
|
|
|
|
|
###########
|
2019-10-21 12:05:55 -04:00
|
|
|
# GLOBALS #
|
2019-10-21 10:12:50 -04:00
|
|
|
###########
|
2019-10-21 15:12:37 -04:00
|
|
|
# Default Vars
|
2019-10-23 10:51:13 -04:00
|
|
|
DEFAULT_RULES_LOCATION='/action/lib/.automation' # Default rules files location
|
2019-10-21 15:12:37 -04:00
|
|
|
# YAML Vars
|
2019-10-23 10:51:13 -04:00
|
|
|
YAML_FILE_NAME='.yaml-lint.yml' # Name of the file
|
|
|
|
YAML_LINTER_RULES="$DEFAULT_RULES_LOCATION/$YAML_FILE_NAME" # Path to the yaml lint rules
|
2019-10-21 15:12:37 -04:00
|
|
|
# MD Vars
|
2019-10-23 10:51:13 -04:00
|
|
|
MD_FILE_NAME='.markdown-lint.yml' # Name of the file
|
|
|
|
MD_LINTER_RULES="$DEFAULT_RULES_LOCATION/$MD_FILE_NAME" # Path to the markdown lint rules
|
2019-10-21 15:12:37 -04:00
|
|
|
# Python Vars
|
2019-10-23 10:51:13 -04:00
|
|
|
PYTHON_FILE_NAME='.python-lint' # Name of the file
|
|
|
|
PYTHON_LINTER_RULES="$DEFAULT_RULES_LOCATION/$PYTHON_FILE_NAME" # Path to the python lint rules
|
2019-10-21 15:12:37 -04:00
|
|
|
# Ruby Vars
|
2019-10-23 10:51:13 -04:00
|
|
|
RUBY_FILE_NAME='.ruby-lint.yml' # Name of the file
|
|
|
|
RUBY_LINTER_RULES="$DEFAULT_RULES_LOCATION/$RUBY_FILE_NAME" # Path to the ruby lint rules
|
2019-10-21 15:12:37 -04:00
|
|
|
# Coffee Vars
|
2019-10-23 10:51:13 -04:00
|
|
|
COFFEE_FILE_NAME='.coffee-lint.json' # Name of the file
|
|
|
|
COFFEE_LINTER_RULES="$DEFAULT_RULES_LOCATION/$COFFEE_FILE_NAME" # Path to the coffescript lint rules
|
2019-10-22 13:21:42 -04:00
|
|
|
# Ansible Vars
|
2019-10-23 10:51:13 -04:00
|
|
|
ANSIBLE_FILE_NAME='.ansible-lint.yml' # Name of the file
|
|
|
|
ANSIBLE_LINTER_RULES="$DEFAULT_RULES_LOCATION/$ANSIBLE_FILE_NAME" # Path to the coffescript lint rules
|
2019-10-21 15:12:37 -04:00
|
|
|
|
|
|
|
###################
|
|
|
|
# GitHub ENV Vars #
|
|
|
|
###################
|
|
|
|
GITHUB_SHA="${GITHUB_SHA}" # GitHub sha from the commit
|
|
|
|
GITHUB_EVENT_PATH="${GITHUB_EVENT_PATH}" # Github Event Path
|
|
|
|
GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # Github Workspace
|
2019-10-21 12:05:55 -04:00
|
|
|
|
|
|
|
############
|
|
|
|
# Counters #
|
|
|
|
############
|
2019-10-21 15:12:37 -04:00
|
|
|
ERRORS_FOUND_YML=0 # Count of errors found
|
|
|
|
ERRORS_FOUND_JSON=0 # Count of errors found
|
|
|
|
ERRORS_FOUND_XML=0 # Count of errors found
|
|
|
|
ERRORS_FOUND_MD=0 # Count of errors found
|
2019-10-21 12:05:55 -04:00
|
|
|
ERRORS_FOUND_BASH=0 # Count of errors found
|
|
|
|
ERRORS_FOUND_PERL=0 # Count of errors found
|
|
|
|
ERRORS_FOUND_RUBY=0 # Count of errors found
|
|
|
|
ERRORS_FOUND_PYTHON=0 # Count of errors found
|
|
|
|
ERRORS_FOUND_COFFEE=0 # Count of errors found
|
2019-10-22 13:21:42 -04:00
|
|
|
ERRORS_FOUND_ANSIBLE=0 # Count of errors found
|
2019-10-21 15:12:37 -04:00
|
|
|
|
2019-10-21 10:12:50 -04:00
|
|
|
################################################################################
|
2019-10-21 12:05:55 -04:00
|
|
|
########################## FUNCTIONS BELOW #####################################
|
2019-10-21 10:12:50 -04:00
|
|
|
################################################################################
|
|
|
|
################################################################################
|
2019-10-21 12:05:55 -04:00
|
|
|
#### Function Header ###########################################################
|
|
|
|
Header()
|
2019-10-21 10:12:50 -04:00
|
|
|
{
|
2019-10-21 12:05:55 -04:00
|
|
|
echo ""
|
|
|
|
echo "---------------------------------------------"
|
2019-10-21 15:12:37 -04:00
|
|
|
echo "------ Github Actions Language Linter -------"
|
2019-10-21 12:05:55 -04:00
|
|
|
echo "---------------------------------------------"
|
|
|
|
echo ""
|
|
|
|
}
|
|
|
|
################################################################################
|
|
|
|
#### Function GetLinterRules ###################################################
|
|
|
|
GetLinterRules()
|
|
|
|
{
|
|
|
|
# Need to validate the rules files exist
|
2019-10-23 10:51:13 -04:00
|
|
|
################
|
|
|
|
# print header #
|
|
|
|
################
|
|
|
|
echo ""
|
|
|
|
echo "----------------------------------------------"
|
|
|
|
echo "Gathering Linter rules from repository, or defaulting..."
|
|
|
|
echo ""
|
2019-10-21 10:12:50 -04:00
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
#####################################
|
|
|
|
# Validate we have the linter rules #
|
|
|
|
#####################################
|
2019-10-23 11:23:16 -04:00
|
|
|
if [ -f "$GITHUB_WORKSPACE/.github/linters/$YAML_FILE_NAME" ]; then
|
2019-10-21 15:12:37 -04:00
|
|
|
echo "User provided file:[$YAML_FILE_NAME], setting rules file..."
|
|
|
|
|
|
|
|
####################################
|
|
|
|
# Move users into default location #
|
|
|
|
####################################
|
2019-10-23 11:23:16 -04:00
|
|
|
MV_CMD=$(mv "$GITHUB_WORKSPACE/.github/linters/$YAML_FILE_NAME" "$YAML_LINTER_RULES" 2>&1)
|
2019-10-21 15:12:37 -04:00
|
|
|
|
|
|
|
###################
|
|
|
|
# Load Error code #
|
|
|
|
###################
|
|
|
|
ERROR_CODE=$?
|
|
|
|
|
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
|
|
|
if [ $ERROR_CODE -ne 0 ]; then
|
|
|
|
echo "ERROR! Failed to set file:[$YAML_FILE_NAME] as default!"
|
|
|
|
echo "ERROR:[$MV_CMD]"
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-10-23 10:51:13 -04:00
|
|
|
else
|
|
|
|
echo "Using Default rules at:[$YAML_LINTER_RULES]"
|
2019-10-21 10:12:50 -04:00
|
|
|
fi
|
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
#####################################
|
|
|
|
# Validate we have the linter rules #
|
|
|
|
#####################################
|
2019-10-23 11:23:16 -04:00
|
|
|
if [ -f "$GITHUB_WORKSPACE/.github/linters/$MD_FILE_NAME" ]; then
|
2019-10-21 15:12:37 -04:00
|
|
|
echo "User provided file:[$MD_FILE_NAME], setting rules file..."
|
|
|
|
|
|
|
|
####################################
|
|
|
|
# Move users into default location #
|
|
|
|
####################################
|
2019-10-23 11:23:16 -04:00
|
|
|
MV_CMD=$(mv "$GITHUB_WORKSPACE/.github/linters/$MD_FILE_NAME" "$MD_LINTER_RULES" 2>&1)
|
2019-10-21 15:12:37 -04:00
|
|
|
|
|
|
|
###################
|
|
|
|
# Load Error code #
|
|
|
|
###################
|
|
|
|
ERROR_CODE=$?
|
|
|
|
|
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
|
|
|
if [ $ERROR_CODE -ne 0 ]; then
|
|
|
|
echo "ERROR! Failed to set file:[$MD_FILE_NAME] as default!"
|
|
|
|
echo "ERROR:[$MV_CMD]"
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-10-23 10:51:13 -04:00
|
|
|
else
|
|
|
|
echo "Using Default rules at:[$MD_LINTER_RULES]"
|
2019-10-21 15:12:37 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
#####################################
|
|
|
|
# Validate we have the linter rules #
|
|
|
|
#####################################
|
2019-10-23 11:23:16 -04:00
|
|
|
if [ -f "$GITHUB_WORKSPACE/.github/linters/$PYTHON_FILE_NAME" ]; then
|
2019-10-21 15:12:37 -04:00
|
|
|
echo "User provided file:[$PYTHON_FILE_NAME], setting rules file..."
|
|
|
|
|
|
|
|
####################################
|
|
|
|
# Move users into default location #
|
|
|
|
####################################
|
2019-10-23 11:23:16 -04:00
|
|
|
MV_CMD=$(mv "$GITHUB_WORKSPACE/.github/linters/$PYTHON_FILE_NAME" "$PYTHON_LINTER_RULES" 2>&1)
|
2019-10-21 15:12:37 -04:00
|
|
|
|
|
|
|
###################
|
|
|
|
# Load Error code #
|
|
|
|
###################
|
|
|
|
ERROR_CODE=$?
|
|
|
|
|
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
|
|
|
if [ $ERROR_CODE -ne 0 ]; then
|
2019-10-23 10:51:13 -04:00
|
|
|
echo "ERROR! Failed to set file:[$PYTHON_FILE_NAME] as default!"
|
2019-10-21 15:12:37 -04:00
|
|
|
echo "ERROR:[$MV_CMD]"
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-10-23 10:51:13 -04:00
|
|
|
else
|
|
|
|
echo "Using Default rules at:[$PYTHON_LINTER_RULES]"
|
2019-10-21 15:12:37 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
#####################################
|
|
|
|
# Validate we have the linter rules #
|
|
|
|
#####################################
|
2019-10-23 11:23:16 -04:00
|
|
|
if [ -f "$GITHUB_WORKSPACE/.github/linters/$RUBY_FILE_NAME" ]; then
|
2019-10-21 15:12:37 -04:00
|
|
|
echo "User provided file:[$RUBY_FILE_NAME], setting rules file..."
|
|
|
|
|
|
|
|
####################################
|
|
|
|
# Move users into default location #
|
|
|
|
####################################
|
2019-10-23 11:23:16 -04:00
|
|
|
MV_CMD=$(mv "$GITHUB_WORKSPACE/.github/linters/$RUBY_FILE_NAME" "$RUBY_LINTER_RULES" 2>&1)
|
2019-10-21 15:12:37 -04:00
|
|
|
|
|
|
|
###################
|
|
|
|
# Load Error code #
|
|
|
|
###################
|
|
|
|
ERROR_CODE=$?
|
|
|
|
|
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
|
|
|
if [ $ERROR_CODE -ne 0 ]; then
|
|
|
|
echo "ERROR! Failed to set file:[$RUBY_FILE_NAME] as default!"
|
|
|
|
echo "ERROR:[$MV_CMD]"
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-10-23 10:51:13 -04:00
|
|
|
else
|
|
|
|
echo "Using Default rules at:[$RUBY_LINTER_RULES]"
|
2019-10-21 15:12:37 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
#####################################
|
|
|
|
# Validate we have the linter rules #
|
|
|
|
#####################################
|
2019-10-23 11:23:16 -04:00
|
|
|
if [ -f "$GITHUB_WORKSPACE/.github/linters/$COFFEE_FILE_NAME" ]; then
|
2019-10-21 15:12:37 -04:00
|
|
|
echo "User provided file:[$COFFEE_FILE_NAME], setting rules file..."
|
|
|
|
|
|
|
|
####################################
|
|
|
|
# Move users into default location #
|
|
|
|
####################################
|
2019-10-23 11:23:16 -04:00
|
|
|
MV_CMD=$(mv "$GITHUB_WORKSPACE/.github/linters/$COFFEE_FILE_NAME" "$COFFEE_LINTER_RULES" 2>&1)
|
2019-10-21 15:12:37 -04:00
|
|
|
|
|
|
|
###################
|
|
|
|
# Load Error code #
|
|
|
|
###################
|
|
|
|
ERROR_CODE=$?
|
|
|
|
|
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
|
|
|
if [ $ERROR_CODE -ne 0 ]; then
|
|
|
|
echo "ERROR! Failed to set file:[$COFFEE_FILE_NAME] as default!"
|
|
|
|
echo "ERROR:[$MV_CMD]"
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-10-23 10:51:13 -04:00
|
|
|
else
|
|
|
|
echo "Using Default rules at:[$COFFEE_LINTER_RULES]"
|
2019-10-21 10:12:50 -04:00
|
|
|
fi
|
2019-10-22 13:21:42 -04:00
|
|
|
|
|
|
|
#####################################
|
|
|
|
# Validate we have the linter rules #
|
|
|
|
#####################################
|
2019-10-23 11:23:16 -04:00
|
|
|
if [ -f "$GITHUB_WORKSPACE/.github/linters/$ANSIBLE_FILE_NAME" ]; then
|
2019-10-22 13:21:42 -04:00
|
|
|
echo "User provided file:[$ANSIBLE_FILE_NAME], setting rules file..."
|
|
|
|
|
|
|
|
####################################
|
|
|
|
# Move users into default location #
|
|
|
|
####################################
|
2019-10-23 11:23:16 -04:00
|
|
|
MV_CMD=$(mv "$GITHUB_WORKSPACE/.github/linters/$ANSIBLE_FILE_NAME" "$ANSIBLE_LINTER_RULES" 2>&1)
|
2019-10-22 13:21:42 -04:00
|
|
|
|
|
|
|
###################
|
|
|
|
# Load Error code #
|
|
|
|
###################
|
|
|
|
ERROR_CODE=$?
|
|
|
|
|
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
|
|
|
if [ $ERROR_CODE -ne 0 ]; then
|
|
|
|
echo "ERROR! Failed to set file:[$ANSIBLE_FILE_NAME] as default!"
|
|
|
|
echo "ERROR:[$MV_CMD]"
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-10-23 10:51:13 -04:00
|
|
|
else
|
|
|
|
echo "Using Default rules at:[$ANSIBLE_LINTER_RULES]"
|
2019-10-22 13:21:42 -04:00
|
|
|
fi
|
2019-10-21 12:05:55 -04:00
|
|
|
}
|
|
|
|
################################################################################
|
|
|
|
#### Function LintJsonFiles ####################################################
|
|
|
|
LintJsonFiles()
|
|
|
|
{
|
|
|
|
################
|
|
|
|
# print header #
|
|
|
|
################
|
|
|
|
echo ""
|
2019-10-21 15:12:37 -04:00
|
|
|
echo "----------------------------------------------"
|
2019-10-21 12:05:55 -04:00
|
|
|
echo "Linting JSON files..."
|
2019-10-21 15:12:37 -04:00
|
|
|
echo "----------------------------------------------"
|
2019-10-21 12:05:55 -04:00
|
|
|
echo ""
|
2019-10-21 10:12:50 -04:00
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
######################
|
|
|
|
# Name of the linter #
|
|
|
|
######################
|
2019-10-22 13:21:42 -04:00
|
|
|
LINTER_NAME="jsonlint"
|
2019-10-21 10:12:50 -04:00
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
#######################################
|
|
|
|
# Validate we have yamllint installed #
|
|
|
|
#######################################
|
|
|
|
# shellcheck disable=SC2230
|
2019-10-23 11:16:17 -04:00
|
|
|
VALIDATE_INSTALL_CMD=$(command -v "$LINTER_NAME" 2>&1)
|
2019-10-21 10:12:50 -04:00
|
|
|
|
|
|
|
#######################
|
|
|
|
# Load the error code #
|
|
|
|
#######################
|
|
|
|
ERROR_CODE=$?
|
|
|
|
|
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
2019-10-21 12:05:55 -04:00
|
|
|
if [ $ERROR_CODE -ne 0 ]; then
|
|
|
|
# Failed
|
|
|
|
echo "ERROR! Failed to find [$LINTER_NAME] in system!"
|
|
|
|
echo "ERROR:[$VALIDATE_INSTALL_CMD]"
|
|
|
|
exit 1
|
2019-10-21 10:12:50 -04:00
|
|
|
else
|
2019-10-21 12:05:55 -04:00
|
|
|
# Success
|
|
|
|
echo "Successfully found binary in system"
|
|
|
|
echo "Location:[$VALIDATE_INSTALL_CMD]"
|
2019-10-21 10:12:50 -04:00
|
|
|
fi
|
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
#################################
|
|
|
|
# Get list of all files to lint #
|
|
|
|
#################################
|
2019-10-23 11:38:53 -04:00
|
|
|
# shellcheck disable=SC2207
|
|
|
|
LIST_FILES=($(cd "$GITHUB_WORKSPACE" || exit; find . -type f -name "*.json" 2>&1))
|
2019-10-21 12:05:55 -04:00
|
|
|
|
|
|
|
##################
|
|
|
|
# Lint the files #
|
|
|
|
##################
|
|
|
|
for FILE in "${LIST_FILES[@]}"
|
|
|
|
do
|
|
|
|
#####################
|
|
|
|
# Get the file name #
|
|
|
|
#####################
|
|
|
|
FILE_NAME=$(basename "$FILE" 2>&1)
|
|
|
|
|
|
|
|
#######################################
|
|
|
|
# Make sure we dont lint node modules #
|
|
|
|
#######################################
|
|
|
|
if [[ $FILE == *"node_modules"* ]]; then
|
|
|
|
# This is a node modules file
|
|
|
|
continue
|
|
|
|
fi
|
2019-10-21 10:12:50 -04:00
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
##############
|
|
|
|
# File print #
|
|
|
|
##############
|
|
|
|
echo "---------------------------"
|
|
|
|
echo "File:[$FILE]"
|
2019-10-21 10:12:50 -04:00
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
################################
|
|
|
|
# Lint the file with the rules #
|
|
|
|
################################
|
|
|
|
LINT_CMD=$("$LINTER_NAME" "$FILE" 2>&1)
|
2019-10-21 10:12:50 -04:00
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
#######################
|
|
|
|
# Load the error code #
|
|
|
|
#######################
|
|
|
|
ERROR_CODE=$?
|
2019-10-21 10:12:50 -04:00
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
|
|
|
if [ $ERROR_CODE -ne 0 ]; then
|
|
|
|
#########
|
|
|
|
# Error #
|
|
|
|
#########
|
|
|
|
echo "ERROR! Found errors in [$LINTER_NAME] linter!"
|
|
|
|
echo "ERROR:[$LINT_CMD]"
|
|
|
|
# Increment error count
|
|
|
|
((ERRORS_FOUND_JSON++))
|
|
|
|
else
|
|
|
|
###########
|
|
|
|
# Success #
|
|
|
|
###########
|
|
|
|
echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully"
|
|
|
|
fi
|
|
|
|
done
|
2019-10-21 10:12:50 -04:00
|
|
|
}
|
|
|
|
################################################################################
|
2019-10-21 12:05:55 -04:00
|
|
|
#### Function LintYmlFiles #####################################################
|
|
|
|
LintYmlFiles()
|
2019-10-21 10:12:50 -04:00
|
|
|
{
|
2019-10-21 12:05:55 -04:00
|
|
|
################
|
|
|
|
# print header #
|
|
|
|
################
|
|
|
|
echo ""
|
2019-10-21 15:12:37 -04:00
|
|
|
echo "----------------------------------------------"
|
2019-10-21 12:05:55 -04:00
|
|
|
echo "Linting YAML files..."
|
2019-10-21 15:12:37 -04:00
|
|
|
echo "----------------------------------------------"
|
2019-10-21 12:05:55 -04:00
|
|
|
echo ""
|
2019-10-21 10:12:50 -04:00
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
######################
|
|
|
|
# Name of the linter #
|
|
|
|
######################
|
|
|
|
LINTER_NAME="yamllint"
|
2019-10-21 10:12:50 -04:00
|
|
|
|
|
|
|
#######################################
|
2019-10-21 12:05:55 -04:00
|
|
|
# Validate we have yamllint installed #
|
2019-10-21 10:12:50 -04:00
|
|
|
#######################################
|
2019-10-21 12:05:55 -04:00
|
|
|
# shellcheck disable=SC2230
|
2019-10-23 11:16:17 -04:00
|
|
|
VALIDATE_INSTALL_CMD=$(command -v "$LINTER_NAME" 2>&1)
|
2019-10-21 10:12:50 -04:00
|
|
|
|
|
|
|
#######################
|
|
|
|
# Load the error code #
|
|
|
|
#######################
|
|
|
|
ERROR_CODE=$?
|
|
|
|
|
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
|
|
|
if [ $ERROR_CODE -ne 0 ]; then
|
2019-10-21 12:05:55 -04:00
|
|
|
# Failed
|
|
|
|
echo "ERROR! Failed to find [$LINTER_NAME] in system!"
|
|
|
|
echo "ERROR:[$VALIDATE_INSTALL_CMD]"
|
|
|
|
exit 1
|
2019-10-21 10:12:50 -04:00
|
|
|
else
|
2019-10-21 12:05:55 -04:00
|
|
|
# Success
|
|
|
|
echo "Successfully found binary in system"
|
|
|
|
echo "Location:[$VALIDATE_INSTALL_CMD]"
|
2019-10-21 10:12:50 -04:00
|
|
|
fi
|
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
#################################
|
|
|
|
# Get list of all files to lint #
|
|
|
|
#################################
|
2019-10-23 11:38:53 -04:00
|
|
|
# shellcheck disable=SC2207
|
|
|
|
LIST_FILES=($(cd "$GITHUB_WORKSPACE" || exit; find . -type f \( -name "*.yml" -or -name "*.yaml" \) 2>&1))
|
2019-10-21 12:05:55 -04:00
|
|
|
|
|
|
|
##################
|
|
|
|
# Lint the files #
|
|
|
|
##################
|
|
|
|
for FILE in "${LIST_FILES[@]}"
|
|
|
|
do
|
|
|
|
#####################
|
|
|
|
# Get the file name #
|
|
|
|
#####################
|
|
|
|
FILE_NAME=$(basename "$FILE" 2>&1)
|
|
|
|
|
|
|
|
#######################################
|
|
|
|
# Make sure we dont lint node modules #
|
|
|
|
#######################################
|
|
|
|
# if [[ $FILE == *"node_modules"* ]]; then
|
|
|
|
# # This is a node modules file
|
|
|
|
# continue
|
|
|
|
# fi
|
|
|
|
|
|
|
|
##############
|
|
|
|
# File print #
|
|
|
|
##############
|
|
|
|
echo "---------------------------"
|
|
|
|
echo "File:[$FILE]"
|
|
|
|
|
|
|
|
################################
|
|
|
|
# Lint the file with the rules #
|
|
|
|
################################
|
|
|
|
LINT_CMD=$("$LINTER_NAME" "$YAML_LINTER_RULES" "$FILE" 2>&1)
|
2019-10-21 10:12:50 -04:00
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
#######################
|
|
|
|
# Load the error code #
|
|
|
|
#######################
|
|
|
|
ERROR_CODE=$?
|
2019-10-21 10:12:50 -04:00
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
|
|
|
if [ $ERROR_CODE -ne 0 ]; then
|
|
|
|
#########
|
|
|
|
# Error #
|
|
|
|
#########
|
|
|
|
echo "ERROR! Found errors in [$LINTER_NAME] linter!"
|
|
|
|
echo "ERROR:[$LINT_CMD]"
|
|
|
|
# Increment error count
|
|
|
|
((ERRORS_FOUND_YML++))
|
|
|
|
else
|
|
|
|
###########
|
|
|
|
# Success #
|
|
|
|
###########
|
|
|
|
echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
################################################################################
|
|
|
|
#### Function LintXmlFiles #####################################################
|
|
|
|
LintXmlFiles()
|
|
|
|
{
|
|
|
|
################
|
|
|
|
# print header #
|
|
|
|
################
|
|
|
|
echo ""
|
2019-10-21 15:12:37 -04:00
|
|
|
echo "----------------------------------------------"
|
2019-10-21 12:05:55 -04:00
|
|
|
echo "Linting XML files..."
|
2019-10-21 15:12:37 -04:00
|
|
|
echo "----------------------------------------------"
|
2019-10-21 12:05:55 -04:00
|
|
|
echo ""
|
2019-10-21 10:12:50 -04:00
|
|
|
|
|
|
|
######################
|
2019-10-21 12:05:55 -04:00
|
|
|
# Name of the linter #
|
2019-10-21 10:12:50 -04:00
|
|
|
######################
|
2019-10-21 12:05:55 -04:00
|
|
|
LINTER_NAME="xmllint"
|
2019-10-21 10:12:50 -04:00
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
#######################################
|
|
|
|
# Validate we have yamllint installed #
|
|
|
|
#######################################
|
|
|
|
# shellcheck disable=SC2230
|
2019-10-23 11:16:17 -04:00
|
|
|
VALIDATE_INSTALL_CMD=$(command -v "$LINTER_NAME" 2>&1)
|
2019-10-21 10:12:50 -04:00
|
|
|
|
|
|
|
#######################
|
|
|
|
# Load the error code #
|
|
|
|
#######################
|
|
|
|
ERROR_CODE=$?
|
|
|
|
|
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
|
|
|
if [ $ERROR_CODE -ne 0 ]; then
|
2019-10-21 12:05:55 -04:00
|
|
|
# Failed
|
|
|
|
echo "ERROR! Failed to find [$LINTER_NAME] in system!"
|
|
|
|
echo "ERROR:[$VALIDATE_INSTALL_CMD]"
|
|
|
|
exit 1
|
2019-10-21 10:12:50 -04:00
|
|
|
else
|
2019-10-21 12:05:55 -04:00
|
|
|
# Success
|
|
|
|
echo "Successfully found binary in system"
|
|
|
|
echo "Location:[$VALIDATE_INSTALL_CMD]"
|
2019-10-21 10:12:50 -04:00
|
|
|
fi
|
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
#################################
|
|
|
|
# Get list of all files to lint #
|
|
|
|
#################################
|
2019-10-23 11:38:53 -04:00
|
|
|
# shellcheck disable=SC2207
|
|
|
|
LIST_FILES=($(cd "$GITHUB_WORKSPACE" || exit; find . -type f -name "*.xml" 2>&1))
|
2019-10-21 12:05:55 -04:00
|
|
|
|
|
|
|
##################
|
|
|
|
# Lint the files #
|
|
|
|
##################
|
|
|
|
for FILE in "${LIST_FILES[@]}"
|
|
|
|
do
|
|
|
|
#####################
|
|
|
|
# Get the file name #
|
|
|
|
#####################
|
|
|
|
FILE_NAME=$(basename "$FILE" 2>&1)
|
|
|
|
|
|
|
|
#######################################
|
|
|
|
# Make sure we dont lint node modules #
|
|
|
|
#######################################
|
|
|
|
# if [[ $FILE == *"node_modules"* ]]; then
|
|
|
|
# # This is a node modules file
|
|
|
|
# continue
|
|
|
|
# fi
|
|
|
|
|
|
|
|
##############
|
|
|
|
# File print #
|
|
|
|
##############
|
|
|
|
echo "---------------------------"
|
|
|
|
echo "File:[$FILE]"
|
|
|
|
|
|
|
|
################################
|
|
|
|
# Lint the file with the rules #
|
|
|
|
################################
|
|
|
|
LINT_CMD=$("$LINTER_NAME" "$FILE" 2>&1)
|
2019-10-21 10:12:50 -04:00
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
#######################
|
|
|
|
# Load the error code #
|
|
|
|
#######################
|
|
|
|
ERROR_CODE=$?
|
2019-10-21 10:12:50 -04:00
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
|
|
|
if [ $ERROR_CODE -ne 0 ]; then
|
|
|
|
#########
|
|
|
|
# Error #
|
|
|
|
#########
|
|
|
|
echo "ERROR! Found errors in [$LINTER_NAME] linter!"
|
|
|
|
echo "ERROR:[$LINT_CMD]"
|
|
|
|
# Increment error count
|
|
|
|
((ERRORS_FOUND_XML++))
|
|
|
|
else
|
|
|
|
###########
|
|
|
|
# Success #
|
|
|
|
###########
|
|
|
|
echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
################################################################################
|
|
|
|
#### Function LintMdFiles ######################################################
|
|
|
|
LintMdFiles()
|
|
|
|
{
|
|
|
|
################
|
|
|
|
# print header #
|
|
|
|
################
|
|
|
|
echo ""
|
2019-10-21 15:12:37 -04:00
|
|
|
echo "----------------------------------------------"
|
2019-10-21 12:05:55 -04:00
|
|
|
echo "Linting Markdown files..."
|
2019-10-21 15:12:37 -04:00
|
|
|
echo "----------------------------------------------"
|
2019-10-21 12:05:55 -04:00
|
|
|
echo ""
|
|
|
|
|
|
|
|
######################
|
|
|
|
# Name of the linter #
|
|
|
|
######################
|
|
|
|
LINTER_NAME="markdownlint"
|
2019-10-21 10:12:50 -04:00
|
|
|
|
|
|
|
#######################################
|
2019-10-21 12:05:55 -04:00
|
|
|
# Validate we have yamllint installed #
|
2019-10-21 10:12:50 -04:00
|
|
|
#######################################
|
2019-10-21 12:05:55 -04:00
|
|
|
# shellcheck disable=SC2230
|
2019-10-23 11:16:17 -04:00
|
|
|
VALIDATE_INSTALL_CMD=$(command -v "$LINTER_NAME" 2>&1)
|
2019-10-21 10:12:50 -04:00
|
|
|
|
|
|
|
#######################
|
|
|
|
# Load the error code #
|
|
|
|
#######################
|
|
|
|
ERROR_CODE=$?
|
|
|
|
|
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
|
|
|
if [ $ERROR_CODE -ne 0 ]; then
|
2019-10-21 12:05:55 -04:00
|
|
|
# Failed
|
|
|
|
echo "ERROR! Failed to find [$LINTER_NAME] in system!"
|
|
|
|
echo "ERROR:[$VALIDATE_INSTALL_CMD]"
|
|
|
|
exit 1
|
2019-10-21 10:12:50 -04:00
|
|
|
else
|
2019-10-21 12:05:55 -04:00
|
|
|
# Success
|
|
|
|
echo "Successfully found binary in system"
|
|
|
|
echo "Location:[$VALIDATE_INSTALL_CMD]"
|
2019-10-21 10:12:50 -04:00
|
|
|
fi
|
2019-10-21 12:05:55 -04:00
|
|
|
|
|
|
|
#################################
|
|
|
|
# Get list of all files to lint #
|
|
|
|
#################################
|
2019-10-23 11:38:53 -04:00
|
|
|
# shellcheck disable=SC2207
|
|
|
|
LIST_FILES=($(cd "$GITHUB_WORKSPACE" || exit; find . -type f -name "*.md" 2>&1))
|
2019-10-21 12:05:55 -04:00
|
|
|
|
|
|
|
##################
|
|
|
|
# Lint the files #
|
|
|
|
##################
|
|
|
|
for FILE in "${LIST_FILES[@]}"
|
|
|
|
do
|
|
|
|
#####################
|
|
|
|
# Get the file name #
|
|
|
|
#####################
|
|
|
|
FILE_NAME=$(basename "$FILE" 2>&1)
|
|
|
|
|
|
|
|
#######################################
|
|
|
|
# Make sure we dont lint node modules #
|
|
|
|
#######################################
|
|
|
|
# if [[ $FILE == *"node_modules"* ]]; then
|
|
|
|
# # This is a node modules file
|
|
|
|
# continue
|
|
|
|
# fi
|
|
|
|
|
|
|
|
##############
|
|
|
|
# File print #
|
|
|
|
##############
|
|
|
|
echo "---------------------------"
|
|
|
|
echo "File:[$FILE]"
|
|
|
|
|
|
|
|
################################
|
|
|
|
# Lint the file with the rules #
|
|
|
|
################################
|
|
|
|
LINT_CMD=$("$LINTER_NAME" -c "$MD_LINTER_RULES" "$FILE" 2>&1)
|
|
|
|
|
|
|
|
#######################
|
|
|
|
# Load the error code #
|
|
|
|
#######################
|
|
|
|
ERROR_CODE=$?
|
|
|
|
|
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
|
|
|
if [ $ERROR_CODE -ne 0 ]; then
|
|
|
|
#########
|
|
|
|
# Error #
|
|
|
|
#########
|
|
|
|
echo "ERROR! Found errors in [$LINTER_NAME] linter!"
|
|
|
|
echo "ERROR:[$LINT_CMD]"
|
|
|
|
# Increment error count
|
|
|
|
((ERRORS_FOUND_MD++))
|
|
|
|
else
|
|
|
|
###########
|
|
|
|
# Success #
|
|
|
|
###########
|
|
|
|
echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully"
|
|
|
|
fi
|
|
|
|
done
|
2019-10-21 10:12:50 -04:00
|
|
|
}
|
|
|
|
################################################################################
|
2019-10-21 12:05:55 -04:00
|
|
|
#### Function LintBashFiles ####################################################
|
|
|
|
LintBashFiles()
|
2019-10-21 10:12:50 -04:00
|
|
|
{
|
2019-10-21 12:05:55 -04:00
|
|
|
################
|
|
|
|
# print header #
|
|
|
|
################
|
|
|
|
echo ""
|
2019-10-21 15:12:37 -04:00
|
|
|
echo "----------------------------------------------"
|
2019-10-21 12:05:55 -04:00
|
|
|
echo "Linting Bash files..."
|
2019-10-21 15:12:37 -04:00
|
|
|
echo "----------------------------------------------"
|
2019-10-21 12:05:55 -04:00
|
|
|
echo ""
|
|
|
|
|
|
|
|
######################
|
|
|
|
# Name of the linter #
|
|
|
|
######################
|
|
|
|
LINTER_NAME="shellcheck"
|
|
|
|
|
|
|
|
#########################################
|
|
|
|
# Validate we have shellcheck installed #
|
|
|
|
#########################################
|
|
|
|
# shellcheck disable=SC2230
|
2019-10-23 11:16:17 -04:00
|
|
|
VALIDATE_INSTALL_CMD=$(command -v "$LINTER_NAME" 2>&1)
|
2019-10-21 10:12:50 -04:00
|
|
|
|
|
|
|
#######################
|
|
|
|
# Load the error code #
|
|
|
|
#######################
|
|
|
|
ERROR_CODE=$?
|
|
|
|
|
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
|
|
|
if [ $ERROR_CODE -ne 0 ]; then
|
2019-10-21 12:05:55 -04:00
|
|
|
# Failed
|
|
|
|
echo "ERROR! Failed to find $LINTER_NAME in system!"
|
|
|
|
echo "ERROR:[$VALIDATE_INSTALL_CMD]"
|
2019-10-21 10:12:50 -04:00
|
|
|
exit 1
|
|
|
|
else
|
2019-10-21 12:05:55 -04:00
|
|
|
# Success
|
|
|
|
echo "Successfully found binary in system"
|
|
|
|
echo "Location:[$VALIDATE_INSTALL_CMD]"
|
2019-10-21 10:12:50 -04:00
|
|
|
fi
|
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
#################################
|
|
|
|
# Get list of all files to lint #
|
|
|
|
#################################
|
2019-10-23 11:38:53 -04:00
|
|
|
# shellcheck disable=SC2207
|
|
|
|
LIST_FILES=($(cd "$GITHUB_WORKSPACE" || exit; find . -type f -name "*.sh" 2>&1))
|
2019-10-21 12:05:55 -04:00
|
|
|
|
|
|
|
##################
|
|
|
|
# Lint the files #
|
|
|
|
##################
|
|
|
|
for FILE in "${LIST_FILES[@]}"
|
|
|
|
do
|
|
|
|
|
|
|
|
#######################################
|
|
|
|
# Make sure we dont lint node modules #
|
|
|
|
#######################################
|
|
|
|
# if [[ $FILE == *"node_modules"* ]]; then
|
|
|
|
# # This is a node modules file
|
|
|
|
# continue
|
|
|
|
# fi
|
|
|
|
|
|
|
|
####################
|
|
|
|
# Get the filename #
|
|
|
|
####################
|
|
|
|
FILE_NAME=$(basename "$FILE" 2>&1)
|
|
|
|
|
|
|
|
##############
|
|
|
|
# File print #
|
|
|
|
##############
|
|
|
|
echo "---------------------------"
|
|
|
|
echo "File:[$FILE]"
|
|
|
|
|
|
|
|
################################
|
|
|
|
# Lint the file with the rules #
|
|
|
|
################################
|
|
|
|
LINT_CMD=$("$LINTER_NAME" "$FILE" 2>&1)
|
2019-10-21 10:12:50 -04:00
|
|
|
|
|
|
|
#######################
|
2019-10-21 12:05:55 -04:00
|
|
|
# Load the error code #
|
2019-10-21 10:12:50 -04:00
|
|
|
#######################
|
2019-10-21 12:05:55 -04:00
|
|
|
ERROR_CODE=$?
|
2019-10-21 10:12:50 -04:00
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
|
|
|
if [ $ERROR_CODE -ne 0 ]; then
|
|
|
|
#########
|
|
|
|
# Error #
|
|
|
|
#########
|
|
|
|
echo "ERROR! Found errors in [$LINTER_NAME] linter!"
|
|
|
|
echo "ERROR:[$LINT_CMD]"
|
|
|
|
# Increment error count
|
|
|
|
((ERRORS_FOUND_BASH++))
|
|
|
|
else
|
|
|
|
###########
|
|
|
|
# Success #
|
|
|
|
###########
|
|
|
|
echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully"
|
|
|
|
fi
|
|
|
|
done
|
2019-10-21 10:12:50 -04:00
|
|
|
}
|
|
|
|
################################################################################
|
2019-10-21 12:05:55 -04:00
|
|
|
#### Function LintPythonFiles ##################################################
|
|
|
|
LintPythonFiles()
|
2019-10-21 10:12:50 -04:00
|
|
|
{
|
2019-10-21 12:05:55 -04:00
|
|
|
################
|
|
|
|
# print header #
|
|
|
|
################
|
|
|
|
echo ""
|
2019-10-21 15:12:37 -04:00
|
|
|
echo "----------------------------------------------"
|
2019-10-21 12:05:55 -04:00
|
|
|
echo "Linting Python files..."
|
2019-10-21 15:12:37 -04:00
|
|
|
echo "----------------------------------------------"
|
2019-10-21 12:05:55 -04:00
|
|
|
echo ""
|
|
|
|
|
|
|
|
######################
|
|
|
|
# Name of the linter #
|
|
|
|
######################
|
|
|
|
LINTER_NAME="pylint"
|
|
|
|
|
|
|
|
#####################################
|
|
|
|
# Validate we have pylint installed #
|
|
|
|
#####################################
|
|
|
|
# shellcheck disable=SC2230
|
2019-10-23 11:16:17 -04:00
|
|
|
VALIDATE_INSTALL_CMD=$(command -v "$LINTER_NAME" 2>&1)
|
2019-10-21 10:12:50 -04:00
|
|
|
|
|
|
|
#######################
|
|
|
|
# Load the error code #
|
|
|
|
#######################
|
|
|
|
ERROR_CODE=$?
|
|
|
|
|
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
|
|
|
if [ $ERROR_CODE -ne 0 ]; then
|
2019-10-21 12:05:55 -04:00
|
|
|
# Failed
|
|
|
|
echo "ERROR! Failed to find $LINTER_NAME in system!"
|
|
|
|
echo "ERROR:[$VALIDATE_INSTALL_CMD]"
|
|
|
|
exit 1
|
2019-10-21 10:12:50 -04:00
|
|
|
else
|
2019-10-21 12:05:55 -04:00
|
|
|
# Success
|
|
|
|
echo "Successfully found binary in system"
|
|
|
|
echo "Location:[$VALIDATE_INSTALL_CMD]"
|
2019-10-21 10:12:50 -04:00
|
|
|
fi
|
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
#################################
|
|
|
|
# Get list of all files to lint #
|
|
|
|
#################################
|
2019-10-23 11:38:53 -04:00
|
|
|
# shellcheck disable=SC2207
|
|
|
|
LIST_FILES=($(cd "$GITHUB_WORKSPACE" || exit; find . -type f -name "*.py" 2>&1))
|
2019-10-21 12:05:55 -04:00
|
|
|
|
|
|
|
##################
|
|
|
|
# Lint the files #
|
|
|
|
##################
|
|
|
|
for FILE in "${LIST_FILES[@]}"
|
|
|
|
do
|
|
|
|
|
|
|
|
#######################################
|
|
|
|
# Make sure we dont lint node modules #
|
|
|
|
#######################################
|
|
|
|
# if [[ $FILE == *"node_modules"* ]]; then
|
|
|
|
# # This is a node modules file
|
|
|
|
# continue
|
|
|
|
# fi
|
|
|
|
|
|
|
|
####################
|
|
|
|
# Get the filename #
|
|
|
|
####################
|
|
|
|
FILE_NAME=$(basename "$FILE" 2>&1)
|
|
|
|
|
|
|
|
##############
|
|
|
|
# File print #
|
|
|
|
##############
|
|
|
|
echo "---------------------------"
|
|
|
|
echo "File:[$FILE]"
|
|
|
|
|
|
|
|
################################
|
|
|
|
# Lint the file with the rules #
|
|
|
|
################################
|
2019-10-21 15:12:37 -04:00
|
|
|
LINT_CMD=$("$LINTER_NAME" --rcfile "$PYTHON_LINTER_RULES" -E "$FILE" 2>&1)
|
2019-10-21 10:12:50 -04:00
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
#######################
|
|
|
|
# Load the error code #
|
|
|
|
#######################
|
|
|
|
ERROR_CODE=$?
|
2019-10-21 10:12:50 -04:00
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
|
|
|
if [ $ERROR_CODE -ne 0 ]; then
|
|
|
|
#########
|
|
|
|
# Error #
|
|
|
|
#########
|
|
|
|
echo "ERROR! Found errors in [$LINTER_NAME] linter!"
|
|
|
|
echo "ERROR:[$LINT_CMD]"
|
|
|
|
# Increment error count
|
|
|
|
((ERRORS_FOUND_PYTHON++))
|
|
|
|
else
|
|
|
|
###########
|
|
|
|
# Success #
|
|
|
|
###########
|
|
|
|
echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully"
|
|
|
|
fi
|
|
|
|
done
|
2019-10-21 10:12:50 -04:00
|
|
|
}
|
|
|
|
################################################################################
|
2019-10-21 12:05:55 -04:00
|
|
|
#### Function LintPerlFiles ####################################################
|
|
|
|
LintPerlFiles()
|
2019-10-21 10:12:50 -04:00
|
|
|
{
|
2019-10-21 12:05:55 -04:00
|
|
|
################
|
|
|
|
# print header #
|
|
|
|
################
|
|
|
|
echo ""
|
2019-10-21 15:12:37 -04:00
|
|
|
echo "----------------------------------------------"
|
2019-10-21 12:05:55 -04:00
|
|
|
echo "Linting Perl files..."
|
2019-10-21 15:12:37 -04:00
|
|
|
echo "----------------------------------------------"
|
2019-10-21 12:05:55 -04:00
|
|
|
echo ""
|
2019-10-21 10:12:50 -04:00
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
######################
|
|
|
|
# Name of the linter #
|
|
|
|
######################
|
|
|
|
LINTER_NAME="perl"
|
|
|
|
|
|
|
|
###################################
|
|
|
|
# Validate we have perl installed #
|
|
|
|
###################################
|
|
|
|
# shellcheck disable=SC2230
|
2019-10-23 11:16:17 -04:00
|
|
|
VALIDATE_INSTALL_CMD=$(command -v "$LINTER_NAME" 2>&1)
|
2019-10-21 10:12:50 -04:00
|
|
|
|
|
|
|
#######################
|
|
|
|
# Load the error code #
|
|
|
|
#######################
|
|
|
|
ERROR_CODE=$?
|
|
|
|
|
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
|
|
|
if [ $ERROR_CODE -ne 0 ]; then
|
2019-10-21 12:05:55 -04:00
|
|
|
# Failed
|
|
|
|
echo "ERROR! Failed to find $LINTER_NAME in system!"
|
|
|
|
echo "ERROR:[$VALIDATE_INSTALL_CMD]"
|
|
|
|
exit 1
|
2019-10-21 10:12:50 -04:00
|
|
|
else
|
|
|
|
# Success
|
2019-10-21 12:05:55 -04:00
|
|
|
echo "Successfully found binary in system"
|
|
|
|
echo "Location:[$VALIDATE_INSTALL_CMD]"
|
2019-10-21 10:12:50 -04:00
|
|
|
fi
|
2019-10-21 12:05:55 -04:00
|
|
|
|
|
|
|
#################################
|
|
|
|
# Get list of all files to lint #
|
|
|
|
#################################
|
2019-10-23 11:38:53 -04:00
|
|
|
# shellcheck disable=SC2207
|
|
|
|
LIST_FILES=($(cd "$GITHUB_WORKSPACE" || exit; find . -type f -name "*.pl" 2>&1))
|
2019-10-21 12:05:55 -04:00
|
|
|
|
|
|
|
##################
|
|
|
|
# Lint the files #
|
|
|
|
##################
|
|
|
|
for FILE in "${LIST_FILES[@]}"
|
|
|
|
do
|
|
|
|
|
|
|
|
#######################################
|
|
|
|
# Make sure we dont lint node modules #
|
|
|
|
#######################################
|
|
|
|
# if [[ $FILE == *"node_modules"* ]]; then
|
|
|
|
# # This is a node modules file
|
|
|
|
# continue
|
|
|
|
# fi
|
|
|
|
|
|
|
|
####################
|
|
|
|
# Get the filename #
|
|
|
|
####################
|
|
|
|
FILE_NAME=$(basename "$FILE" 2>&1)
|
|
|
|
|
|
|
|
##############
|
|
|
|
# File print #
|
|
|
|
##############
|
|
|
|
echo "---------------------------"
|
|
|
|
echo "File:[$FILE]"
|
|
|
|
|
|
|
|
################################
|
|
|
|
# Lint the file with the rules #
|
|
|
|
################################
|
|
|
|
LINT_CMD=$("$LINTER_NAME" -Mstrict -cw "$FILE" 2>&1)
|
|
|
|
|
|
|
|
#######################
|
|
|
|
# Load the error code #
|
|
|
|
#######################
|
|
|
|
ERROR_CODE=$?
|
|
|
|
|
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
|
|
|
if [ $ERROR_CODE -ne 0 ]; then
|
|
|
|
#########
|
|
|
|
# Error #
|
|
|
|
#########
|
|
|
|
echo "ERROR! Found errors in [$LINTER_NAME] linter!"
|
|
|
|
echo "ERROR:[$LINT_CMD]"
|
|
|
|
# Increment error count
|
|
|
|
((ERRORS_FOUND_PERL++))
|
|
|
|
else
|
|
|
|
###########
|
|
|
|
# Success #
|
|
|
|
###########
|
|
|
|
echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully"
|
|
|
|
fi
|
|
|
|
done
|
2019-10-21 10:12:50 -04:00
|
|
|
}
|
|
|
|
################################################################################
|
2019-10-21 12:05:55 -04:00
|
|
|
#### Function LintRubyFiles ####################################################
|
|
|
|
LintRubyFiles()
|
2019-10-21 10:12:50 -04:00
|
|
|
{
|
2019-10-21 12:05:55 -04:00
|
|
|
################
|
|
|
|
# print header #
|
|
|
|
################
|
|
|
|
echo ""
|
2019-10-21 15:12:37 -04:00
|
|
|
echo "----------------------------------------------"
|
2019-10-21 12:05:55 -04:00
|
|
|
echo "Linting Ruby files..."
|
2019-10-21 15:12:37 -04:00
|
|
|
echo "----------------------------------------------"
|
2019-10-21 12:05:55 -04:00
|
|
|
echo ""
|
2019-10-21 10:12:50 -04:00
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
######################
|
|
|
|
# Name of the linter #
|
|
|
|
######################
|
|
|
|
LINTER_NAME="rubocop"
|
2019-10-21 10:12:50 -04:00
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
###################################
|
|
|
|
# Validate we have perl installed #
|
|
|
|
###################################
|
|
|
|
# shellcheck disable=SC2230
|
2019-10-23 11:16:17 -04:00
|
|
|
VALIDATE_INSTALL_CMD=$(command -v "$LINTER_NAME" 2>&1)
|
2019-10-21 10:12:50 -04:00
|
|
|
|
|
|
|
#######################
|
|
|
|
# Load the error code #
|
|
|
|
#######################
|
|
|
|
ERROR_CODE=$?
|
|
|
|
|
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
|
|
|
if [ $ERROR_CODE -ne 0 ]; then
|
2019-10-21 12:05:55 -04:00
|
|
|
# Failed
|
|
|
|
echo "ERROR! Failed to find $LINTER_NAME in system!"
|
|
|
|
echo "ERROR:[$VALIDATE_INSTALL_CMD]"
|
|
|
|
exit 1
|
2019-10-21 10:12:50 -04:00
|
|
|
else
|
|
|
|
# Success
|
2019-10-21 12:05:55 -04:00
|
|
|
echo "Successfully found binary in system"
|
|
|
|
echo "Location:[$VALIDATE_INSTALL_CMD]"
|
2019-10-21 10:12:50 -04:00
|
|
|
fi
|
2019-10-21 12:05:55 -04:00
|
|
|
|
|
|
|
#################################
|
|
|
|
# Get list of all files to lint #
|
|
|
|
#################################
|
2019-10-23 11:38:53 -04:00
|
|
|
# shellcheck disable=SC2207
|
|
|
|
LIST_FILES=($(cd "$GITHUB_WORKSPACE" || exit; find . -type f -name "*.rb" 2>&1))
|
2019-10-21 12:05:55 -04:00
|
|
|
|
|
|
|
##################
|
|
|
|
# Lint the files #
|
|
|
|
##################
|
|
|
|
for FILE in "${LIST_FILES[@]}"
|
|
|
|
do
|
|
|
|
|
|
|
|
#######################################
|
|
|
|
# Make sure we dont lint node modules #
|
|
|
|
#######################################
|
|
|
|
# if [[ $FILE == *"node_modules"* ]]; then
|
|
|
|
# # This is a node modules file
|
|
|
|
# continue
|
|
|
|
# fi
|
|
|
|
|
|
|
|
####################
|
|
|
|
# Get the filename #
|
|
|
|
####################
|
|
|
|
FILE_NAME=$(basename "$FILE" 2>&1)
|
|
|
|
|
|
|
|
##############
|
|
|
|
# File print #
|
|
|
|
##############
|
|
|
|
echo "---------------------------"
|
|
|
|
echo "File:[$FILE]"
|
|
|
|
|
|
|
|
################################
|
|
|
|
# Lint the file with the rules #
|
|
|
|
################################
|
2019-10-21 15:12:37 -04:00
|
|
|
LINT_CMD=$("$LINTER_NAME" -c "$RUBY_LINTER_RULES" "$FILE" 2>&1)
|
2019-10-21 10:12:50 -04:00
|
|
|
|
|
|
|
#######################
|
|
|
|
# Load the error code #
|
|
|
|
#######################
|
|
|
|
ERROR_CODE=$?
|
|
|
|
|
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
|
|
|
if [ $ERROR_CODE -ne 0 ]; then
|
2019-10-21 12:05:55 -04:00
|
|
|
#########
|
|
|
|
# Error #
|
|
|
|
#########
|
|
|
|
echo "ERROR! Found errors in [$LINTER_NAME] linter!"
|
|
|
|
echo "ERROR:[$LINT_CMD]"
|
|
|
|
# Increment error count
|
|
|
|
((ERRORS_FOUND_RUBY++))
|
2019-10-21 10:12:50 -04:00
|
|
|
else
|
2019-10-21 12:05:55 -04:00
|
|
|
###########
|
|
|
|
# Success #
|
|
|
|
###########
|
|
|
|
echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully"
|
2019-10-21 10:12:50 -04:00
|
|
|
fi
|
2019-10-21 12:05:55 -04:00
|
|
|
done
|
2019-10-21 10:12:50 -04:00
|
|
|
}
|
|
|
|
################################################################################
|
2019-10-21 12:05:55 -04:00
|
|
|
#### Function LintCoffeeFiles ##################################################
|
|
|
|
LintCoffeeFiles()
|
2019-10-21 10:12:50 -04:00
|
|
|
{
|
|
|
|
################
|
2019-10-21 12:05:55 -04:00
|
|
|
# print header #
|
2019-10-21 10:12:50 -04:00
|
|
|
################
|
2019-10-21 12:05:55 -04:00
|
|
|
echo ""
|
2019-10-21 15:12:37 -04:00
|
|
|
echo "----------------------------------------------"
|
2019-10-21 12:05:55 -04:00
|
|
|
echo "Linting Coffee files..."
|
2019-10-21 15:12:37 -04:00
|
|
|
echo "----------------------------------------------"
|
2019-10-21 12:05:55 -04:00
|
|
|
echo ""
|
2019-10-21 10:12:50 -04:00
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
######################
|
|
|
|
# Name of the linter #
|
|
|
|
######################
|
|
|
|
LINTER_NAME="coffeelint"
|
2019-10-21 10:12:50 -04:00
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
#####################################
|
|
|
|
# Validate we have pylint installed #
|
|
|
|
#####################################
|
|
|
|
# shellcheck disable=SC2230
|
2019-10-23 11:16:17 -04:00
|
|
|
VALIDATE_INSTALL_CMD=$(command -v "$LINTER_NAME" 2>&1)
|
2019-10-21 10:12:50 -04:00
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
#######################
|
|
|
|
# Load the error code #
|
|
|
|
#######################
|
|
|
|
ERROR_CODE=$?
|
2019-10-21 10:12:50 -04:00
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
|
|
|
if [ $ERROR_CODE -ne 0 ]; then
|
|
|
|
# Failed
|
|
|
|
echo "ERROR! Failed to find $LINTER_NAME in system!"
|
|
|
|
echo "ERROR:[$VALIDATE_INSTALL_CMD]"
|
|
|
|
exit 1
|
2019-10-21 10:12:50 -04:00
|
|
|
else
|
2019-10-21 12:05:55 -04:00
|
|
|
# Success
|
|
|
|
echo "Successfully found binary in system"
|
|
|
|
echo "Location:[$VALIDATE_INSTALL_CMD]"
|
|
|
|
fi
|
|
|
|
|
|
|
|
#################################
|
|
|
|
# Get list of all files to lint #
|
|
|
|
#################################
|
2019-10-23 11:38:53 -04:00
|
|
|
# shellcheck disable=SC2207
|
|
|
|
LIST_FILES=($(cd "$GITHUB_WORKSPACE" || exit; find . -type f -name "*.coffee" 2>&1))
|
2019-10-21 12:05:55 -04:00
|
|
|
|
|
|
|
##################
|
|
|
|
# Lint the files #
|
|
|
|
##################
|
|
|
|
for FILE in "${LIST_FILES[@]}"
|
|
|
|
do
|
|
|
|
|
|
|
|
#######################################
|
|
|
|
# Make sure we dont lint node modules #
|
|
|
|
#######################################
|
|
|
|
# if [[ $FILE == *"node_modules"* ]]; then
|
|
|
|
# # This is a node modules file
|
|
|
|
# continue
|
|
|
|
# fi
|
|
|
|
|
|
|
|
####################
|
|
|
|
# Get the filename #
|
|
|
|
####################
|
|
|
|
FILE_NAME=$(basename "$FILE" 2>&1)
|
|
|
|
|
|
|
|
##############
|
|
|
|
# File print #
|
|
|
|
##############
|
|
|
|
echo "---------------------------"
|
|
|
|
echo "File:[$FILE]"
|
|
|
|
|
|
|
|
################################
|
|
|
|
# Lint the file with the rules #
|
|
|
|
################################
|
2019-10-21 15:12:37 -04:00
|
|
|
LINT_CMD=$("$LINTER_NAME" -f "$COFFEE_LINTER_RULES" "$FILE" 2>&1)
|
2019-10-21 10:12:50 -04:00
|
|
|
|
|
|
|
#######################
|
|
|
|
# Load the error code #
|
|
|
|
#######################
|
|
|
|
ERROR_CODE=$?
|
|
|
|
|
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
|
|
|
if [ $ERROR_CODE -ne 0 ]; then
|
2019-10-21 12:05:55 -04:00
|
|
|
#########
|
|
|
|
# Error #
|
|
|
|
#########
|
|
|
|
echo "ERROR! Found errors in [$LINTER_NAME] linter!"
|
|
|
|
echo "ERROR:[$LINT_CMD]"
|
|
|
|
# Increment error count
|
|
|
|
((ERRORS_FOUND_COFFEE++))
|
|
|
|
else
|
|
|
|
###########
|
|
|
|
# Success #
|
|
|
|
###########
|
|
|
|
echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully"
|
2019-10-21 10:12:50 -04:00
|
|
|
fi
|
2019-10-21 12:05:55 -04:00
|
|
|
done
|
2019-10-21 10:12:50 -04:00
|
|
|
}
|
|
|
|
################################################################################
|
2019-10-21 15:12:37 -04:00
|
|
|
#### Function GetGitHubVars ####################################################
|
|
|
|
GetGitHubVars()
|
|
|
|
{
|
|
|
|
##########
|
|
|
|
# Prints #
|
|
|
|
##########
|
|
|
|
echo "--------------------------------------------"
|
|
|
|
echo "Gathering GitHub information..."
|
|
|
|
|
|
|
|
############################
|
|
|
|
# Validate we have a value #
|
|
|
|
############################
|
|
|
|
if [ -z "$GITHUB_SHA" ]; then
|
|
|
|
echo "ERROR! Failed to get [GITHUB_SHA]!"
|
|
|
|
echo "ERROR:[$GITHUB_SHA]"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Successfully found:[GITHUB_SHA]"
|
|
|
|
fi
|
|
|
|
|
|
|
|
############################
|
|
|
|
# Validate we have a value #
|
|
|
|
############################
|
|
|
|
if [ -z "$GITHUB_WORKSPACE" ]; then
|
|
|
|
echo "ERROR! Failed to get [GITHUB_WORKSPACE]!"
|
|
|
|
echo "ERROR:[$GITHUB_WORKSPACE]"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Successfully found:[GITHUB_WORKSPACE]"
|
|
|
|
fi
|
|
|
|
|
|
|
|
############################
|
|
|
|
# Validate we have a value #
|
|
|
|
############################
|
|
|
|
if [ -z "$GITHUB_EVENT_PATH" ]; then
|
|
|
|
echo "ERROR! Failed to get [GITHUB_EVENT_PATH]!"
|
|
|
|
echo "ERROR:[$GITHUB_EVENT_PATH]"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Successfully found:[GITHUB_EVENT_PATH]"
|
|
|
|
fi
|
|
|
|
|
|
|
|
##################################################
|
|
|
|
# Need to pull the GitHub Vars from the env file #
|
|
|
|
##################################################
|
|
|
|
|
|
|
|
######################
|
|
|
|
# Get the GitHub Org #
|
|
|
|
######################
|
|
|
|
# shellcheck disable=SC2002
|
|
|
|
GITHUB_ORG=$(cat "$GITHUB_EVENT_PATH" | jq -r '.repository.owner.login' )
|
|
|
|
|
|
|
|
############################
|
|
|
|
# Validate we have a value #
|
|
|
|
############################
|
|
|
|
if [ -z "$GITHUB_ORG" ]; then
|
|
|
|
echo "ERROR! Failed to get [GITHUB_ORG]!"
|
|
|
|
echo "ERROR:[$GITHUB_ORG]"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Successfully found:[GITHUB_ORG]"
|
|
|
|
fi
|
|
|
|
|
|
|
|
#######################
|
|
|
|
# Get the GitHub Repo #
|
|
|
|
#######################
|
|
|
|
# shellcheck disable=SC2002
|
|
|
|
GITHUB_REPO=$(cat "$GITHUB_EVENT_PATH"| jq -r '.repository.name' )
|
|
|
|
|
|
|
|
############################
|
|
|
|
# Validate we have a value #
|
|
|
|
############################
|
|
|
|
if [ -z "$GITHUB_REPO" ]; then
|
|
|
|
echo "ERROR! Failed to get [GITHUB_REPO]!"
|
|
|
|
echo "ERROR:[$GITHUB_REPO]"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Successfully found:[GITHUB_REPO]"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
################################################################################
|
2019-10-22 13:21:42 -04:00
|
|
|
#### Function LintAnsibleFiles #################################################
|
|
|
|
LintAnsibleFiles()
|
|
|
|
{
|
|
|
|
ANSIBLE_DIR="$GITHUB_WORKSPACE/ansible" # Ansible directory
|
|
|
|
|
|
|
|
################
|
|
|
|
# print header #
|
|
|
|
################
|
|
|
|
echo ""
|
|
|
|
echo "----------------------------------------------"
|
|
|
|
echo "Linting Ansible files..."
|
|
|
|
echo "----------------------------------------------"
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
######################
|
|
|
|
# Name of the linter #
|
|
|
|
######################
|
|
|
|
LINTER_NAME="ansible-lint"
|
|
|
|
|
|
|
|
###########################################
|
|
|
|
# Validate we have ansible-lint installed #
|
|
|
|
###########################################
|
|
|
|
# shellcheck disable=SC2230
|
2019-10-23 11:16:17 -04:00
|
|
|
VALIDATE_INSTALL_CMD=$(command -v "$LINTER_NAME" 2>&1)
|
2019-10-22 13:21:42 -04:00
|
|
|
|
|
|
|
#######################
|
|
|
|
# Load the error code #
|
|
|
|
#######################
|
|
|
|
ERROR_CODE=$?
|
|
|
|
|
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
|
|
|
if [ $ERROR_CODE -ne 0 ]; then
|
|
|
|
# Failed
|
|
|
|
echo "ERROR! Failed to find $LINTER_NAME in system!"
|
|
|
|
echo "ERROR:[$VALIDATE_INSTALL_CMD]"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
# Success
|
|
|
|
echo "Successfully found binary in system"
|
|
|
|
echo "Location:[$VALIDATE_INSTALL_CMD]"
|
|
|
|
fi
|
|
|
|
|
2019-10-23 10:51:13 -04:00
|
|
|
######################################################
|
|
|
|
# Only go into ansible linter if we have base folder #
|
|
|
|
######################################################
|
|
|
|
if [ -d "$ANSIBLE_DIR" ]; then
|
|
|
|
#################################
|
|
|
|
# Get list of all files to lint #
|
|
|
|
#################################
|
2019-10-23 11:16:17 -04:00
|
|
|
# shellcheck disable=SC2164,SC2010,SC2207
|
2019-10-23 10:51:13 -04:00
|
|
|
LIST_FILES=($(cd "$ANSIBLE_DIR"; ls -I vault.yml -I galaxy.yml | grep ".yml" 2>&1))
|
|
|
|
|
|
|
|
##################
|
|
|
|
# Lint the files #
|
|
|
|
##################
|
|
|
|
for FILE in "${LIST_FILES[@]}"
|
|
|
|
do
|
|
|
|
|
|
|
|
#######################################
|
|
|
|
# Make sure we dont lint node modules #
|
|
|
|
#######################################
|
|
|
|
# if [[ $FILE == *"node_modules"* ]]; then
|
|
|
|
# # This is a node modules file
|
|
|
|
# continue
|
|
|
|
# fi
|
|
|
|
|
|
|
|
####################
|
|
|
|
# Get the filename #
|
|
|
|
####################
|
|
|
|
FILE_NAME=$(basename "$ANSIBLE_DIR/$FILE" 2>&1)
|
|
|
|
|
|
|
|
##############
|
|
|
|
# File print #
|
|
|
|
##############
|
|
|
|
echo "---------------------------"
|
|
|
|
echo "File:[$FILE]"
|
|
|
|
|
|
|
|
################################
|
|
|
|
# Lint the file with the rules #
|
|
|
|
################################
|
|
|
|
LINT_CMD=$("$LINTER_NAME" -v -c "$ANSIBLE_LINTER_FILE" "$ANSIBLE_DIR/$FILE" 2>&1)
|
|
|
|
|
|
|
|
#######################
|
|
|
|
# Load the error code #
|
|
|
|
#######################
|
|
|
|
ERROR_CODE=$?
|
|
|
|
|
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
|
|
|
if [ $ERROR_CODE -ne 0 ]; then
|
|
|
|
#########
|
|
|
|
# Error #
|
|
|
|
#########
|
|
|
|
echo "ERROR! Found errors in [$LINTER_NAME] linter!"
|
|
|
|
echo "ERROR:[$LINT_CMD]"
|
|
|
|
# Increment error count
|
|
|
|
((ERRORS_FOUND_ANSIBLE++))
|
|
|
|
else
|
|
|
|
###########
|
|
|
|
# Success #
|
|
|
|
###########
|
|
|
|
echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
else
|
|
|
|
########################
|
|
|
|
# No Ansible dir found #
|
|
|
|
########################
|
|
|
|
echo "WARN! No Ansible base directory found at:[$ANSIBLE_DIR]"
|
|
|
|
echo "skipping ansible lint"
|
|
|
|
fi
|
2019-10-22 13:21:42 -04:00
|
|
|
}
|
|
|
|
################################################################################
|
2019-10-21 12:05:55 -04:00
|
|
|
#### Function Footer ###########################################################
|
|
|
|
Footer()
|
2019-10-21 10:12:50 -04:00
|
|
|
{
|
2019-10-21 12:05:55 -04:00
|
|
|
echo ""
|
|
|
|
echo "---------------------------"
|
|
|
|
echo "The script has completed"
|
|
|
|
echo "---------------------------"
|
|
|
|
echo "ERRORS FOUND in YAML:[$ERRORS_FOUND_YML]"
|
|
|
|
echo "ERRORS FOUND in JSON:[$ERRORS_FOUND_JSON]"
|
|
|
|
echo "ERRORS FOUND in XML:[$ERRORS_FOUND_XML]"
|
|
|
|
echo "ERRORS FOUND IN MD:[$ERRORS_FOUND_MD]"
|
|
|
|
echo "ERRORS FOUND in BASH:[$ERRORS_FOUND_BASH]"
|
|
|
|
echo "ERRORS FOUND in PERL:[$ERRORS_FOUND_PERL]"
|
|
|
|
echo "ERRORS FOUND in PYTHON:[$ERRORS_FOUND_PYTHON]"
|
|
|
|
echo "ERRORS FOUND in RUBY:[$ERRORS_FOUND_RUBY]"
|
2019-10-22 13:21:42 -04:00
|
|
|
echo "ERRORS FOUND in ANSIBLE:[$ERRORS_FOUND_ANSIBLE]"
|
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
echo ""
|
|
|
|
|
|
|
|
###############################
|
|
|
|
# Exit with 1 if errors found #
|
|
|
|
###############################
|
2019-10-21 15:12:37 -04:00
|
|
|
if [ $ERRORS_FOUND_YML -ne 0 ] || \
|
|
|
|
[ $ERRORS_FOUND_JSON -ne 0 ] || \
|
|
|
|
[ $ERRORS_FOUND_XML -ne 0 ] || \
|
|
|
|
[ $ERRORS_FOUND_MD -ne 0 ] || \
|
|
|
|
[ $ERRORS_FOUND_BASH -ne 0 ] || \
|
|
|
|
[ $ERRORS_FOUND_PERL -ne 0 ] || \
|
|
|
|
[ $ERRORS_FOUND_PYTHON -ne 0 ] || \
|
2019-10-22 13:21:42 -04:00
|
|
|
[ $ERRORS_FOUND_ANSIBLE -ne 0 ] || \
|
2019-10-21 15:12:37 -04:00
|
|
|
[ $ERRORS_FOUND_RUBY -ne 0 ]; then
|
2019-10-21 12:05:55 -04:00
|
|
|
# Failed exit
|
|
|
|
echo "Exiting with errors found!"
|
2019-10-21 10:12:50 -04:00
|
|
|
exit 1
|
|
|
|
else
|
2019-10-21 12:05:55 -04:00
|
|
|
# Successful exit
|
|
|
|
exit 0
|
2019-10-21 10:12:50 -04:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
################################################################################
|
2019-10-21 12:05:55 -04:00
|
|
|
############################### MAIN ###########################################
|
2019-10-21 10:12:50 -04:00
|
|
|
################################################################################
|
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
##########
|
|
|
|
# Header #
|
|
|
|
##########
|
|
|
|
Header
|
|
|
|
|
2019-10-21 15:12:37 -04:00
|
|
|
#######################
|
|
|
|
# Get Github Env Vars #
|
|
|
|
#######################
|
|
|
|
# Need to pull in all the Github variables
|
|
|
|
# needed to connect back and update checks
|
|
|
|
GetGitHubVars
|
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
########################
|
|
|
|
# Get the linter rules #
|
|
|
|
########################
|
|
|
|
GetLinterRules
|
|
|
|
|
2019-10-21 15:12:37 -04:00
|
|
|
######################
|
|
|
|
# Validate workspace #
|
|
|
|
######################
|
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
######################
|
|
|
|
# Lint the Yml Files #
|
|
|
|
######################
|
|
|
|
LintYmlFiles
|
|
|
|
|
2019-10-21 10:12:50 -04:00
|
|
|
#######################
|
2019-10-21 12:05:55 -04:00
|
|
|
# Lint the json files #
|
2019-10-21 10:12:50 -04:00
|
|
|
#######################
|
2019-10-21 12:05:55 -04:00
|
|
|
LintJsonFiles
|
2019-10-21 10:12:50 -04:00
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
######################
|
|
|
|
# Lint the XML Files #
|
|
|
|
######################
|
|
|
|
LintXmlFiles
|
2019-10-21 10:12:50 -04:00
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
###########################
|
|
|
|
# Lint the Markdown Files #
|
|
|
|
###########################
|
|
|
|
LintMdFiles
|
|
|
|
|
|
|
|
#######################
|
|
|
|
# Lint the bash files #
|
|
|
|
#######################
|
|
|
|
LintBashFiles
|
|
|
|
|
|
|
|
#########################
|
|
|
|
# Lint the python files #
|
|
|
|
#########################
|
|
|
|
LintPythonFiles
|
|
|
|
|
|
|
|
#######################
|
|
|
|
# Lint the perl files #
|
|
|
|
#######################
|
|
|
|
LintPerlFiles
|
|
|
|
|
|
|
|
#######################
|
|
|
|
# Lint the ruby files #
|
|
|
|
#######################
|
|
|
|
LintRubyFiles
|
|
|
|
|
|
|
|
#########################
|
|
|
|
# Lint the coffee files #
|
|
|
|
#########################
|
|
|
|
LintCoffeeFiles
|
|
|
|
|
2019-10-22 13:21:42 -04:00
|
|
|
##########################
|
|
|
|
# Lint the Ansible files #
|
|
|
|
##########################
|
|
|
|
LintAnsibleFiles
|
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
##########
|
|
|
|
# Footer #
|
|
|
|
##########
|
|
|
|
Footer
|