Adding logic

This commit is contained in:
Lucas Gravley 2020-01-09 10:29:18 -06:00
parent 601eb39812
commit e2d4484c1f
2 changed files with 125 additions and 75 deletions

View file

@ -90,7 +90,8 @@ ENV GITHUB_SHA=${GITHUB_SHA} \
VALIDATE_COFFEE=${VALIDATE_COFFEE} \
VALIDATE_ANSIBLE=${VALIDATE_ANSIBLE} \
VALIDATE_JAVASCRIPT=${VALIDATE_JAVASCRIPT} \
ANSIBLE_DIRECTORY=${ANSIBLE_DIRECTORY}
ANSIBLE_DIRECTORY=${ANSIBLE_DIRECTORY} \
RUN_LOCAL=${RUN_LOCAL}
#############################
# Copy scripts to container #

View file

@ -56,13 +56,16 @@ VALIDATE_RUBY="${VALIDATE_RUBY}" # Boolean to validate language
VALIDATE_COFFEE="${VALIDATE_COFFEE}" # Boolean to validate language
VALIDATE_ANSIBLE="${VALIDATE_ANSIBLE}" # Boolean to validate language
VALIDATE_JAVASCRIPT="${VALIDATE_JAVASCRIPT}" # Boolean to validate language
RUN_LOCAL="${RUN_LOCAL}" # Boolean to see if we are running locally
################
# Default Vars #
################
DEFAULT_VALIDATE_ALL_CODEBASE='true' # Default value for validate all files
DEFAULT_VALIDATE_LANGUAGE='true' # Default to validate language
DEFAULT_WORKSPACE='/tmp/lint' # Default workspace if running locally
DEFAULT_ANSIBLE_DIRECTORY="$GITHUB_WORKSPACE/ansible" # Default Ansible Directory
DEFAULT_RUN_LOCAL='false' # default value for debugging
RAW_FILE_ARRAY=() # Array of all files that were changed
##########################
@ -1900,6 +1903,46 @@ GetGitHubVars()
echo "--------------------------------------------"
echo "Gathering GitHub information..."
##########################
# Get the run local flag #
##########################
if [ -z "$RUN_LOCAL" ]; then
##################################
# No flag passed, set to default #
##################################
RUN_LOCAL="$DEFAULT_RUN_LOCAL"
fi
###############################
# Convert string to lowercase #
###############################
RUN_LOCAL=$(echo "$RUN_LOCAL" | awk '{print tolower($0)}')
#################################
# Check if were running locally #
#################################
if [[ "$RUN_LOCAL" != "false" ]]; then
##########################################
# We are running locally for a debug run #
##########################################
echo "NOTE: ENV VAR [RUN_LOCAL] has been set to:[true]"
echo "bypassing GitHub Actions variables..."
echo "Linting all files in mapped directory:[$DEFAULT_WORKSPACE]"
# No need to touch or set the GITHUB_SHA
# No need to touch or set the GITHUB_EVENT_PATH
# No need to touch or set the GITHUB_ORG
# No need to touch or set the GITHUB_REPO
############################
# Set the GITHUB_WORKSPACE #
############################
GITHUB_WORKSPACE="$DEFAULT_WORKSPACE"
#################################
# Set the VALIDATE_ALL_CODEBASE #
#################################
VALIDATE_ALL_CODEBASE="$DEFAULT_VALIDATE_ALL_CODEBASE"
else
############################
# Validate we have a value #
############################
@ -1970,6 +2013,7 @@ GetGitHubVars()
else
echo "Successfully found:[GITHUB_REPO], value:[$GITHUB_REPO]"
fi
fi
############################################
# Print headers for user provided env vars #
@ -1978,6 +2022,10 @@ GetGitHubVars()
echo "--------------------------------------------"
echo "Gathering User provided information..."
###########################################
# Skip validation if were running locally #
###########################################
if [[ "$RUN_LOCAL" != "true" ]]; then
###############################
# Convert string to lowercase #
###############################
@ -1993,6 +2041,7 @@ GetGitHubVars()
# Its false
echo "- Only validating [new], or [edited] files in code base..."
fi
fi
###############################
# Convert string to lowercase #