Merge pull request #343 from github/MinorFixGrabBag

Were going to fix it all
This commit is contained in:
Zack Koppert 2020-07-01 13:29:18 -07:00 committed by GitHub
commit 97e64a47e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 47 additions and 52 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")
##########################################################
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
##########################################################
READ_ONLY_CHANGE_FLAG=1
fi fi
##########################################################
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
##########################################################
READ_ONLY_CHANGE_FLAG=1
###################### ######################
# 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

@ -38,8 +38,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
@ -297,40 +297,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 "ERROR! Failed to set file:[$FILE_NAME] as default!"
echo "ERROR:[$CP_CMD]"
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
} }
@ -426,7 +417,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 #
@ -788,33 +779,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 #
@ -1000,7 +991,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
###################### ######################
@ -1133,7 +1124,7 @@ if [ "$VALIDATE_POWERSHELL" == "true" ]; then
# For POWERSHELL, ensure PSScriptAnalyzer module is available # # For POWERSHELL, ensure PSScriptAnalyzer module is available #
############################################################### ###############################################################
ValidatePowershellModules ValidatePowershellModules
############################# #############################
# Lint the powershell files # # Lint the powershell files #
############################# #############################