Merge remote-tracking branch 'upstream/master' into color

This commit is contained in:
Eric Nemchik 2020-07-01 16:04:25 -05:00
commit f7f8e6f37c
5 changed files with 46 additions and 51 deletions

View file

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

View file

@ -125,7 +125,8 @@ jobs:
uses: docker://github/super-linter:v3 uses: docker://github/super-linter:v3
env: env:
VALIDATE_ALL_CODEBASE: false VALIDATE_ALL_CODEBASE: false
VALIDATE_ANSIBLE: false DEFAULT_BRANCH: master
... ...
``` ```

View file

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

View file

@ -26,7 +26,7 @@ function BuildFileList()
################################################################################# #################################################################################
# Switch codebase back to the default branch to get a list of all files changed # # Switch codebase back to the default branch to get a list of all files changed #
################################################################################# #################################################################################
SWITCH_CMD=$(cd "$GITHUB_WORKSPACE" || exit; git pull --quiet; git checkout "$DEFAULT_BRANCH" 2>&1) SWITCH_CMD=$(git -C "$GITHUB_WORKSPACE" pull --quiet; git -C "$GITHUB_WORKSPACE" checkout "$DEFAULT_BRANCH" 2>&1)
####################### #######################
# Load the error code # # Load the error code #
@ -100,11 +100,11 @@ function BuildFileList()
##################### #####################
# Get the CFN files # # Get the CFN files #
##################### #####################
if [ "$FILE_TYPE" == "json" ] || [ "$FILE_TYPE" == "yml" ] || [ "$FILE_TYPE" == "yaml" ] && DetectCloudFormationFile "$FILE"; then if [ "$FILE_TYPE" == "yml" ] || [ "$FILE_TYPE" == "yaml" ]; then
################################ ################################
# Append the file to the array # # Append the file to the array #
################################ ################################
FILE_ARRAY_CFN+=("$FILE") FILE_ARRAY_YML+=("$FILE")
########################################################## ##########################################################
# Set the READ_ONLY_CHANGE_FLAG since this could be exec # # Set the READ_ONLY_CHANGE_FLAG since this could be exec #
########################################################## ##########################################################
@ -118,11 +118,12 @@ function BuildFileList()
# Append the file to the array # # Append the file to the array #
################################ ################################
FILE_ARRAY_CFN+=("$FILE") FILE_ARRAY_CFN+=("$FILE")
fi
########################################################## ##########################################################
# Set the READ_ONLY_CHANGE_FLAG since this could be exec # # Set the READ_ONLY_CHANGE_FLAG since this could be exec #
########################################################## ##########################################################
READ_ONLY_CHANGE_FLAG=1 READ_ONLY_CHANGE_FLAG=1
fi
###################### ######################
# Get the JSON files # # Get the JSON files #
###################### ######################
@ -416,7 +417,7 @@ function BuildFileList()
######################################### #########################################
# Need to switch back to branch of code # # Need to switch back to branch of code #
######################################### #########################################
SWITCH2_CMD=$(cd "$GITHUB_WORKSPACE" || exit; git checkout --progress --force "$GITHUB_SHA" 2>&1) SWITCH2_CMD=$(git -C "$GITHUB_WORKSPACE" checkout --progress --force "$GITHUB_SHA" 2>&1)
####################### #######################
# Load the error code # # Load the error code #

View file

