mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-21 21:50:59 -05:00
fixed and cleaned folders
This commit is contained in:
parent
5cfc3ac09c
commit
67ca56bf84
13 changed files with 147 additions and 1930 deletions
|
@ -1,3 +0,0 @@
|
||||||
# Automation
|
|
||||||
|
|
||||||
This folder holds all scripting and configuration to run **GitHub Actions** that validate the sanity of the source code in this repository.
|
|
|
@ -1,184 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
################## Ansible Linter @admiralawkbar ###############################
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
###########
|
|
||||||
# GLOBALS #
|
|
||||||
###########
|
|
||||||
BUILD_DIR=$(pwd 2>&1) # Current Build dir
|
|
||||||
ANSIBLE_LINTER_FILE=".automation/.ansible-lint" # Name of the Linter file
|
|
||||||
ANSIBLE_DIR="$BUILD_DIR/ansible" # Ansible directory
|
|
||||||
|
|
||||||
############
|
|
||||||
# Counters #
|
|
||||||
############
|
|
||||||
ERRORS_FOUND_ANSIBLE=0 # Count of errors found
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
########################## FUNCTIONS BELOW #####################################
|
|
||||||
################################################################################
|
|
||||||
################################################################################
|
|
||||||
#### Function Header ###########################################################
|
|
||||||
Header()
|
|
||||||
{
|
|
||||||
echo ""
|
|
||||||
echo "-----------------------------------"
|
|
||||||
echo "---------- Ansible Linter ---------"
|
|
||||||
echo "-----------------------------------"
|
|
||||||
echo ""
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
#### Function LintAnsibleFiles #################################################
|
|
||||||
LintAnsibleFiles()
|
|
||||||
{
|
|
||||||
################
|
|
||||||
# print header #
|
|
||||||
################
|
|
||||||
echo ""
|
|
||||||
echo "--------------------------------"
|
|
||||||
echo "Linting Ansible files..."
|
|
||||||
echo "--------------------------------"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
##########################################
|
|
||||||
# Validate we have the linter rules file #
|
|
||||||
##########################################
|
|
||||||
if [ ! -f "$ANSIBLE_LINTER_FILE" ]; then
|
|
||||||
# Error
|
|
||||||
echo "ERROR! Failed to find rules file at:[$ANSIBLE_LINTER_FILE]"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
######################
|
|
||||||
# Name of the linter #
|
|
||||||
######################
|
|
||||||
LINTER_NAME="ansible-lint"
|
|
||||||
|
|
||||||
###########################################
|
|
||||||
# Validate we have ansible-lint installed #
|
|
||||||
###########################################
|
|
||||||
# shellcheck disable=SC2230
|
|
||||||
VALIDATE_INSTALL_CMD=$(which "$LINTER_NAME" 2>&1)
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# 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
|
|
||||||
|
|
||||||
#################################
|
|
||||||
# Get list of all files to lint #
|
|
||||||
#################################
|
|
||||||
# shellcheck disable=SC2164,SC2010,SC2207
|
|
||||||
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
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
#### Function Footer ###########################################################
|
|
||||||
Footer()
|
|
||||||
{
|
|
||||||
echo ""
|
|
||||||
echo "---------------------------"
|
|
||||||
echo "The script has completed"
|
|
||||||
echo "---------------------------"
|
|
||||||
echo "ERRORS FOUND in ANSIBLE:[$ERRORS_FOUND_ANSIBLE]"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
###############################
|
|
||||||
# Exit with 1 if errors found #
|
|
||||||
###############################
|
|
||||||
if [ $ERRORS_FOUND_ANSIBLE -ne 0 ]; then
|
|
||||||
# Failed exit
|
|
||||||
echo "Exiting with errors found!"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
# Successful exit
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
############################### MAIN ###########################################
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
##########
|
|
||||||
# Header #
|
|
||||||
##########
|
|
||||||
Header
|
|
||||||
|
|
||||||
##########################
|
|
||||||
# Lint the Ansible files #
|
|
||||||
##########################
|
|
||||||
LintAnsibleFiles
|
|
||||||
|
|
||||||
##########
|
|
||||||
# Footer #
|
|
||||||
##########
|
|
||||||
Footer
|
|
|
@ -1,347 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
################## Scripting Language Linter @admiralawkbar ####################
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
###########
|
|
||||||
# GLOBALS #
|
|
||||||
###########
|
|
||||||
APT_PACKAGE_ARRAY=() # Packages to install using APT
|
|
||||||
GEM_PACKAGE_ARRAY=() # Packages to install using GEM
|
|
||||||
NPM_PACKAGE_ARRAY=() # Packages to install using NPM
|
|
||||||
PIP_PACKAGE_ARRAY=(
|
|
||||||
"ansible-lint==4.0.1") # Packages to install using PIP
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
########################## FUNCTIONS BELOW #####################################
|
|
||||||
################################################################################
|
|
||||||
################################################################################
|
|
||||||
#### Function Header ###########################################################
|
|
||||||
Header()
|
|
||||||
{
|
|
||||||
echo ""
|
|
||||||
echo "------------------------------"
|
|
||||||
echo "---- Install Dependancies ----"
|
|
||||||
echo "------------------------------"
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
#### Function InstallAptPackages ###############################################
|
|
||||||
InstallAptPackages()
|
|
||||||
{
|
|
||||||
######################################################
|
|
||||||
# Convert Array to string for single pass to install #
|
|
||||||
######################################################
|
|
||||||
INSTALL_PACKAGE_STRING=$(ConvertArray "${APT_PACKAGE_ARRAY[@]}")
|
|
||||||
|
|
||||||
###############################
|
|
||||||
# Check the string for length #
|
|
||||||
###############################
|
|
||||||
LENGTH=${#INSTALL_PACKAGE_STRING}
|
|
||||||
|
|
||||||
#############################
|
|
||||||
# Skip loop if no variables #
|
|
||||||
#############################
|
|
||||||
if [ "$LENGTH" -le 1 ]; then
|
|
||||||
echo ""
|
|
||||||
echo "------------------------------"
|
|
||||||
echo "No APT package(s) to install... skipping..."
|
|
||||||
else
|
|
||||||
###########
|
|
||||||
# Headers #
|
|
||||||
###########
|
|
||||||
echo ""
|
|
||||||
echo "------------------------------"
|
|
||||||
echo "Installing APT package(s)"
|
|
||||||
echo "Packages:[$INSTALL_PACKAGE_STRING]"
|
|
||||||
echo "This could take several moments..."
|
|
||||||
|
|
||||||
####################################
|
|
||||||
# Need to install all APT packages #
|
|
||||||
####################################
|
|
||||||
# shellcheck disable=SC2086
|
|
||||||
INSTALL_CMD=$(sudo apt-get install $INSTALL_PACKAGE_STRING -y 2>&1)
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# Load the error code #
|
|
||||||
#######################
|
|
||||||
ERROR_CODE=$?
|
|
||||||
|
|
||||||
##############################
|
|
||||||
# Check the shell for errors #
|
|
||||||
##############################
|
|
||||||
if [ $ERROR_CODE -ne 0 ]; then
|
|
||||||
# Error
|
|
||||||
echo "ERROR! Failed to install APT packages!"
|
|
||||||
echo "ERROR:[$INSTALL_CMD]"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
# Success
|
|
||||||
echo "Successfully installed all APT packages"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
#### Function InstallPipPackages ###############################################
|
|
||||||
InstallPipPackages()
|
|
||||||
{
|
|
||||||
######################################################
|
|
||||||
# Convert Array to string for single pass to install #
|
|
||||||
######################################################
|
|
||||||
INSTALL_PACKAGE_STRING=$(ConvertArray "${PIP_PACKAGE_ARRAY[@]}")
|
|
||||||
|
|
||||||
###############################
|
|
||||||
# Check the string for length #
|
|
||||||
###############################
|
|
||||||
LENGTH=${#INSTALL_PACKAGE_STRING}
|
|
||||||
|
|
||||||
#############################
|
|
||||||
# Skip loop if no variables #
|
|
||||||
#############################
|
|
||||||
if [ "$LENGTH" -le 1 ]; then
|
|
||||||
echo ""
|
|
||||||
echo "------------------------------"
|
|
||||||
echo "No PIP package(s) to install... skipping..."
|
|
||||||
else
|
|
||||||
###########
|
|
||||||
# Headers #
|
|
||||||
###########
|
|
||||||
echo ""
|
|
||||||
echo "------------------------------"
|
|
||||||
echo "Installing PIP package(s)"
|
|
||||||
echo "Packages:[$INSTALL_PACKAGE_STRING]"
|
|
||||||
echo "This could take several moments..."
|
|
||||||
|
|
||||||
####################################
|
|
||||||
# Need to install all APT packages #
|
|
||||||
####################################
|
|
||||||
# shellcheck disable=SC2086
|
|
||||||
INSTALL_CMD=$(sudo -H pip install $INSTALL_PACKAGE_STRING 2>&1)
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# Load the error code #
|
|
||||||
#######################
|
|
||||||
ERROR_CODE=$?
|
|
||||||
|
|
||||||
##############################
|
|
||||||
# Check the shell for errors #
|
|
||||||
##############################
|
|
||||||
if [ $ERROR_CODE -ne 0 ]; then
|
|
||||||
# Error
|
|
||||||
echo "ERROR! Failed to install PIP packages!"
|
|
||||||
echo "ERROR:[$INSTALL_CMD]"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
# Success
|
|
||||||
echo "Successfully installed all PIP packages"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
#### Function InstallGemPackages ###############################################
|
|
||||||
InstallGemPackages()
|
|
||||||
{
|
|
||||||
######################################################
|
|
||||||
# Convert Array to string for single pass to install #
|
|
||||||
######################################################
|
|
||||||
INSTALL_PACKAGE_STRING=$(ConvertArray "${GEM_PACKAGE_ARRAY[@]}")
|
|
||||||
|
|
||||||
###############################
|
|
||||||
# Check the string for length #
|
|
||||||
###############################
|
|
||||||
LENGTH=${#INSTALL_PACKAGE_STRING}
|
|
||||||
|
|
||||||
#############################
|
|
||||||
# Skip loop if no variables #
|
|
||||||
#############################
|
|
||||||
if [ "$LENGTH" -le 1 ]; then
|
|
||||||
echo ""
|
|
||||||
echo "------------------------------"
|
|
||||||
echo "No GEM package(s) to install... skipping..."
|
|
||||||
else
|
|
||||||
###########
|
|
||||||
# Headers #
|
|
||||||
###########
|
|
||||||
echo ""
|
|
||||||
echo "------------------------------"
|
|
||||||
echo "Installing GEM package(s)"
|
|
||||||
echo "Packages:[$INSTALL_PACKAGE_STRING]"
|
|
||||||
echo "This could take several moments..."
|
|
||||||
|
|
||||||
####################################
|
|
||||||
# Need to install all APT packages #
|
|
||||||
####################################
|
|
||||||
# shellcheck disable=SC2086
|
|
||||||
INSTALL_CMD=$(gem install $INSTALL_PACKAGE_STRING 2>&1)
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# Load the error code #
|
|
||||||
#######################
|
|
||||||
ERROR_CODE=$?
|
|
||||||
|
|
||||||
##############################
|
|
||||||
# Check the shell for errors #
|
|
||||||
##############################
|
|
||||||
if [ $ERROR_CODE -ne 0 ]; then
|
|
||||||
# Error
|
|
||||||
echo "ERROR! Failed to install GEM packages!"
|
|
||||||
echo "ERROR:[$INSTALL_CMD]"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
# Success
|
|
||||||
echo "Successfully installed all GEM packages"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
#### Function InstallNPMPackages ###############################################
|
|
||||||
InstallNPMPackages()
|
|
||||||
{
|
|
||||||
######################################################
|
|
||||||
# Convert Array to string for single pass to install #
|
|
||||||
######################################################
|
|
||||||
INSTALL_PACKAGE_STRING=$(ConvertArray "${NPM_PACKAGE_ARRAY[@]}")
|
|
||||||
|
|
||||||
###############################
|
|
||||||
# Check the string for length #
|
|
||||||
###############################
|
|
||||||
LENGTH=${#INSTALL_PACKAGE_STRING}
|
|
||||||
|
|
||||||
#############################
|
|
||||||
# Skip loop if no variables #
|
|
||||||
#############################
|
|
||||||
if [ "$LENGTH" -le 1 ]; then
|
|
||||||
echo ""
|
|
||||||
echo "------------------------------"
|
|
||||||
echo "No NPM package(s) to install... skipping..."
|
|
||||||
else
|
|
||||||
###########
|
|
||||||
# Headers #
|
|
||||||
###########
|
|
||||||
echo ""
|
|
||||||
echo "------------------------------"
|
|
||||||
echo "Installing NPM package(s)"
|
|
||||||
echo "Packages:[$INSTALL_PACKAGE_STRING]"
|
|
||||||
echo "This could take several moments..."
|
|
||||||
|
|
||||||
####################################
|
|
||||||
# Need to install all APT packages #
|
|
||||||
####################################
|
|
||||||
# shellcheck disable=SC2086
|
|
||||||
INSTALL_CMD=$(npm -g install $INSTALL_PACKAGE_STRING 2>&1)
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# Load the error code #
|
|
||||||
#######################
|
|
||||||
ERROR_CODE=$?
|
|
||||||
|
|
||||||
##############################
|
|
||||||
# Check the shell for errors #
|
|
||||||
##############################
|
|
||||||
if [ $ERROR_CODE -ne 0 ]; then
|
|
||||||
# Error
|
|
||||||
echo "ERROR! Failed to install NPM packages!"
|
|
||||||
echo "ERROR:[$INSTALL_CMD]"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
# Success
|
|
||||||
echo "Successfully installed all NPM packages"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
#### Function ConvertArray #####################################################
|
|
||||||
ConvertArray()
|
|
||||||
{
|
|
||||||
#####################
|
|
||||||
# Read in the array #
|
|
||||||
#####################
|
|
||||||
ARRAY=("$@")
|
|
||||||
|
|
||||||
###################################################
|
|
||||||
# Convert the array into a space seperated string #
|
|
||||||
###################################################
|
|
||||||
STRING=$(IFS=$' '; echo "${ARRAY[*]}" 2>&1)
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# Load the error code #
|
|
||||||
#######################
|
|
||||||
ERROR_CODE=$?
|
|
||||||
|
|
||||||
##############################
|
|
||||||
# Check the shell for errors #
|
|
||||||
##############################
|
|
||||||
if [ $ERROR_CODE -ne 0 ]; then
|
|
||||||
# Error
|
|
||||||
echo "ERROR! Failed to create string!"
|
|
||||||
echo "ERROR:[$STRING]"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
##########################################
|
|
||||||
# Need to remove whitespace on the edges #
|
|
||||||
##########################################
|
|
||||||
CLEANED_STRING=$(echo "$STRING" | xargs 2>&1)
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# Load the error code #
|
|
||||||
#######################
|
|
||||||
ERROR_CODE=$?
|
|
||||||
|
|
||||||
##############################
|
|
||||||
# Check the shell for errors #
|
|
||||||
##############################
|
|
||||||
if [ $ERROR_CODE -ne 0 ]; then
|
|
||||||
# Error
|
|
||||||
echo "ERROR! Failed to clean string!"
|
|
||||||
echo "ERROR:[$STRING]"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
############################################################
|
|
||||||
# Echo the cleaned string back to the master function call #
|
|
||||||
############################################################
|
|
||||||
echo "$CLEANED_STRING"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
#### Function Footer ###########################################################
|
|
||||||
Footer()
|
|
||||||
{
|
|
||||||
echo ""
|
|
||||||
echo "---------------------------"
|
|
||||||
echo "The script has completed"
|
|
||||||
echo "---------------------------"
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
############################### MAIN ###########################################
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
##########
|
|
||||||
# Header #
|
|
||||||
##########
|
|
||||||
Header
|
|
||||||
|
|
||||||
########################
|
|
||||||
# Install APT packages #
|
|
||||||
########################
|
|
||||||
InstallAptPackages
|
|
||||||
|
|
||||||
########################
|
|
||||||
# Install PIP packages #
|
|
||||||
########################
|
|
||||||
InstallPipPackages
|
|
||||||
|
|
||||||
########################
|
|
||||||
# Install GEM packages #
|
|
||||||
########################
|
|
||||||
InstallGemPackages
|
|
||||||
|
|
||||||
########################
|
|
||||||
# Install NPM packages #
|
|
||||||
########################
|
|
||||||
InstallNPMPackages
|
|
||||||
|
|
||||||
##########
|
|
||||||
# Footer #
|
|
||||||
##########
|
|
||||||
Footer
|
|
|
@ -1,353 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
################## Scripting Language Linter @admiralawkbar ####################
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
###########
|
|
||||||
# GLOBALS #
|
|
||||||
###########
|
|
||||||
APT_PACKAGE_ARRAY=(
|
|
||||||
"yamllint"
|
|
||||||
"shellcheck"
|
|
||||||
"jsonlint"
|
|
||||||
"pylint"
|
|
||||||
"libxml2-utils") # Packages to install using APT
|
|
||||||
GEM_PACKAGE_ARRAY=(
|
|
||||||
"rubocop") # Packages to install using GEM
|
|
||||||
NPM_PACKAGE_ARRAY=(
|
|
||||||
"markdownlint-cli") # Packages to install using NPM
|
|
||||||
PIP_PACKAGE_ARRAY=() # Packages to install using PIP
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
########################## FUNCTIONS BELOW #####################################
|
|
||||||
################################################################################
|
|
||||||
################################################################################
|
|
||||||
#### Function Header ###########################################################
|
|
||||||
Header()
|
|
||||||
{
|
|
||||||
echo ""
|
|
||||||
echo "------------------------------"
|
|
||||||
echo "---- Install Dependancies ----"
|
|
||||||
echo "------------------------------"
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
#### Function InstallAptPackages ###############################################
|
|
||||||
InstallAptPackages()
|
|
||||||
{
|
|
||||||
######################################################
|
|
||||||
# Convert Array to string for single pass to install #
|
|
||||||
######################################################
|
|
||||||
INSTALL_PACKAGE_STRING=$(ConvertArray "${APT_PACKAGE_ARRAY[@]}")
|
|
||||||
|
|
||||||
###############################
|
|
||||||
# Check the string for length #
|
|
||||||
###############################
|
|
||||||
LENGTH=${#INSTALL_PACKAGE_STRING}
|
|
||||||
|
|
||||||
#############################
|
|
||||||
# Skip loop if no variables #
|
|
||||||
#############################
|
|
||||||
if [ "$LENGTH" -le 1 ]; then
|
|
||||||
echo ""
|
|
||||||
echo "------------------------------"
|
|
||||||
echo "No APT package(s) to install... skipping..."
|
|
||||||
else
|
|
||||||
###########
|
|
||||||
# Headers #
|
|
||||||
###########
|
|
||||||
echo ""
|
|
||||||
echo "------------------------------"
|
|
||||||
echo "Installing APT package(s)"
|
|
||||||
echo "Packages:[$INSTALL_PACKAGE_STRING]"
|
|
||||||
echo "This could take several moments..."
|
|
||||||
|
|
||||||
####################################
|
|
||||||
# Need to install all APT packages #
|
|
||||||
####################################
|
|
||||||
# shellcheck disable=SC2086
|
|
||||||
INSTALL_CMD=$(sudo apt-get install $INSTALL_PACKAGE_STRING -y 2>&1)
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# Load the error code #
|
|
||||||
#######################
|
|
||||||
ERROR_CODE=$?
|
|
||||||
|
|
||||||
##############################
|
|
||||||
# Check the shell for errors #
|
|
||||||
##############################
|
|
||||||
if [ $ERROR_CODE -ne 0 ]; then
|
|
||||||
# Error
|
|
||||||
echo "ERROR! Failed to install APT packages!"
|
|
||||||
echo "ERROR:[$INSTALL_CMD]"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
# Success
|
|
||||||
echo "Successfully installed all APT packages"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
#### Function InstallPipPackages ###############################################
|
|
||||||
InstallPipPackages()
|
|
||||||
{
|
|
||||||
######################################################
|
|
||||||
# Convert Array to string for single pass to install #
|
|
||||||
######################################################
|
|
||||||
INSTALL_PACKAGE_STRING=$(ConvertArray "${PIP_PACKAGE_ARRAY[@]}")
|
|
||||||
|
|
||||||
###############################
|
|
||||||
# Check the string for length #
|
|
||||||
###############################
|
|
||||||
LENGTH=${#INSTALL_PACKAGE_STRING}
|
|
||||||
|
|
||||||
#############################
|
|
||||||
# Skip loop if no variables #
|
|
||||||
#############################
|
|
||||||
if [ "$LENGTH" -le 1 ]; then
|
|
||||||
echo ""
|
|
||||||
echo "------------------------------"
|
|
||||||
echo "No PIP package(s) to install... skipping..."
|
|
||||||
else
|
|
||||||
###########
|
|
||||||
# Headers #
|
|
||||||
###########
|
|
||||||
echo ""
|
|
||||||
echo "------------------------------"
|
|
||||||
echo "Installing PIP package(s)"
|
|
||||||
echo "Packages:[$INSTALL_PACKAGE_STRING]"
|
|
||||||
echo "This could take several moments..."
|
|
||||||
|
|
||||||
####################################
|
|
||||||
# Need to install all APT packages #
|
|
||||||
####################################
|
|
||||||
# shellcheck disable=SC2086
|
|
||||||
INSTALL_CMD=$(pip install $INSTALL_PACKAGE_STRING 2>&1)
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# Load the error code #
|
|
||||||
#######################
|
|
||||||
ERROR_CODE=$?
|
|
||||||
|
|
||||||
##############################
|
|
||||||
# Check the shell for errors #
|
|
||||||
##############################
|
|
||||||
if [ $ERROR_CODE -ne 0 ]; then
|
|
||||||
# Error
|
|
||||||
echo "ERROR! Failed to install PIP packages!"
|
|
||||||
echo "ERROR:[$INSTALL_CMD]"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
# Success
|
|
||||||
echo "Successfully installed all PIP packages"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
#### Function InstallGemPackages ###############################################
|
|
||||||
InstallGemPackages()
|
|
||||||
{
|
|
||||||
######################################################
|
|
||||||
# Convert Array to string for single pass to install #
|
|
||||||
######################################################
|
|
||||||
INSTALL_PACKAGE_STRING=$(ConvertArray "${GEM_PACKAGE_ARRAY[@]}")
|
|
||||||
|
|
||||||
###############################
|
|
||||||
# Check the string for length #
|
|
||||||
###############################
|
|
||||||
LENGTH=${#INSTALL_PACKAGE_STRING}
|
|
||||||
|
|
||||||
#############################
|
|
||||||
# Skip loop if no variables #
|
|
||||||
#############################
|
|
||||||
if [ "$LENGTH" -le 1 ]; then
|
|
||||||
echo ""
|
|
||||||
echo "------------------------------"
|
|
||||||
echo "No GEM package(s) to install... skipping..."
|
|
||||||
else
|
|
||||||
###########
|
|
||||||
# Headers #
|
|
||||||
###########
|
|
||||||
echo ""
|
|
||||||
echo "------------------------------"
|
|
||||||
echo "Installing GEM package(s)"
|
|
||||||
echo "Packages:[$INSTALL_PACKAGE_STRING]"
|
|
||||||
echo "This could take several moments..."
|
|
||||||
|
|
||||||
####################################
|
|
||||||
# Need to install all APT packages #
|
|
||||||
####################################
|
|
||||||
# shellcheck disable=SC2086
|
|
||||||
INSTALL_CMD=$(gem install $INSTALL_PACKAGE_STRING 2>&1)
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# Load the error code #
|
|
||||||
#######################
|
|
||||||
ERROR_CODE=$?
|
|
||||||
|
|
||||||
##############################
|
|
||||||
# Check the shell for errors #
|
|
||||||
##############################
|
|
||||||
if [ $ERROR_CODE -ne 0 ]; then
|
|
||||||
# Error
|
|
||||||
echo "ERROR! Failed to install GEM packages!"
|
|
||||||
echo "ERROR:[$INSTALL_CMD]"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
# Success
|
|
||||||
echo "Successfully installed all GEM packages"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
#### Function InstallNPMPackages ###############################################
|
|
||||||
InstallNPMPackages()
|
|
||||||
{
|
|
||||||
######################################################
|
|
||||||
# Convert Array to string for single pass to install #
|
|
||||||
######################################################
|
|
||||||
INSTALL_PACKAGE_STRING=$(ConvertArray "${NPM_PACKAGE_ARRAY[@]}")
|
|
||||||
|
|
||||||
###############################
|
|
||||||
# Check the string for length #
|
|
||||||
###############################
|
|
||||||
LENGTH=${#INSTALL_PACKAGE_STRING}
|
|
||||||
|
|
||||||
#############################
|
|
||||||
# Skip loop if no variables #
|
|
||||||
#############################
|
|
||||||
if [ "$LENGTH" -le 1 ]; then
|
|
||||||
echo ""
|
|
||||||
echo "------------------------------"
|
|
||||||
echo "No NPM package(s) to install... skipping..."
|
|
||||||
else
|
|
||||||
###########
|
|
||||||
# Headers #
|
|
||||||
###########
|
|
||||||
echo ""
|
|
||||||
echo "------------------------------"
|
|
||||||
echo "Installing NPM package(s)"
|
|
||||||
echo "Packages:[$INSTALL_PACKAGE_STRING]"
|
|
||||||
echo "This could take several moments..."
|
|
||||||
|
|
||||||
####################################
|
|
||||||
# Need to install all APT packages #
|
|
||||||
####################################
|
|
||||||
# shellcheck disable=SC2086
|
|
||||||
INSTALL_CMD=$(npm -g install $INSTALL_PACKAGE_STRING 2>&1)
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# Load the error code #
|
|
||||||
#######################
|
|
||||||
ERROR_CODE=$?
|
|
||||||
|
|
||||||
##############################
|
|
||||||
# Check the shell for errors #
|
|
||||||
##############################
|
|
||||||
if [ $ERROR_CODE -ne 0 ]; then
|
|
||||||
# Error
|
|
||||||
echo "ERROR! Failed to install NPM packages!"
|
|
||||||
echo "ERROR:[$INSTALL_CMD]"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
# Success
|
|
||||||
echo "Successfully installed all NPM packages"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
#### Function ConvertArray #####################################################
|
|
||||||
ConvertArray()
|
|
||||||
{
|
|
||||||
#####################
|
|
||||||
# Read in the array #
|
|
||||||
#####################
|
|
||||||
ARRAY=("$@")
|
|
||||||
|
|
||||||
###################################################
|
|
||||||
# Convert the array into a space seperated string #
|
|
||||||
###################################################
|
|
||||||
STRING=$(IFS=$' '; echo "${ARRAY[*]}" 2>&1)
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# Load the error code #
|
|
||||||
#######################
|
|
||||||
ERROR_CODE=$?
|
|
||||||
|
|
||||||
##############################
|
|
||||||
# Check the shell for errors #
|
|
||||||
##############################
|
|
||||||
if [ $ERROR_CODE -ne 0 ]; then
|
|
||||||
# Error
|
|
||||||
echo "ERROR! Failed to create string!"
|
|
||||||
echo "ERROR:[$STRING]"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
##########################################
|
|
||||||
# Need to remove whitespace on the edges #
|
|
||||||
##########################################
|
|
||||||
CLEANED_STRING=$(echo "$STRING" | xargs 2>&1)
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# Load the error code #
|
|
||||||
#######################
|
|
||||||
ERROR_CODE=$?
|
|
||||||
|
|
||||||
##############################
|
|
||||||
# Check the shell for errors #
|
|
||||||
##############################
|
|
||||||
if [ $ERROR_CODE -ne 0 ]; then
|
|
||||||
# Error
|
|
||||||
echo "ERROR! Failed to clean string!"
|
|
||||||
echo "ERROR:[$STRING]"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
############################################################
|
|
||||||
# Echo the cleaned string back to the master function call #
|
|
||||||
############################################################
|
|
||||||
echo "$CLEANED_STRING"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
#### Function Footer ###########################################################
|
|
||||||
Footer()
|
|
||||||
{
|
|
||||||
echo ""
|
|
||||||
echo "---------------------------"
|
|
||||||
echo "The script has completed"
|
|
||||||
echo "---------------------------"
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
############################### MAIN ###########################################
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
##########
|
|
||||||
# Header #
|
|
||||||
##########
|
|
||||||
Header
|
|
||||||
|
|
||||||
########################
|
|
||||||
# Install APT packages #
|
|
||||||
########################
|
|
||||||
InstallAptPackages
|
|
||||||
|
|
||||||
########################
|
|
||||||
# Install PIP packages #
|
|
||||||
########################
|
|
||||||
InstallPipPackages
|
|
||||||
|
|
||||||
########################
|
|
||||||
# Install GEM packages #
|
|
||||||
########################
|
|
||||||
InstallGemPackages
|
|
||||||
|
|
||||||
########################
|
|
||||||
# Install NPM packages #
|
|
||||||
########################
|
|
||||||
InstallNPMPackages
|
|
||||||
|
|
||||||
##########
|
|
||||||
# Footer #
|
|
||||||
##########
|
|
||||||
Footer
|
|
|
@ -1,527 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
########### Markup and Markdown Language Linter @AdmiralAwkbar #################
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
###########
|
|
||||||
# GLOBALS #
|
|
||||||
###########
|
|
||||||
YAML_LINTER_RULES='.automation/yaml-linter-rules.yml' # Path to the yaml lint rules
|
|
||||||
MD_LINTER_RULES='.automation/md-linter-rules.yml' # Path to the markdown lint rules
|
|
||||||
|
|
||||||
############
|
|
||||||
# Counters #
|
|
||||||
############
|
|
||||||
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
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
########################## FUNCTIONS BELOW #####################################
|
|
||||||
################################################################################
|
|
||||||
################################################################################
|
|
||||||
#### Function Header ###########################################################
|
|
||||||
Header()
|
|
||||||
{
|
|
||||||
echo ""
|
|
||||||
echo "---------------------------------------------"
|
|
||||||
echo "---- Markup and Markdown Language Linter ----"
|
|
||||||
echo "---------------------------------------------"
|
|
||||||
echo ""
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
#### Function GetLinterRules ###################################################
|
|
||||||
GetLinterRules()
|
|
||||||
{
|
|
||||||
# Need to validate the rules files exist
|
|
||||||
|
|
||||||
#####################################
|
|
||||||
# Validate we have the linter rules #
|
|
||||||
#####################################
|
|
||||||
if [ ! -f "$YAML_LINTER_RULES" ]; then
|
|
||||||
echo "ERROR! Failed to find:[$YAML_LINTER_RULES] in root of code base!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
#####################################
|
|
||||||
# Validate we have the linter rules #
|
|
||||||
#####################################
|
|
||||||
if [ ! -f "$MD_LINTER_RULES" ]; then
|
|
||||||
echo "ERROR! Failed to find:[$MD_LINTER_RULES] in root of code base!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
#### Function LintJsonFiles ####################################################
|
|
||||||
LintJsonFiles()
|
|
||||||
{
|
|
||||||
################
|
|
||||||
# print header #
|
|
||||||
################
|
|
||||||
echo ""
|
|
||||||
echo "--------------------------------"
|
|
||||||
echo "Linting JSON files..."
|
|
||||||
echo "--------------------------------"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
######################
|
|
||||||
# Name of the linter #
|
|
||||||
######################
|
|
||||||
LINTER_NAME="jsonlint-php"
|
|
||||||
|
|
||||||
#######################################
|
|
||||||
# Validate we have yamllint installed #
|
|
||||||
#######################################
|
|
||||||
# shellcheck disable=SC2230
|
|
||||||
VALIDATE_INSTALL_CMD=$(which "$LINTER_NAME" 2>&1)
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# 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
|
|
||||||
|
|
||||||
#################################
|
|
||||||
# Get list of all files to lint #
|
|
||||||
#################################
|
|
||||||
# shellcheck disable=SC2207
|
|
||||||
LIST_FILES=($(find . -type f -name "*.json" 2>&1))
|
|
||||||
|
|
||||||
##################
|
|
||||||
# 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)
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# 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_JSON++))
|
|
||||||
else
|
|
||||||
###########
|
|
||||||
# Success #
|
|
||||||
###########
|
|
||||||
echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
#### Function LintYmlFiles #####################################################
|
|
||||||
LintYmlFiles()
|
|
||||||
{
|
|
||||||
################
|
|
||||||
# print header #
|
|
||||||
################
|
|
||||||
echo ""
|
|
||||||
echo "--------------------------------"
|
|
||||||
echo "Linting YAML files..."
|
|
||||||
echo "--------------------------------"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
######################
|
|
||||||
# Name of the linter #
|
|
||||||
######################
|
|
||||||
LINTER_NAME="yamllint"
|
|
||||||
|
|
||||||
#######################################
|
|
||||||
# Validate we have yamllint installed #
|
|
||||||
#######################################
|
|
||||||
# shellcheck disable=SC2230
|
|
||||||
VALIDATE_INSTALL_CMD=$(which "$LINTER_NAME" 2>&1)
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# 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
|
|
||||||
|
|
||||||
#################################
|
|
||||||
# Get list of all files to lint #
|
|
||||||
#################################
|
|
||||||
# shellcheck disable=SC2207
|
|
||||||
LIST_FILES=($(find . -type f \( -name "*.yml" -or -name "*.yaml" \) 2>&1))
|
|
||||||
|
|
||||||
##################
|
|
||||||
# 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)
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# 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_YML++))
|
|
||||||
else
|
|
||||||
###########
|
|
||||||
# Success #
|
|
||||||
###########
|
|
||||||
echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
#### Function LintXmlFiles #####################################################
|
|
||||||
LintXmlFiles()
|
|
||||||
{
|
|
||||||
################
|
|
||||||
# print header #
|
|
||||||
################
|
|
||||||
echo ""
|
|
||||||
echo "--------------------------------"
|
|
||||||
echo "Linting XML files..."
|
|
||||||
echo "--------------------------------"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
######################
|
|
||||||
# Name of the linter #
|
|
||||||
######################
|
|
||||||
LINTER_NAME="xmllint"
|
|
||||||
|
|
||||||
#######################################
|
|
||||||
# Validate we have yamllint installed #
|
|
||||||
#######################################
|
|
||||||
# shellcheck disable=SC2230
|
|
||||||
VALIDATE_INSTALL_CMD=$(which "$LINTER_NAME" 2>&1)
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# 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
|
|
||||||
|
|
||||||
#################################
|
|
||||||
# Get list of all files to lint #
|
|
||||||
#################################
|
|
||||||
# shellcheck disable=SC2207
|
|
||||||
LIST_FILES=($(find . -type f -name "*.xml" 2>&1))
|
|
||||||
|
|
||||||
##################
|
|
||||||
# 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)
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# 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_XML++))
|
|
||||||
else
|
|
||||||
###########
|
|
||||||
# Success #
|
|
||||||
###########
|
|
||||||
echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
#### Function LintMdFiles ######################################################
|
|
||||||
LintMdFiles()
|
|
||||||
{
|
|
||||||
################
|
|
||||||
# print header #
|
|
||||||
################
|
|
||||||
echo ""
|
|
||||||
echo "--------------------------------"
|
|
||||||
echo "Linting Markdown files..."
|
|
||||||
echo "--------------------------------"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
######################
|
|
||||||
# Name of the linter #
|
|
||||||
######################
|
|
||||||
LINTER_NAME="markdownlint"
|
|
||||||
|
|
||||||
#######################################
|
|
||||||
# Validate we have yamllint installed #
|
|
||||||
#######################################
|
|
||||||
# shellcheck disable=SC2230
|
|
||||||
VALIDATE_INSTALL_CMD=$(which "$LINTER_NAME" 2>&1)
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# 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
|
|
||||||
|
|
||||||
#################################
|
|
||||||
# Get list of all files to lint #
|
|
||||||
#################################
|
|
||||||
# shellcheck disable=SC2207
|
|
||||||
LIST_FILES=($(find . -type f -name "*.md" 2>&1))
|
|
||||||
|
|
||||||
##################
|
|
||||||
# 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
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
#### Function Footer ###########################################################
|
|
||||||
Footer()
|
|
||||||
{
|
|
||||||
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 ""
|
|
||||||
|
|
||||||
###############################
|
|
||||||
# Exit with 1 if errors found #
|
|
||||||
###############################
|
|
||||||
if [ $ERRORS_FOUND_YML -ne 0 ] || [ $ERRORS_FOUND_JSON -ne 0 ] || [ $ERRORS_FOUND_XML -ne 0 ] || [ $ERRORS_FOUND_MD -ne 0 ]; then
|
|
||||||
# Failed exit
|
|
||||||
echo "Exiting with errors found!"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
# Successful exit
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
############################### MAIN ###########################################
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
##########
|
|
||||||
# Header #
|
|
||||||
##########
|
|
||||||
Header
|
|
||||||
|
|
||||||
########################
|
|
||||||
# Get the linter rules #
|
|
||||||
########################
|
|
||||||
GetLinterRules
|
|
||||||
|
|
||||||
######################
|
|
||||||
# Lint the Yml Files #
|
|
||||||
######################
|
|
||||||
LintYmlFiles
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# Lint the json files #
|
|
||||||
#######################
|
|
||||||
LintJsonFiles
|
|
||||||
|
|
||||||
######################
|
|
||||||
# Lint the XML Files #
|
|
||||||
######################
|
|
||||||
LintXmlFiles
|
|
||||||
|
|
||||||
###########################
|
|
||||||
# Lint the Markdown Files #
|
|
||||||
###########################
|
|
||||||
LintMdFiles
|
|
||||||
|
|
||||||
##########
|
|
||||||
# Footer #
|
|
||||||
##########
|
|
||||||
Footer
|
|
|
@ -1,504 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
################## Scripting Language Linter @admiralawkbar ####################
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
###########
|
|
||||||
# GLOBALS #
|
|
||||||
###########
|
|
||||||
PYTHON_LINTER_FILE=".automation/pylintrc" # Name of the Linter file
|
|
||||||
RUBY_LINTER_FILE=".automation/.rubocop.yml" # Name of the Linter file
|
|
||||||
|
|
||||||
############
|
|
||||||
# Counters #
|
|
||||||
############
|
|
||||||
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
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
########################## FUNCTIONS BELOW #####################################
|
|
||||||
################################################################################
|
|
||||||
################################################################################
|
|
||||||
#### Function Header ###########################################################
|
|
||||||
Header()
|
|
||||||
{
|
|
||||||
echo ""
|
|
||||||
echo "-----------------------------------"
|
|
||||||
echo "---- Scripting Language Linter ----"
|
|
||||||
echo "-----------------------------------"
|
|
||||||
echo ""
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
#### Function LintBashFiles ####################################################
|
|
||||||
LintBashFiles()
|
|
||||||
{
|
|
||||||
################
|
|
||||||
# print header #
|
|
||||||
################
|
|
||||||
echo ""
|
|
||||||
echo "--------------------------------"
|
|
||||||
echo "Linting Bash files..."
|
|
||||||
echo "--------------------------------"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
######################
|
|
||||||
# Name of the linter #
|
|
||||||
######################
|
|
||||||
LINTER_NAME="shellcheck"
|
|
||||||
|
|
||||||
#########################################
|
|
||||||
# Validate we have shellcheck installed #
|
|
||||||
#########################################
|
|
||||||
# shellcheck disable=SC2230
|
|
||||||
VALIDATE_INSTALL_CMD=$(which "$LINTER_NAME" 2>&1)
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# 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
|
|
||||||
|
|
||||||
#################################
|
|
||||||
# Get list of all files to lint #
|
|
||||||
#################################
|
|
||||||
# shellcheck disable=SC2207
|
|
||||||
LIST_FILES=($(find . -type f -name "*.sh" 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 "$FILE" 2>&1)
|
|
||||||
|
|
||||||
##############
|
|
||||||
# File print #
|
|
||||||
##############
|
|
||||||
echo "---------------------------"
|
|
||||||
echo "File:[$FILE]"
|
|
||||||
|
|
||||||
################################
|
|
||||||
# Lint the file with the rules #
|
|
||||||
################################
|
|
||||||
LINT_CMD=$("$LINTER_NAME" "$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_BASH++))
|
|
||||||
else
|
|
||||||
###########
|
|
||||||
# Success #
|
|
||||||
###########
|
|
||||||
echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
#### Function LintPythonFiles ##################################################
|
|
||||||
LintPythonFiles()
|
|
||||||
{
|
|
||||||
################
|
|
||||||
# print header #
|
|
||||||
################
|
|
||||||
echo ""
|
|
||||||
echo "--------------------------------"
|
|
||||||
echo "Linting Python files..."
|
|
||||||
echo "--------------------------------"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
######################
|
|
||||||
# Name of the linter #
|
|
||||||
######################
|
|
||||||
LINTER_NAME="pylint"
|
|
||||||
|
|
||||||
#####################################
|
|
||||||
# Validate we have pylint installed #
|
|
||||||
#####################################
|
|
||||||
# shellcheck disable=SC2230
|
|
||||||
VALIDATE_INSTALL_CMD=$(which "$LINTER_NAME" 2>&1)
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# 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
|
|
||||||
|
|
||||||
#################################
|
|
||||||
# Get list of all files to lint #
|
|
||||||
#################################
|
|
||||||
# shellcheck disable=SC2207
|
|
||||||
LIST_FILES=($(find . -type f -name "*.py" 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 "$FILE" 2>&1)
|
|
||||||
|
|
||||||
##############
|
|
||||||
# File print #
|
|
||||||
##############
|
|
||||||
echo "---------------------------"
|
|
||||||
echo "File:[$FILE]"
|
|
||||||
|
|
||||||
################################
|
|
||||||
# Lint the file with the rules #
|
|
||||||
################################
|
|
||||||
LINT_CMD=$("$LINTER_NAME" --rcfile "$PYTHON_LINTER_FILE" -E "$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_PYTHON++))
|
|
||||||
else
|
|
||||||
###########
|
|
||||||
# Success #
|
|
||||||
###########
|
|
||||||
echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
#### Function LintPerlFiles ####################################################
|
|
||||||
LintPerlFiles()
|
|
||||||
{
|
|
||||||
################
|
|
||||||
# print header #
|
|
||||||
################
|
|
||||||
echo ""
|
|
||||||
echo "--------------------------------"
|
|
||||||
echo "Linting Perl files..."
|
|
||||||
echo "--------------------------------"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
######################
|
|
||||||
# Name of the linter #
|
|
||||||
######################
|
|
||||||
LINTER_NAME="perl"
|
|
||||||
|
|
||||||
###################################
|
|
||||||
# Validate we have perl installed #
|
|
||||||
###################################
|
|
||||||
# shellcheck disable=SC2230
|
|
||||||
VALIDATE_INSTALL_CMD=$(which "$LINTER_NAME" 2>&1)
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# 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
|
|
||||||
|
|
||||||
#################################
|
|
||||||
# Get list of all files to lint #
|
|
||||||
#################################
|
|
||||||
# shellcheck disable=SC2207
|
|
||||||
LIST_FILES=($(find . -type f -name "*.pl" 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 "$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
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
#### Function LintRubyFiles ####################################################
|
|
||||||
LintRubyFiles()
|
|
||||||
{
|
|
||||||
################
|
|
||||||
# print header #
|
|
||||||
################
|
|
||||||
echo ""
|
|
||||||
echo "--------------------------------"
|
|
||||||
echo "Linting Ruby files..."
|
|
||||||
echo "--------------------------------"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
######################
|
|
||||||
# Name of the linter #
|
|
||||||
######################
|
|
||||||
LINTER_NAME="rubocop"
|
|
||||||
|
|
||||||
###################################
|
|
||||||
# Validate we have perl installed #
|
|
||||||
###################################
|
|
||||||
# shellcheck disable=SC2230
|
|
||||||
VALIDATE_INSTALL_CMD=$(which "$LINTER_NAME" 2>&1)
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# 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
|
|
||||||
|
|
||||||
#################################
|
|
||||||
# Get list of all files to lint #
|
|
||||||
#################################
|
|
||||||
# shellcheck disable=SC2207
|
|
||||||
LIST_FILES=($(find . -type f -name "*.rb" 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 "$FILE" 2>&1)
|
|
||||||
|
|
||||||
##############
|
|
||||||
# File print #
|
|
||||||
##############
|
|
||||||
echo "---------------------------"
|
|
||||||
echo "File:[$FILE]"
|
|
||||||
|
|
||||||
################################
|
|
||||||
# Lint the file with the rules #
|
|
||||||
################################
|
|
||||||
LINT_CMD=$("$LINTER_NAME" -c "$RUBY_LINTER_FILE" "$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_RUBY++))
|
|
||||||
else
|
|
||||||
###########
|
|
||||||
# Success #
|
|
||||||
###########
|
|
||||||
echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
#### Function Footer ###########################################################
|
|
||||||
Footer()
|
|
||||||
{
|
|
||||||
echo ""
|
|
||||||
echo "---------------------------"
|
|
||||||
echo "The script has completed"
|
|
||||||
echo "---------------------------"
|
|
||||||
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]"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
###############################
|
|
||||||
# Exit with 1 if errors found #
|
|
||||||
###############################
|
|
||||||
if [ $ERRORS_FOUND_BASH -ne 0 ] || [ $ERRORS_FOUND_PERL -ne 0 ] || [ $ERRORS_FOUND_PYTHON -ne 0 ] || [ $ERRORS_FOUND_RUBY -ne 0 ]; then
|
|
||||||
# Failed exit
|
|
||||||
echo "Exiting with errors found!"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
# Successful exit
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
############################### MAIN ###########################################
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
##########
|
|
||||||
# Header #
|
|
||||||
##########
|
|
||||||
Header
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# Lint the bash files #
|
|
||||||
#######################
|
|
||||||
LintBashFiles
|
|
||||||
|
|
||||||
#########################
|
|
||||||
# Lint the python files #
|
|
||||||
#########################
|
|
||||||
LintPythonFiles
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# Lint the perl files #
|
|
||||||
#######################
|
|
||||||
LintPerlFiles
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# Lint the ruby files #
|
|
||||||
#######################
|
|
||||||
LintRubyFiles
|
|
||||||
|
|
||||||
##########
|
|
||||||
# Footer #
|
|
||||||
##########
|
|
||||||
Footer
|
|
135
.github/linters/.coffee-lint.json
vendored
Normal file
135
.github/linters/.coffee-lint.json
vendored
Normal file
|
@ -0,0 +1,135 @@
|
||||||
|
{
|
||||||
|
"arrow_spacing": {
|
||||||
|
"level": "ignore"
|
||||||
|
},
|
||||||
|
"braces_spacing": {
|
||||||
|
"level": "ignore",
|
||||||
|
"spaces": 0,
|
||||||
|
"empty_object_spaces": 0
|
||||||
|
},
|
||||||
|
"camel_case_classes": {
|
||||||
|
"level": "error"
|
||||||
|
},
|
||||||
|
"coffeescript_error": {
|
||||||
|
"level": "error"
|
||||||
|
},
|
||||||
|
"colon_assignment_spacing": {
|
||||||
|
"level": "ignore",
|
||||||
|
"spacing": {
|
||||||
|
"left": 0,
|
||||||
|
"right": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"cyclomatic_complexity": {
|
||||||
|
"level": "ignore",
|
||||||
|
"value": 10
|
||||||
|
},
|
||||||
|
"duplicate_key": {
|
||||||
|
"level": "error"
|
||||||
|
},
|
||||||
|
"empty_constructor_needs_parens": {
|
||||||
|
"level": "ignore"
|
||||||
|
},
|
||||||
|
"ensure_comprehensions": {
|
||||||
|
"level": "warn"
|
||||||
|
},
|
||||||
|
"eol_last": {
|
||||||
|
"level": "ignore"
|
||||||
|
},
|
||||||
|
"indentation": {
|
||||||
|
"value": 2,
|
||||||
|
"level": "warn"
|
||||||
|
},
|
||||||
|
"line_endings": {
|
||||||
|
"level": "ignore",
|
||||||
|
"value": "unix"
|
||||||
|
},
|
||||||
|
"max_line_length": {
|
||||||
|
"value": 80,
|
||||||
|
"level": "ignore",
|
||||||
|
"limitComments": true
|
||||||
|
},
|
||||||
|
"missing_fat_arrows": {
|
||||||
|
"level": "ignore",
|
||||||
|
"is_strict": false
|
||||||
|
},
|
||||||
|
"newlines_after_classes": {
|
||||||
|
"value": 3,
|
||||||
|
"level": "ignore"
|
||||||
|
},
|
||||||
|
"no_backticks": {
|
||||||
|
"level": "error"
|
||||||
|
},
|
||||||
|
"no_debugger": {
|
||||||
|
"level": "warn",
|
||||||
|
"console": false
|
||||||
|
},
|
||||||
|
"no_empty_functions": {
|
||||||
|
"level": "ignore"
|
||||||
|
},
|
||||||
|
"no_empty_param_list": {
|
||||||
|
"level": "ignore"
|
||||||
|
},
|
||||||
|
"no_implicit_braces": {
|
||||||
|
"level": "ignore",
|
||||||
|
"strict": true
|
||||||
|
},
|
||||||
|
"no_implicit_parens": {
|
||||||
|
"level": "ignore",
|
||||||
|
"strict": true
|
||||||
|
},
|
||||||
|
"no_interpolation_in_single_quotes": {
|
||||||
|
"level": "ignore"
|
||||||
|
},
|
||||||
|
"no_nested_string_interpolation": {
|
||||||
|
"level": "warn"
|
||||||
|
},
|
||||||
|
"no_plusplus": {
|
||||||
|
"level": "ignore"
|
||||||
|
},
|
||||||
|
"no_private_function_fat_arrows": {
|
||||||
|
"level": "warn"
|
||||||
|
},
|
||||||
|
"no_stand_alone_at": {
|
||||||
|
"level": "ignore"
|
||||||
|
},
|
||||||
|
"no_tabs": {
|
||||||
|
"level": "error"
|
||||||
|
},
|
||||||
|
"no_this": {
|
||||||
|
"level": "ignore"
|
||||||
|
},
|
||||||
|
"no_throwing_strings": {
|
||||||
|
"level": "error"
|
||||||
|
},
|
||||||
|
"no_trailing_semicolons": {
|
||||||
|
"level": "error"
|
||||||
|
},
|
||||||
|
"no_trailing_whitespace": {
|
||||||
|
"level": "ignore",
|
||||||
|
"allowed_in_comments": false,
|
||||||
|
"allowed_in_empty_lines": true
|
||||||
|
},
|
||||||
|
"no_unnecessary_double_quotes": {
|
||||||
|
"level": "ignore"
|
||||||
|
},
|
||||||
|
"no_unnecessary_fat_arrows": {
|
||||||
|
"level": "warn"
|
||||||
|
},
|
||||||
|
"non_empty_constructor_needs_parens": {
|
||||||
|
"level": "ignore"
|
||||||
|
},
|
||||||
|
"prefer_english_operator": {
|
||||||
|
"level": "ignore",
|
||||||
|
"doubleNotLevel": "ignore"
|
||||||
|
},
|
||||||
|
"space_operators": {
|
||||||
|
"level": "ignore"
|
||||||
|
},
|
||||||
|
"spacing_after_comma": {
|
||||||
|
"level": "ignore"
|
||||||
|
},
|
||||||
|
"transform_messes_up_line_numbers": {
|
||||||
|
"level": "warn"
|
||||||
|
}
|
||||||
|
}
|
|
@ -78,13 +78,13 @@ GetLinterRules()
|
||||||
#####################################
|
#####################################
|
||||||
# Validate we have the linter rules #
|
# Validate we have the linter rules #
|
||||||
#####################################
|
#####################################
|
||||||
if [ -f "$GITHUB_WORKSPACE/.github/$YAML_FILE_NAME" ]; then
|
if [ -f "$GITHUB_WORKSPACE/.github/linters/$YAML_FILE_NAME" ]; then
|
||||||
echo "User provided file:[$YAML_FILE_NAME], setting rules file..."
|
echo "User provided file:[$YAML_FILE_NAME], setting rules file..."
|
||||||
|
|
||||||
####################################
|
####################################
|
||||||
# Move users into default location #
|
# Move users into default location #
|
||||||
####################################
|
####################################
|
||||||
MV_CMD=$(mv "$GITHUB_WORKSPACE/.github/$YAML_FILE_NAME" "$YAML_LINTER_RULES" 2>&1)
|
MV_CMD=$(mv "$GITHUB_WORKSPACE/.github/linters/$YAML_FILE_NAME" "$YAML_LINTER_RULES" 2>&1)
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# Load Error code #
|
# Load Error code #
|
||||||
|
@ -106,13 +106,13 @@ GetLinterRules()
|
||||||
#####################################
|
#####################################
|
||||||
# Validate we have the linter rules #
|
# Validate we have the linter rules #
|
||||||
#####################################
|
#####################################
|
||||||
if [ -f "$GITHUB_WORKSPACE/.github/$MD_FILE_NAME" ]; then
|
if [ -f "$GITHUB_WORKSPACE/.github/linters/$MD_FILE_NAME" ]; then
|
||||||
echo "User provided file:[$MD_FILE_NAME], setting rules file..."
|
echo "User provided file:[$MD_FILE_NAME], setting rules file..."
|
||||||
|
|
||||||
####################################
|
####################################
|
||||||
# Move users into default location #
|
# Move users into default location #
|
||||||
####################################
|
####################################
|
||||||
MV_CMD=$(mv "$GITHUB_WORKSPACE/.github/$MD_FILE_NAME" "$MD_LINTER_RULES" 2>&1)
|
MV_CMD=$(mv "$GITHUB_WORKSPACE/.github/linters/$MD_FILE_NAME" "$MD_LINTER_RULES" 2>&1)
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# Load Error code #
|
# Load Error code #
|
||||||
|
@ -134,13 +134,13 @@ GetLinterRules()
|
||||||
#####################################
|
#####################################
|
||||||
# Validate we have the linter rules #
|
# Validate we have the linter rules #
|
||||||
#####################################
|
#####################################
|
||||||
if [ -f "$GITHUB_WORKSPACE/.github/$PYTHON_FILE_NAME" ]; then
|
if [ -f "$GITHUB_WORKSPACE/.github/linters/$PYTHON_FILE_NAME" ]; then
|
||||||
echo "User provided file:[$PYTHON_FILE_NAME], setting rules file..."
|
echo "User provided file:[$PYTHON_FILE_NAME], setting rules file..."
|
||||||
|
|
||||||
####################################
|
####################################
|
||||||
# Move users into default location #
|
# Move users into default location #
|
||||||
####################################
|
####################################
|
||||||
MV_CMD=$(mv "$GITHUB_WORKSPACE/.github/$PYTHON_FILE_NAME" "$PYTHON_LINTER_RULES" 2>&1)
|
MV_CMD=$(mv "$GITHUB_WORKSPACE/.github/linters/$PYTHON_FILE_NAME" "$PYTHON_LINTER_RULES" 2>&1)
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# Load Error code #
|
# Load Error code #
|
||||||
|
@ -162,13 +162,13 @@ GetLinterRules()
|
||||||
#####################################
|
#####################################
|
||||||
# Validate we have the linter rules #
|
# Validate we have the linter rules #
|
||||||
#####################################
|
#####################################
|
||||||
if [ -f "$GITHUB_WORKSPACE/.github/$RUBY_FILE_NAME" ]; then
|
if [ -f "$GITHUB_WORKSPACE/.github/linters/$RUBY_FILE_NAME" ]; then
|
||||||
echo "User provided file:[$RUBY_FILE_NAME], setting rules file..."
|
echo "User provided file:[$RUBY_FILE_NAME], setting rules file..."
|
||||||
|
|
||||||
####################################
|
####################################
|
||||||
# Move users into default location #
|
# Move users into default location #
|
||||||
####################################
|
####################################
|
||||||
MV_CMD=$(mv "$GITHUB_WORKSPACE/.github/$RUBY_FILE_NAME" "$RUBY_LINTER_RULES" 2>&1)
|
MV_CMD=$(mv "$GITHUB_WORKSPACE/.github/linters/$RUBY_FILE_NAME" "$RUBY_LINTER_RULES" 2>&1)
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# Load Error code #
|
# Load Error code #
|
||||||
|
@ -190,13 +190,13 @@ GetLinterRules()
|
||||||
#####################################
|
#####################################
|
||||||
# Validate we have the linter rules #
|
# Validate we have the linter rules #
|
||||||
#####################################
|
#####################################
|
||||||
if [ -f "$GITHUB_WORKSPACE/.github/$COFFEE_FILE_NAME" ]; then
|
if [ -f "$GITHUB_WORKSPACE/.github/linters/$COFFEE_FILE_NAME" ]; then
|
||||||
echo "User provided file:[$COFFEE_FILE_NAME], setting rules file..."
|
echo "User provided file:[$COFFEE_FILE_NAME], setting rules file..."
|
||||||
|
|
||||||
####################################
|
####################################
|
||||||
# Move users into default location #
|
# Move users into default location #
|
||||||
####################################
|
####################################
|
||||||
MV_CMD=$(mv "$GITHUB_WORKSPACE/.github/$COFFEE_FILE_NAME" "$COFFEE_LINTER_RULES" 2>&1)
|
MV_CMD=$(mv "$GITHUB_WORKSPACE/.github/linters/$COFFEE_FILE_NAME" "$COFFEE_LINTER_RULES" 2>&1)
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# Load Error code #
|
# Load Error code #
|
||||||
|
@ -218,13 +218,13 @@ GetLinterRules()
|
||||||
#####################################
|
#####################################
|
||||||
# Validate we have the linter rules #
|
# Validate we have the linter rules #
|
||||||
#####################################
|
#####################################
|
||||||
if [ -f "$GITHUB_WORKSPACE/.github/$ANSIBLE_FILE_NAME" ]; then
|
if [ -f "$GITHUB_WORKSPACE/.github/linters/$ANSIBLE_FILE_NAME" ]; then
|
||||||
echo "User provided file:[$ANSIBLE_FILE_NAME], setting rules file..."
|
echo "User provided file:[$ANSIBLE_FILE_NAME], setting rules file..."
|
||||||
|
|
||||||
####################################
|
####################################
|
||||||
# Move users into default location #
|
# Move users into default location #
|
||||||
####################################
|
####################################
|
||||||
MV_CMD=$(mv "$GITHUB_WORKSPACE/.github/$ANSIBLE_FILE_NAME" "$ANSIBLE_LINTER_RULES" 2>&1)
|
MV_CMD=$(mv "$GITHUB_WORKSPACE/.github/linters/$ANSIBLE_FILE_NAME" "$ANSIBLE_LINTER_RULES" 2>&1)
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# Load Error code #
|
# Load Error code #
|
||||||
|
|
Loading…
Reference in a new issue