superlint/lib/validation.sh

826 lines
27 KiB
Bash
Raw Normal View History

2020-06-29 10:55:59 -04:00
#!/usr/bin/env bash
################################################################################
################################################################################
########### Super-Linter Validation Functions @admiralawkbar ###################
################################################################################
################################################################################
########################## FUNCTION CALLS BELOW ################################
################################################################################
################################################################################
#### Function GetValidationInfo ################################################
2020-07-01 17:40:40 -04:00
function GetValidationInfo() {
2020-06-29 10:55:59 -04:00
############################################
# Print headers for user provided env vars #
############################################
echo ""
echo "--------------------------------------------"
echo "Gathering user validation information..."
###########################################
# Skip validation if were running locally #
###########################################
2020-07-01 17:40:40 -04:00
if [[ $RUN_LOCAL != "true" ]]; then
2020-06-29 10:55:59 -04:00
###############################
# Convert string to lowercase #
###############################
2020-07-21 12:09:05 -04:00
VALIDATE_ALL_CODEBASE="${VALIDATE_ALL_CODEBASE,,}"
2020-06-29 10:55:59 -04:00
######################################
# Validate we should check all files #
######################################
2020-07-01 17:40:40 -04:00
if [[ $VALIDATE_ALL_CODEBASE != "false" ]]; then
2020-06-29 10:55:59 -04:00
# Set to true
VALIDATE_ALL_CODEBASE="$DEFAULT_VALIDATE_ALL_CODEBASE"
echo "- Validating ALL files in code base..."
else
# Its false
echo "- Only validating [new], or [edited] files in code base..."
fi
fi
######################
# Create Print Array #
######################
PRINT_ARRAY=()
################################
# Convert strings to lowercase #
################################
2020-07-21 12:09:05 -04:00
VALIDATE_ANSIBLE="${VALIDATE_ANSIBLE,,}"
VALIDATE_ARM="${VALIDATE_ARM,,}"
VALIDATE_BASH="${VALIDATE_BASH,,}"
VALIDATE_CLOJURE="${VALIDATE_CLOJURE,,}"
VALIDATE_COFFEE="${VALIDATE_COFFEE,,}"
VALIDATE_CSS="${VALIDATE_CSS,,}"
VALIDATE_DART="${VALIDATE_DART,,}"
VALIDATE_DOCKER="${VALIDATE_DOCKER,,}"
VALIDATE_EDITORCONFIG="${VALIDATE_EDITORCONFIG,,}"
VALIDATE_ENV="${VALIDATE_ENV,,}"
VALIDATE_GO="${VALIDATE_GO,,}"
VALIDATE_HTML="${VALIDATE_HTML,,}"
VALIDATE_JAVASCRIPT_ES="${VALIDATE_JAVASCRIPT_ES,,}"
VALIDATE_JAVASCRIPT_STANDARD="${VALIDATE_JAVASCRIPT_STANDARD,,}"
VALIDATE_JSON="${VALIDATE_JSON,,}"
VALIDATE_JSX="${VALIDATE_JSX,,}"
VALIDATE_KOTLIN="${VALIDATE_KOTLIN,,}"
VALIDATE_MARKDOWN="${VALIDATE_MARKDOWN,,}"
VALIDATE_OPENAPI="${VALIDATE_OPENAPI,,}"
VALIDATE_PERL="${VALIDATE_PERL,,}"
VALIDATE_PHP="${VALIDATE_PHP,,}"
VALIDATE_POWERSHELL="${VALIDATE_POWERSHELL,,}"
VALIDATE_PROTOBUF="${VALIDATE_PROTOBUF,,}"
VALIDATE_PYTHON="${VALIDATE_PYTHON,,}"
VALIDATE_RAKU="${VALIDATE_RAKU,,}"
VALIDATE_RUBY="${VALIDATE_RUBY,,}"
2020-07-21 14:50:04 -04:00
VALIDATE_STATES="${VALIDATE_STATES,,}"
2020-07-21 12:09:05 -04:00
VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM,,}"
VALIDATE_TSX="${VALIDATE_TSX,,}"
VALIDATE_TYPESCRIPT_ES="${VALIDATE_TYPESCRIPT_ES,,}"
VALIDATE_TYPESCRIPT_STANDARD="${VALIDATE_TYPESCRIPT_STANDARD,,}"
VALIDATE_YAML="${VALIDATE_YAML,,}"
VALIDATE_XML="${VALIDATE_XML,,}"
2020-06-29 10:55:59 -04:00
################################################
# Determine if any linters were explicitly set #
################################################
ANY_SET="false"
2020-07-21 14:50:04 -04:00
if [[ -n $VALIDATE_ANSIBLE || -n \
$VALIDATE_ARM || -n \
$VALIDATE_BASH || -n \
$VALIDATE_CLOJURE || -n \
$VALIDATE_COFFEE || -n \
$VALIDATE_CSS || -n \
$VALIDATE_DART || -n \
$VALIDATE_DOCKER || -n \
$VALIDATE_EDITORCONFIG || -n \
$VALIDATE_ENV || -n \
$VALIDATE_GO || -n \
2020-07-21 14:55:27 -04:00
$VALIDATE_HTML || -n \
2020-07-21 14:50:04 -04:00
$VALIDATE_JAVASCRIPT_ES || -n \
$VALIDATE_JAVASCRIPT_STANDARD || -n \
2020-07-01 17:40:40 -04:00
$VALIDATE_JSON || -n \
2020-07-21 14:50:04 -04:00
$VALIDATE_KOTLIN || -n \
2020-07-21 09:52:30 -04:00
$VALIDATE_MARKDOWN || -n \
2020-07-21 14:50:04 -04:00
$VALIDATE_OPENAPI || -n \
2020-07-01 17:40:40 -04:00
$VALIDATE_PERL || -n \
$VALIDATE_PHP || -n \
2020-07-21 14:50:04 -04:00
$VALIDATE_POWERSHELL || -n \
$VALIDATE_PROTOBUF || -n \
2020-07-01 17:40:40 -04:00
$VALIDATE_PYTHON || -n \
2020-07-21 14:50:04 -04:00
$VALIDATE_RAKU || -n \
2020-07-01 17:40:40 -04:00
$VALIDATE_RUBY || -n \
2020-07-21 14:50:04 -04:00
$VALIDATE_TERRAFORM || -n \
2020-07-01 17:40:40 -04:00
$VALIDATE_TYPESCRIPT_ES || -n \
$VALIDATE_TYPESCRIPT_STANDARD || -n \
2020-07-21 14:50:04 -04:00
$VALIDATE_XML || -n \
$VALIDATE_YAML ]]; then
2020-06-29 10:55:59 -04:00
ANY_SET="true"
fi
####################################
# Validate if we should check YAML #
####################################
2020-07-01 17:40:40 -04:00
if [[ $ANY_SET == "true" ]]; then
2020-06-29 10:55:59 -04:00
# Some linter flags were set - only run those set to true
2020-07-01 17:40:40 -04:00
if [[ -z $VALIDATE_YAML ]]; then
2020-06-29 10:55:59 -04:00
# YAML flag was not set - default to false
VALIDATE_YAML="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_YAML="true"
fi
####################################
# Validate if we should check JSON #
####################################
2020-07-01 17:40:40 -04:00
if [[ $ANY_SET == "true" ]]; then
2020-06-29 10:55:59 -04:00
# Some linter flags were set - only run those set to true
2020-07-01 17:40:40 -04:00
if [[ -z $VALIDATE_JSON ]]; then
2020-06-29 10:55:59 -04:00
# JSON flag was not set - default to false
VALIDATE_JSON="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_JSON="true"
fi
###################################
# Validate if we should check XML #
###################################
2020-07-01 17:40:40 -04:00
if [[ $ANY_SET == "true" ]]; then
2020-06-29 10:55:59 -04:00
# Some linter flags were set - only run those set to true
2020-07-01 17:40:40 -04:00
if [[ -z $VALIDATE_XML ]]; then
2020-06-29 10:55:59 -04:00
# XML flag was not set - default to false
VALIDATE_XML="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_XML="true"
fi
########################################
# Validate if we should check MARKDOWN #
########################################
2020-07-01 17:40:40 -04:00
if [[ $ANY_SET == "true" ]]; then
2020-06-29 10:55:59 -04:00
# Some linter flags were set - only run those set to true
2020-07-21 09:52:30 -04:00
if [[ -z $VALIDATE_MARKDOWN ]]; then
2020-06-29 10:55:59 -04:00
# MD flag was not set - default to false
2020-07-21 09:52:30 -04:00
VALIDATE_MARKDOWN="false"
2020-06-29 10:55:59 -04:00
fi
else
# No linter flags were set - default all to true
2020-07-21 09:52:30 -04:00
VALIDATE_MARKDOWN="true"
2020-06-29 10:55:59 -04:00
fi
####################################
# Validate if we should check BASH #
####################################
2020-07-01 17:40:40 -04:00
if [[ $ANY_SET == "true" ]]; then
2020-06-29 10:55:59 -04:00
# Some linter flags were set - only run those set to true
2020-07-01 17:40:40 -04:00
if [[ -z $VALIDATE_BASH ]]; then
2020-06-29 10:55:59 -04:00
# BASH flag was not set - default to false
VALIDATE_BASH="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_BASH="true"
fi
####################################
# Validate if we should check PERL #
####################################
2020-07-01 17:40:40 -04:00
if [[ $ANY_SET == "true" ]]; then
2020-06-29 10:55:59 -04:00
# Some linter flags were set - only run those set to true
2020-07-01 17:40:40 -04:00
if [[ -z $VALIDATE_PERL ]]; then
2020-06-29 10:55:59 -04:00
# PERL flag was not set - default to false
VALIDATE_PERL="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_PERL="true"
fi
2020-07-05 22:21:13 -04:00
####################################
# Validate if we should check RAKU #
####################################
if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true
if [[ -z $VALIDATE_RAKU ]]; then
# RAKU flag was not set - default to false
VALIDATE_RAKU="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_RAKU="true"
fi
2020-06-29 10:55:59 -04:00
####################################
# Validate if we should check PHP #
####################################
2020-07-01 17:40:40 -04:00
if [[ $ANY_SET == "true" ]]; then
2020-06-29 10:55:59 -04:00
# Some linter flags were set - only run those set to true
2020-07-01 17:40:40 -04:00
if [[ -z $VALIDATE_PHP ]]; then
2020-06-29 10:55:59 -04:00
# PHP flag was not set - default to false
VALIDATE_PHP="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_PHP="true"
fi
######################################
# Validate if we should check PYTHON #
######################################
2020-07-01 17:40:40 -04:00
if [[ $ANY_SET == "true" ]]; then
2020-06-29 10:55:59 -04:00
# Some linter flags were set - only run those set to true
2020-07-01 17:40:40 -04:00
if [[ -z $VALIDATE_PYTHON ]]; then
2020-06-29 10:55:59 -04:00
# PYTHON flag was not set - default to false
VALIDATE_PYTHON="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_PYTHON="true"
fi
####################################
# Validate if we should check RUBY #
####################################
2020-07-01 17:40:40 -04:00
if [[ $ANY_SET == "true" ]]; then
2020-06-29 10:55:59 -04:00
# Some linter flags were set - only run those set to true
2020-07-01 17:40:40 -04:00
if [[ -z $VALIDATE_RUBY ]]; then
2020-06-29 10:55:59 -04:00
# RUBY flag was not set - default to false
VALIDATE_RUBY="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_RUBY="true"
fi
2020-07-21 14:50:04 -04:00
##########################################
# Validate if we should check AWS States #
##########################################
if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true
if [[ -z $VALIDATE_STATES ]]; then
# STATES flag was not set - default to false
VALIDATE_STATES="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_STATES="true"
fi
2020-06-29 10:55:59 -04:00
######################################
# Validate if we should check COFFEE #
######################################
2020-07-01 17:40:40 -04:00
if [[ $ANY_SET == "true" ]]; then
2020-06-29 10:55:59 -04:00
# Some linter flags were set - only run those set to true
2020-07-01 17:40:40 -04:00
if [[ -z $VALIDATE_COFFEE ]]; then
2020-06-29 10:55:59 -04:00
# COFFEE flag was not set - default to false
VALIDATE_COFFEE="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_COFFEE="true"
fi
#######################################
# Validate if we should check ANSIBLE #
#######################################
2020-07-01 17:40:40 -04:00
if [[ $ANY_SET == "true" ]]; then
2020-06-29 10:55:59 -04:00
# Some linter flags were set - only run those set to true
2020-07-01 17:40:40 -04:00
if [[ -z $VALIDATE_ANSIBLE ]]; then
2020-06-29 10:55:59 -04:00
# ANSIBLE flag was not set - default to false
VALIDATE_ANSIBLE="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_ANSIBLE="true"
fi
#############################################
# Validate if we should check JAVASCRIPT_ES #
#############################################
2020-07-01 17:40:40 -04:00
if [[ $ANY_SET == "true" ]]; then
2020-06-29 10:55:59 -04:00
# Some linter flags were set - only run those set to true
2020-07-01 17:40:40 -04:00
if [[ -z $VALIDATE_JAVASCRIPT_ES ]]; then
2020-06-29 10:55:59 -04:00
# JAVASCRIPT_ES flag was not set - default to false
VALIDATE_JAVASCRIPT_ES="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_JAVASCRIPT_ES="true"
fi
###################################################
# Validate if we should check JAVASCRIPT_STANDARD #
###################################################
2020-07-01 17:40:40 -04:00
if [[ $ANY_SET == "true" ]]; then
2020-06-29 10:55:59 -04:00
# Some linter flags were set - only run those set to true
2020-07-01 17:40:40 -04:00
if [[ -z $VALIDATE_JAVASCRIPT_STANDARD ]]; then
2020-06-29 10:55:59 -04:00
# JAVASCRIPT_STANDARD flag was not set - default to false
VALIDATE_JAVASCRIPT_STANDARD="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_JAVASCRIPT_STANDARD="true"
fi
2020-07-07 09:15:20 -04:00
#############################################
# Validate if we should check JSX #
#############################################
if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true
if [[ -z $VALIDATE_JSX ]]; then
# JSX flag was not set - default to false
VALIDATE_JSX="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_JSX="true"
fi
#############################################
# Validate if we should check TSX #
#############################################
if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true
if [[ -z $VALIDATE_TSX ]]; then
# TSX flag was not set - default to false
VALIDATE_TSX="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_TSX="true"
fi
2020-06-29 10:55:59 -04:00
#############################################
# Validate if we should check TYPESCRIPT_ES #
#############################################
2020-07-01 17:40:40 -04:00
if [[ $ANY_SET == "true" ]]; then
2020-06-29 10:55:59 -04:00
# Some linter flags were set - only run those set to true
2020-07-01 17:40:40 -04:00
if [[ -z $VALIDATE_TYPESCRIPT_ES ]]; then
2020-06-29 10:55:59 -04:00
# TYPESCRIPT_ES flag was not set - default to false
VALIDATE_TYPESCRIPT_ES="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_TYPESCRIPT_ES="true"
fi
###################################################
# Validate if we should check TYPESCRIPT_STANDARD #
###################################################
2020-07-01 17:40:40 -04:00
if [[ $ANY_SET == "true" ]]; then
2020-06-29 10:55:59 -04:00
# Some linter flags were set - only run those set to true
2020-07-01 17:40:40 -04:00
if [[ -z $VALIDATE_TYPESCRIPT_STANDARD ]]; then
2020-06-29 10:55:59 -04:00
# TYPESCRIPT_STANDARD flag was not set - default to false
VALIDATE_TYPESCRIPT_STANDARD="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_TYPESCRIPT_STANDARD="true"
fi
######################################
# Validate if we should check DOCKER #
######################################
2020-07-01 17:40:40 -04:00
if [[ $ANY_SET == "true" ]]; then
2020-06-29 10:55:59 -04:00
# Some linter flags were set - only run those set to true
2020-07-01 17:40:40 -04:00
if [[ -z $VALIDATE_DOCKER ]]; then
2020-06-29 10:55:59 -04:00
# DOCKER flag was not set - default to false
VALIDATE_DOCKER="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_DOCKER="true"
fi
##################################
# Validate if we should check GO #
##################################
2020-07-01 17:40:40 -04:00
if [[ $ANY_SET == "true" ]]; then
2020-06-29 10:55:59 -04:00
# Some linter flags were set - only run those set to true
2020-07-01 17:40:40 -04:00
if [[ -z $VALIDATE_GO ]]; then
2020-06-29 10:55:59 -04:00
# GO flag was not set - default to false
VALIDATE_GO="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_GO="true"
fi
#########################################
# Validate if we should check TERRAFORM #
#########################################
2020-07-01 17:40:40 -04:00
if [[ $ANY_SET == "true" ]]; then
2020-06-29 10:55:59 -04:00
# Some linter flags were set - only run those set to true
2020-07-01 17:40:40 -04:00
if [[ -z $VALIDATE_TERRAFORM ]]; then
2020-06-29 10:55:59 -04:00
# TERRAFORM flag was not set - default to false
VALIDATE_TERRAFORM="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_TERRAFORM="true"
fi
#########################################
# Validate if we should check POWERSHELL #
#########################################
2020-07-01 17:40:40 -04:00
if [[ $ANY_SET == "true" ]]; then
2020-06-29 10:55:59 -04:00
# Some linter flags were set - only run those set to true
2020-07-01 17:40:40 -04:00
if [[ -z $VALIDATE_POWERSHELL ]]; then
2020-06-29 10:55:59 -04:00
# POWERSHELL flag was not set - default to false
VALIDATE_POWERSHELL="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_POWERSHELL="true"
fi
2020-07-02 17:31:16 -04:00
###################################
# Validate if we should check ARM #
###################################
if [[ "$ANY_SET" == "true" ]]; then
# Some linter flags were set - only run those set to true
if [[ -z "$VALIDATE_ARM" ]]; then
# ARM flag was not set - default to false
VALIDATE_ARM="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_ARM="true"
fi
2020-06-29 10:55:59 -04:00
###################################
# Validate if we should check CSS #
###################################
2020-07-01 17:40:40 -04:00
if [[ $ANY_SET == "true" ]]; then
2020-06-29 10:55:59 -04:00
# Some linter flags were set - only run those set to true
2020-07-01 17:40:40 -04:00
if [[ -z $VALIDATE_CSS ]]; then
2020-06-29 10:55:59 -04:00
# CSS flag was not set - default to false
VALIDATE_CSS="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_CSS="true"
fi
###################################
# Validate if we should check ENV #
###################################
2020-07-01 17:40:40 -04:00
if [[ $ANY_SET == "true" ]]; then
2020-06-29 10:55:59 -04:00
# Some linter flags were set - only run those set to true
2020-07-01 17:40:40 -04:00
if [[ -z $VALIDATE_ENV ]]; then
2020-06-29 10:55:59 -04:00
# ENV flag was not set - default to false
VALIDATE_ENV="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_ENV="true"
fi
######################################
# Validate if we should check KOTLIN #
######################################
2020-07-01 17:40:40 -04:00
if [[ $ANY_SET == "true" ]]; then
2020-06-29 10:55:59 -04:00
# Some linter flags were set - only run those set to true
2020-07-01 17:40:40 -04:00
if [[ -z $VALIDATE_KOTLIN ]]; then
2020-06-29 10:55:59 -04:00
# ENV flag was not set - default to false
VALIDATE_KOTLIN="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_KOTLIN="true"
fi
2020-07-06 04:17:20 -04:00
####################################
# Validate if we should check DART #
####################################
if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true
if [[ -z $VALIDATE_DART ]]; then
# ENV flag was not set - default to false
VALIDATE_DART="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_DART="true"
fi
2020-06-29 10:55:59 -04:00
#######################################
# Validate if we should check OPENAPI #
#######################################
2020-07-01 17:40:40 -04:00
if [[ $ANY_SET == "true" ]]; then
2020-06-29 10:55:59 -04:00
# Some linter flags were set - only run those set to true
2020-07-01 17:40:40 -04:00
if [[ -z $VALIDATE_OPENAPI ]]; then
2020-06-29 10:55:59 -04:00
# OPENAPI flag was not set - default to false
VALIDATE_OPENAPI="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_OPENAPI="true"
fi
#######################################
# Validate if we should check PROTOBUF #
#######################################
2020-07-01 17:40:40 -04:00
if [[ $ANY_SET == "true" ]]; then
2020-06-29 10:55:59 -04:00
# Some linter flags were set - only run those set to true
2020-07-01 17:40:40 -04:00
if [[ -z $VALIDATE_PROTOBUF ]]; then
2020-06-29 10:55:59 -04:00
# PROTOBUF flag was not set - default to false
VALIDATE_PROTOBUF="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_PROTOBUF="true"
fi
#######################################
# Validate if we should check Clojure #
#######################################
2020-07-01 17:40:40 -04:00
if [[ $ANY_SET == "true" ]]; then
2020-06-29 10:55:59 -04:00
# Some linter flags were set - only run those set to true
2020-07-01 17:40:40 -04:00
if [[ -z $VALIDATE_CLOJURE ]]; then
2020-06-29 10:55:59 -04:00
# Clojure flag was not set - default to false
VALIDATE_CLOJURE="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_CLOJURE="true"
fi
############################################
# Validate if we should check editorconfig #
############################################
if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true
if [[ -z $VALIDATE_EDITORCONFIG ]]; then
# EDITORCONFIG flag was not set - default to false
VALIDATE_EDITORCONFIG="false"
fi
else
2020-07-06 20:20:05 -04:00
# No linter flags were set
2020-07-07 10:18:04 -04:00
# special case checking for .editorconfig
if [ -f "$GITHUB_WORKSPACE/.editorconfig" ]; then
2020-07-06 20:20:05 -04:00
VALIDATE_EDITORCONFIG="true"
fi
fi
2020-07-07 09:15:20 -04:00
2020-07-04 18:14:27 -04:00
####################################
# Validate if we should check HTML #
####################################
if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true
if [[ -z $VALIDATE_HTML ]]; then
# HTML flag was not set - default to false
VALIDATE_HTML="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_HTML="true"
fi
2020-06-29 10:55:59 -04:00
#######################################
# Print which linters we are enabling #
#######################################
2020-07-01 17:40:40 -04:00
if [[ $VALIDATE_YAML == "true" ]]; then
2020-06-29 10:55:59 -04:00
PRINT_ARRAY+=("- Validating [YAML] files in code base...")
else
PRINT_ARRAY+=("- Excluding [YAML] files in code base...")
fi
2020-07-01 17:40:40 -04:00
if [[ $VALIDATE_JSON == "true" ]]; then
2020-06-29 10:55:59 -04:00
PRINT_ARRAY+=("- Validating [JSON] files in code base...")
else
PRINT_ARRAY+=("- Excluding [JSON] files in code base...")
fi
2020-07-01 17:40:40 -04:00
if [[ $VALIDATE_XML == "true" ]]; then
2020-06-29 10:55:59 -04:00
PRINT_ARRAY+=("- Validating [XML] files in code base...")
else
PRINT_ARRAY+=("- Excluding [XML] files in code base...")
fi
2020-07-21 09:52:30 -04:00
if [[ $VALIDATE_MARKDOWN == "true" ]]; then
2020-06-29 10:55:59 -04:00
PRINT_ARRAY+=("- Validating [MARKDOWN] files in code base...")
else
PRINT_ARRAY+=("- Excluding [MARKDOWN] files in code base...")
fi
2020-07-01 17:40:40 -04:00
if [[ $VALIDATE_BASH == "true" ]]; then
2020-06-29 10:55:59 -04:00
PRINT_ARRAY+=("- Validating [BASH] files in code base...")
else
PRINT_ARRAY+=("- Excluding [BASH] files in code base...")
fi
2020-07-01 17:40:40 -04:00
if [[ $VALIDATE_PERL == "true" ]]; then
2020-06-29 10:55:59 -04:00
PRINT_ARRAY+=("- Validating [PERL] files in code base...")
else
PRINT_ARRAY+=("- Excluding [PERL] files in code base...")
fi
2020-07-05 22:21:13 -04:00
if [[ $VALIDATE_RAKU == "true" ]]; then
PRINT_ARRAY+=("- Validating [RAKU] files in code base...")
else
PRINT_ARRAY+=("- Excluding [RAKU] files in code base...")
fi
2020-07-01 17:40:40 -04:00
if [[ $VALIDATE_PHP == "true" ]]; then
2020-06-29 10:55:59 -04:00
PRINT_ARRAY+=("- Validating [PHP] files in code base...")
else
PRINT_ARRAY+=("- Excluding [PHP] files in code base...")
fi
2020-07-01 17:40:40 -04:00
if [[ $VALIDATE_PYTHON == "true" ]]; then
2020-06-29 10:55:59 -04:00
PRINT_ARRAY+=("- Validating [PYTHON] files in code base...")
else
PRINT_ARRAY+=("- Excluding [PYTHON] files in code base...")
fi
2020-07-01 17:40:40 -04:00
if [[ $VALIDATE_RUBY == "true" ]]; then
2020-06-29 10:55:59 -04:00
PRINT_ARRAY+=("- Validating [RUBY] files in code base...")
else
PRINT_ARRAY+=("- Excluding [RUBY] files in code base...")
fi
2020-07-01 17:40:40 -04:00
if [[ $VALIDATE_COFFEE == "true" ]]; then
2020-06-29 10:55:59 -04:00
PRINT_ARRAY+=("- Validating [COFFEE] files in code base...")
else
PRINT_ARRAY+=("- Excluding [COFFEE] files in code base...")
fi
2020-07-01 17:40:40 -04:00
if [[ $VALIDATE_ANSIBLE == "true" ]]; then
2020-06-29 10:55:59 -04:00
PRINT_ARRAY+=("- Validating [ANSIBLE] files in code base...")
else
PRINT_ARRAY+=("- Excluding [ANSIBLE] files in code base...")
fi
2020-07-01 17:40:40 -04:00
if [[ $VALIDATE_JAVASCRIPT_ES == "true" ]]; then
2020-06-29 10:55:59 -04:00
PRINT_ARRAY+=("- Validating [JAVASCRIPT(eslint)] files in code base...")
else
PRINT_ARRAY+=("- Excluding [JAVASCRIPT(eslint)] files in code base...")
fi
2020-07-01 17:40:40 -04:00
if [[ $VALIDATE_JAVASCRIPT_STANDARD == "true" ]]; then
2020-06-29 10:55:59 -04:00
PRINT_ARRAY+=("- Validating [JAVASCRIPT(standard)] files in code base...")
else
PRINT_ARRAY+=("- Excluding [JAVASCRIPT(standard)] files in code base...")
fi
2020-07-01 17:40:40 -04:00
if [[ $VALIDATE_TYPESCRIPT_ES == "true" ]]; then
2020-06-29 10:55:59 -04:00
PRINT_ARRAY+=("- Validating [TYPESCRIPT(eslint)] files in code base...")
else
PRINT_ARRAY+=("- Excluding [TYPESCRIPT(eslint)] files in code base...")
fi
2020-07-01 17:40:40 -04:00
if [[ $VALIDATE_TYPESCRIPT_STANDARD == "true" ]]; then
2020-06-29 10:55:59 -04:00
PRINT_ARRAY+=("- Validating [TYPESCRIPT(standard)] files in code base...")
else
PRINT_ARRAY+=("- Excluding [TYPESCRIPT(standard)] files in code base...")
fi
2020-07-01 17:40:40 -04:00
if [[ $VALIDATE_DOCKER == "true" ]]; then
2020-06-29 10:55:59 -04:00
PRINT_ARRAY+=("- Validating [DOCKER] files in code base...")
else
PRINT_ARRAY+=("- Excluding [DOCKER] files in code base...")
fi
2020-07-01 17:40:40 -04:00
if [[ $VALIDATE_GO == "true" ]]; then
2020-06-29 10:55:59 -04:00
PRINT_ARRAY+=("- Validating [GOLANG] files in code base...")
else
PRINT_ARRAY+=("- Excluding [GOLANG] files in code base...")
fi
2020-07-01 17:40:40 -04:00
if [[ $VALIDATE_TERRAFORM == "true" ]]; then
2020-06-29 10:55:59 -04:00
PRINT_ARRAY+=("- Validating [TERRAFORM] files in code base...")
else
PRINT_ARRAY+=("- Excluding [TERRAFORM] files in code base...")
fi
2020-07-01 17:40:40 -04:00
if [[ $VALIDATE_POWERSHELL == "true" ]]; then
2020-06-29 10:55:59 -04:00
PRINT_ARRAY+=("- Validating [POWERSHELL] files in code base...")
else
PRINT_ARRAY+=("- Excluding [POWERSHELL] files in code base...")
fi
if [[ $VALIDATE_ARM == "true" ]]; then
2020-07-02 17:31:16 -04:00
PRINT_ARRAY+=("- Validating [ARM] files in code base...")
else
PRINT_ARRAY+=("- Excluding [ARM] files in code base...")
fi
2020-07-01 17:40:40 -04:00
if [[ $VALIDATE_CSS == "true" ]]; then
2020-06-29 10:55:59 -04:00
PRINT_ARRAY+=("- Validating [CSS] files in code base...")
else
PRINT_ARRAY+=("- Excluding [CSS] files in code base...")
fi
2020-07-01 17:40:40 -04:00
if [[ $VALIDATE_CLOJURE == "true" ]]; then
2020-06-29 10:55:59 -04:00
PRINT_ARRAY+=("- Validating [CLOJURE] files in code base...")
else
PRINT_ARRAY+=("- Excluding [CLOJURE] files in code base...")
fi
2020-07-01 17:40:40 -04:00
if [[ $VALIDATE_ENV == "true" ]]; then
2020-06-29 10:55:59 -04:00
PRINT_ARRAY+=("- Validating [ENV] files in code base...")
else
PRINT_ARRAY+=("- Excluding [ENV] files in code base...")
fi
2020-07-01 17:40:40 -04:00
if [[ $VALIDATE_KOTLIN == "true" ]]; then
2020-06-29 10:55:59 -04:00
PRINT_ARRAY+=("- Validating [KOTLIN] files in code base...")
else
PRINT_ARRAY+=("- Excluding [KOTLIN] files in code base...")
fi
2020-07-01 17:40:40 -04:00
if [[ $VALIDATE_OPENAPI == "true" ]]; then
2020-06-29 10:55:59 -04:00
PRINT_ARRAY+=("- Validating [OPENAPI] files in code base...")
else
PRINT_ARRAY+=("- Excluding [OPENAPI] files in code base...")
fi
2020-07-01 17:40:40 -04:00
if [[ $VALIDATE_PROTOBUF == "true" ]]; then
2020-06-29 10:55:59 -04:00
PRINT_ARRAY+=("- Validating [PROTOBUF] files in code base...")
else
PRINT_ARRAY+=("- Excluding [PROTOBUF] files in code base...")
fi
2020-07-06 04:17:20 -04:00
if [[ $VALIDATE_DART == "true" ]]; then
PRINT_ARRAY+=("- Validating [DART] files in code base...")
else
PRINT_ARRAY+=("- Excluding [DART] files in code base...")
2020-07-07 00:18:17 -04:00
fi
if [[ $VALIDATE_EDITORCONFIG == "true" ]]; then
PRINT_ARRAY+=("- Validating [EDITORCONFIG] files in code base...")
else
PRINT_ARRAY+=("- Excluding [EDITORCONFIG] files in code base...")
fi
2020-07-04 18:14:27 -04:00
if [[ $VALIDATE_HTML == "true" ]]; then
PRINT_ARRAY+=("- Validating [HTML] files in code base...")
else
PRINT_ARRAY+=("- Excluding [HTML] files in code base...")
2020-07-06 04:17:20 -04:00
fi
2020-07-21 14:50:04 -04:00
if [[ $VALIDATE_STATES == "true" ]]; then
PRINT_ARRAY+=("- Validating [AWS STATES] files in code base...")
else
PRINT_ARRAY+=("- Excluding [AWS STATES] files in code base...")
fi
2020-06-29 10:55:59 -04:00
##############################
# Validate Ansible Directory #
##############################
if [ -z "$ANSIBLE_DIRECTORY" ]; then
# No Value, need to default
ANSIBLE_DIRECTORY="$DEFAULT_ANSIBLE_DIRECTORY"
else
# Check if first char is '/'
if [[ ${ANSIBLE_DIRECTORY:0:1} == "/" ]]; then
# Remove first char
ANSIBLE_DIRECTORY="${ANSIBLE_DIRECTORY:1}"
fi
# Need to give it full path
TEMP_ANSIBLE_DIRECTORY="$GITHUB_WORKSPACE/$ANSIBLE_DIRECTORY"
# Set the value
ANSIBLE_DIRECTORY="$TEMP_ANSIBLE_DIRECTORY"
fi
###############################
# Get the disable errors flag #
###############################
if [ -z "$DISABLE_ERRORS" ]; then
##################################
# No flag passed, set to default #
##################################
DISABLE_ERRORS="$DEFAULT_DISABLE_ERRORS"
fi
###############################
# Convert string to lowercase #
###############################
2020-07-21 12:09:05 -04:00
DISABLE_ERRORS="${DISABLE_ERRORS,,}"
2020-06-29 10:55:59 -04:00
############################
# Set to false if not true #
############################
if [ "$DISABLE_ERRORS" != "true" ]; then
DISABLE_ERRORS="false"
fi
############################
# Get the run verbose flag #
############################
if [ -z "$ACTIONS_RUNNER_DEBUG" ]; then
##################################
# No flag passed, set to default #
##################################
ACTIONS_RUNNER_DEBUG="$DEFAULT_ACTIONS_RUNNER_DEBUG"
fi
###############################
# Convert string to lowercase #
###############################
2020-07-21 12:09:05 -04:00
ACTIONS_RUNNER_DEBUG="${ACTIONS_RUNNER_DEBUG,,}"
2020-06-29 10:55:59 -04:00
############################
# Set to true if not false #
############################
if [ "$ACTIONS_RUNNER_DEBUG" != "false" ]; then
ACTIONS_RUNNER_DEBUG="true"
fi
###################
# Debug on runner #
###################
2020-07-01 17:40:40 -04:00
if [[ $ACTIONS_RUNNER_DEBUG == "true" ]]; then
2020-06-29 10:55:59 -04:00
###########################
# Print the validate info #
###########################
2020-07-01 17:40:40 -04:00
for LINE in "${PRINT_ARRAY[@]}"; do
2020-06-29 10:55:59 -04:00
echo "$LINE"
done
echo "--- DEBUG INFO ---"
echo "---------------------------------------------"
RUNNER=$(whoami)
echo "Runner:[$RUNNER]"
echo "ENV:"
printenv
echo "---------------------------------------------"
fi
}