From b616dafd41652195b5cf0f13b67117b049fe6c32 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Mon, 27 Apr 2020 12:21:38 -0500 Subject: [PATCH] Cleanup of linter rules prints: --- README.md | 4 +-- {.github => docs}/run-linter-locally.md | 4 +++ lib/linter.sh | 45 +++++++++++++++---------- 3 files changed, 33 insertions(+), 20 deletions(-) rename {.github => docs}/run-linter-locally.md (97%) diff --git a/README.md b/README.md index 3c50cce7..edee40f7 100644 --- a/README.md +++ b/README.md @@ -145,7 +145,7 @@ The super-linter allows you to pass the following `ENV` variables to be able to - **VALIDATE_TERRAFORM** - Default: `true` - Flag to enable or disable the linting process of the language -- **VERBOSE_OUTPUT** +- **ACTIONS_RUNNER_DEBUG** - Default: `false` - Flag to enable additional information about the linter, versions, and additional output @@ -161,7 +161,7 @@ If you need to disable certain *rules* and *functionality*, you can view [Disabl The **Docker** container that is built from this repository is located at `https://cloud.docker.com/u/admiralawkbar/repository/docker/admiralawkbar/super-linter` ## Running Super-Linter locally (troubleshooting/debugging/enhancements) -If you find that you need to run super-linter locally, you can follow the documentation at [Running super-linter locally](https://github.com/github/super-linter/blob/master/.github/run-linter-locally.md) +If you find that you need to run super-linter locally, you can follow the documentation at [Running super-linter locally](https://github.com/github/super-linter/blob/master/docs/run-linter-locally.md) ### CI/CT/CD The **Super-Linter** has *CI/CT/CD* configured utilizing **GitHub** Actions. diff --git a/.github/run-linter-locally.md b/docs/run-linter-locally.md similarity index 97% rename from .github/run-linter-locally.md rename to docs/run-linter-locally.md index 4ebd60b2..4bfdee18 100644 --- a/.github/run-linter-locally.md +++ b/docs/run-linter-locally.md @@ -94,6 +94,10 @@ Once the container has been downloaded to your local environment, you can then b - `-e ANSIBLE_DIRECTORY=` - Default: `/ansible` - Flag to set the root directory for Ansible file location(s) + - **ACTIONS_RUNNER_DEBUG** + - `-e ACTIONS_RUNNER_DEBUG=` + - Default: `false` + - Flag to enable or disable additional debug info ## Troubleshooting diff --git a/lib/linter.sh b/lib/linter.sh index e044b22b..635938c9 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -85,8 +85,8 @@ TEST_CASE_RUN="${TEST_CASE_RUN}" # Boolean to validate only ############## # Debug Vars # ############## -RUN_LOCAL="${RUN_LOCAL}" # Boolean to see if we are running locally -VERBOSE_OUTPUT="${VERBOSE_OUTPUT}" # Boolean to see even more info (debug) +RUN_LOCAL="${RUN_LOCAL}" # Boolean to see if we are running locally +ACTIONS_RUNNER_DEBUG="${ACTIONS_RUNNER_DEBUG}" # Boolean to see even more info (debug) ################ # Default Vars # @@ -97,7 +97,7 @@ DEFAULT_WORKSPACE='/tmp/lint' # Default workspace if run DEFAULT_ANSIBLE_DIRECTORY="$GITHUB_WORKSPACE/ansible" # Default Ansible Directory DEFAULT_RUN_LOCAL='false' # Default value for debugging locally DEFAULT_TEST_CASE_RUN='false' # Flag to tell code to run only test cases -DEFAULT_VERBOSE_OUTPUT='false' # Default value for debugging output +DEFAULT_ACTIONS_RUNNER_DEBUG='false' # Default value for debugging output RAW_FILE_ARRAY=() # Array of all files that were changed READ_ONLY_CHANGE_FLAG=0 # Flag set to 1 if files changed are not txt or md TEST_CASE_FOLDER='.automation/test' # Folder for test cases we should always ignore @@ -219,16 +219,11 @@ GetLinterRules() FILE_NAME="$1" # Name fo the linter file FILE_LOCATION="$2" # Location of the linter file - ################ - # print header # - ################ - echo "----------------------------------------------" - echo "Gathering users linter:[$FILE_NAME] rules from repository, or defaulting..." - ##################################### # Validate we have the linter rules # ##################################### if [ -f "$GITHUB_WORKSPACE/$LINTER_PATH/$FILE_NAME" ]; then + echo "----------------------------------------------" echo "User provided file:[$FILE_NAME], setting rules file..." #################################### @@ -253,7 +248,9 @@ GetLinterRules() ######################################################## # No user default provided, using the template default # ######################################################## - echo " -> Codebase does NOT have file:[$LINTER_PATH/$FILE_NAME], using Default rules at:[$FILE_LOCATION]" + if [[ "$ACTIONS_RUNNER_DEBUG" != "false" ]]; then + echo " -> Codebase does NOT have file:[$LINTER_PATH/$FILE_NAME], using Default rules at:[$FILE_LOCATION]" + fi fi } ################################################################################ @@ -378,7 +375,7 @@ LintAnsibleFiles() exit 1 else # Success - if [[ "$VERBOSE_OUTPUT" != "false" ]]; then + if [[ "$ACTIONS_RUNNER_DEBUG" != "false" ]]; then # Success echo "Successfully found binary in system" echo "Location:[$VALIDATE_INSTALL_CMD]" @@ -624,13 +621,17 @@ GetGitHubVars() echo "Successfully found:[GITHUB_REPO], value:[$GITHUB_REPO]" fi fi - +} +################################################################################ +#### Function GetValidationInfo ################################################ +GetValidationInfo() +{ ############################################ # Print headers for user provided env vars # ############################################ echo "" echo "--------------------------------------------" - echo "Gathering User provided information..." + echo "Gathering user validation information..." ########################################### # Skip validation if were running locally # @@ -946,22 +947,22 @@ GetGitHubVars() ############################ # Get the run verbose flag # ############################ - if [ -z "$VERBOSE_OUTPUT" ]; then + if [ -z "$ACTIONS_RUNNER_DEBUG" ]; then ################################## # No flag passed, set to default # ################################## - VERBOSE_OUTPUT="$DEFAULT_VERBOSE_OUTPUT" + ACTIONS_RUNNER_DEBUG="$DEFAULT_ACTIONS_RUNNER_DEBUG" fi ############################### # Convert string to lowercase # ############################### - VERBOSE_OUTPUT=$(echo "$VERBOSE_OUTPUT" | awk '{print tolower($0)}') + ACTIONS_RUNNER_DEBUG=$(echo "$ACTIONS_RUNNER_DEBUG" | awk '{print tolower($0)}') ################### # Debug on runner # ################### - if [[ "$VERBOSE_OUTPUT" != "false" ]]; then + if [[ "$ACTIONS_RUNNER_DEBUG" != "false" ]]; then echo "--- DEBUG ---" echo "---------------------------------------------" RUNNER=$(whoami) @@ -1749,6 +1750,14 @@ Header # needed to connect back and update checks GetGitHubVars +########################################## +# Get the langugages we need to validate # +########################################## +if [[ "$ACTIONS_RUNNER_DEBUG" != "false" ]]; then + # Get the flags for langugaes to validate + GetValidationInfo +fi + ######################## # Get the linter rules # ######################## @@ -1778,7 +1787,7 @@ GetLinterRules "$TERRAFORM_FILE_NAME" "$TERRAFORM_LINTER_RULES" ################################# # Check if were in verbose mode # ################################# -if [[ "$VERBOSE_OUTPUT" != "false" ]]; then +if [[ "$ACTIONS_RUNNER_DEBUG" != "false" ]]; then ################################## # Get and print all version info # ##################################