@ -40,8 +40,8 @@ CFN_LINTER_RULES="$DEFAULT_RULES_LOCATION/$CFN_FILE_NAME" # Path to th
RUBY_FILE_NAME="${RUBY_CONFIG_FILE:-.ruby-lint.yml}" # Name of the file RUBY_FILE_NAME="${RUBY_CONFIG_FILE:-.ruby-lint.yml}" # Name of the file
RUBY_LINTER_RULES="$DEFAULT_RULES_LOCATION/$RUBY_FILE_NAME" # Path to the ruby lint rules RUBY_LINTER_RULES="$DEFAULT_RULES_LOCATION/$RUBY_FILE_NAME" # Path to the ruby lint rules
# Coffee Vars # Coffee Vars
COFFEE_FILE_NAME='.coffee-lint.json' # Name of the file COFFEESCRIPT_FILE_NAME='.coffee-lint.json' # Name of the file
COFFEESCRIPT_LINTER_RULES="$DEFAULT_RULES_LOCATION/$COFFEE_FILE_NAME" # Path to the coffeescript lint rules COFFEESCRIPT_LINTER_RULES="$DEFAULT_RULES_LOCATION/$COFFEESCRIPT_FILE_NAME" # Path to the coffeescript lint rules
# Javascript Vars # Javascript Vars
JAVASCRIPT_FILE_NAME="${JAVASCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file JAVASCRIPT_FILE_NAME="${JAVASCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file
JAVASCRIPT_LINTER_RULES="$DEFAULT_RULES_LOCATION/$JAVASCRIPT_FILE_NAME" # Path to the Javascript lint rules JAVASCRIPT_LINTER_RULES="$DEFAULT_RULES_LOCATION/$JAVASCRIPT_FILE_NAME" # Path to the Javascript lint rules
@ -299,40 +299,31 @@ GetLinterRules()
################ ################
# Pull in vars # # Pull in vars #
################ ################
FILE_NAME="$1" # Name fo the linter file LANGUAGE_NAME="$1" # Name of the language were looking for
FILE_LOCATION="$2" # Location of the linter file
#######################################################
# Need to create the variables for the real variables #
#######################################################
LANGUAGE_FILE_NAME="${LANGUAGE_NAME}_FILE_NAME"
LANGUAGE_LINTER_RULES="${LANGUAGE_NAME}_LINTER_RULES"
##################################### #####################################
# Validate we have the linter rules # # Validate we have the linter rules #
##################################### #####################################
if [ -f "$GITHUB_WORKSPACE/$LINTER_RULES_PATH/$FILE_NAME" ]; then if [ -f "$GITHUB_WORKSPACE/$LINTER_RULES_PATH/${!LANGUAGE_FILE_NAME}" ]; then
echo "----------------------------------------------" echo "----------------------------------------------"
echo "User provided file:[$FILE_NAME], setting rules file..." echo "User provided file:[${!LANGUAGE_FILE_NAME}], setting rules file..."
#################################### ########################################
# Copy users into default location # # Update the path to the file location #
#################################### ########################################
CP_CMD=$(cp "$GITHUB_WORKSPACE/$LINTER_RULES_PATH/$FILE_NAME" "$FILE_LOCATION" 2>&1) declare "${LANGUAGE_LINTER_RULES}=$GITHUB_WORKSPACE/$LINTER_RULES_PATH/${!LANGUAGE_FILE_NAME}"
###################
# Load Error code #
###################
ERROR_CODE=$?
##############################
# Check the shell for errors #
##############################
if [ $ERROR_CODE -ne 0 ]; then
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to set file:[$FILE_NAME] as default!${NC}"
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$CP_CMD]${NC}"
exit 1
fi
else else
######################################################## ########################################################
# No user default provided, using the template default # # No user default provided, using the template default #
######################################################## ########################################################
if [[ "$ACTIONS_RUNNER_DEBUG" == "true" ]]; then if [[ "$ACTIONS_RUNNER_DEBUG" == "true" ]]; then
echo " -> Codebase does NOT have file:[$LINTER_RULES_PATH/$FILE_NAME], using Default rules at:[$FILE_LOCATION]" echo " -> Codebase does NOT have file:[$LINTER_RULES_PATH/${!LANGUAGE_FILE_NAME}], using Default rules at:[${!LANGUAGE_LINTER_RULES}]"
fi fi
fi fi
} }
@ -428,7 +419,7 @@ DetectOpenAPIFile()
############################### ###############################
# Check the file for keywords # # Check the file for keywords #
############################### ###############################
grep -E '"openapi":|"swagger":|^openapi:|^swagger:' "$GITHUB_WORKSPACE/$FILE" > /dev/null grep -E '"openapi":|"swagger":|^openapi:|^swagger:' "$FILE" > /dev/null
####################### #######################
# Load the error code # # Load the error code #
@ -790,33 +781,33 @@ GetValidationInfo
# Get the linter rules # # Get the linter rules #
######################## ########################
# Get YML rules # Get YML rules
GetLinterRules "$YAML_FILE_NAME" "$YAML_LINTER_RULES" GetLinterRules "YAML"
# Get Markdown rules # Get Markdown rules
GetLinterRules "$MD_FILE_NAME" "$MD_LINTER_RULES" GetLinterRules "MD"
# Get Python rules # Get Python rules
GetLinterRules "$PYTHON_FILE_NAME" "$PYTHON_LINTER_RULES" GetLinterRules "PYTHON"
# Get Ruby rules # Get Ruby rules
GetLinterRules "$RUBY_FILE_NAME" "$RUBY_LINTER_RULES" GetLinterRules "RUBY"
# Get Coffeescript rules # Get Coffeescript rules
GetLinterRules "$COFFEE_FILE_NAME" "$COFFEESCRIPT_LINTER_RULES" GetLinterRules "COFFEESCRIPT"
# Get Ansible rules # Get Ansible rules
GetLinterRules "$ANSIBLE_FILE_NAME" "$ANSIBLE_LINTER_RULES" GetLinterRules "ANSIBLE"
# Get JavaScript rules # Get JavaScript rules
GetLinterRules "$JAVASCRIPT_FILE_NAME" "$JAVASCRIPT_LINTER_RULES" GetLinterRules "JAVASCRIPT"
# Get TypeScript rules # Get TypeScript rules
GetLinterRules "$TYPESCRIPT_FILE_NAME" "$TYPESCRIPT_LINTER_RULES" GetLinterRules "TYPESCRIPT"
# Get Golang rules # Get Golang rules
GetLinterRules "$GO_FILE_NAME" "$GO_LINTER_RULES" GetLinterRules "GO"
# Get Docker rules # Get Docker rules
GetLinterRules "$DOCKER_FILE_NAME" "$DOCKER_LINTER_RULES" GetLinterRules "DOCKER"
# Get Terraform rules # Get Terraform rules
GetLinterRules "$TERRAFORM_FILE_NAME" "$TERRAFORM_LINTER_RULES" GetLinterRules "TERRAFORM"
# Get PowerShell rules # Get PowerShell rules
GetLinterRules "$POWERSHELL_FILE_NAME" "$POWERSHELL_LINTER_RULES" GetLinterRules "POWERSHELL"
# Get CSS rules # Get CSS rules
GetLinterRules "$CSS_FILE_NAME" "$CSS_LINTER_RULES" GetLinterRules "CSS"
# Get CFN rules # Get CFN rules
GetLinterRules "$CFN_FILE_NAME" "$CFN_LINTER_RULES" GetLinterRules "CFN"
################################# #################################
# Check if were in verbose mode # # Check if were in verbose mode #
@ -1002,7 +993,7 @@ if [ "$VALIDATE_ANSIBLE" == "true" ]; then
# Due to the nature of how we want to validate Ansible, we cannot use the # Due to the nature of how we want to validate Ansible, we cannot use the
# standard loop, since it looks for an ansible folder, excludes certain # standard loop, since it looks for an ansible folder, excludes certain
# files, and looks for additional changes, it should be an outlier # files, and looks for additional changes, it should be an outlier
LintAnsibleFiles LintAnsibleFiles "$ANSIBLE_LINTER_RULES" # Passing rules but not needed, dont want to exclude unused var
fi fi
###################### ######################