From c3bb133a88ca6f9d721d7b11931b5c42e185f2d5 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 1 Jul 2020 08:29:22 -0500 Subject: [PATCH 1/9] better example of usage --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d3c7b8a6..40c4c2b3 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,8 @@ jobs: uses: docker://github/super-linter:v3 env: VALIDATE_ALL_CODEBASE: false - VALIDATE_ANSIBLE: false + DEFAULT_BRANCH: master + ... ``` From 6812f75bd935cbfc3857ac551622f24ec935e556 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 1 Jul 2020 08:35:15 -0500 Subject: [PATCH 2/9] fix for forked duplicates --- .github/workflows/deploy-DEV.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/deploy-DEV.yml b/.github/workflows/deploy-DEV.yml index 0f55b010..2372e17b 100644 --- a/.github/workflows/deploy-DEV.yml +++ b/.github/workflows/deploy-DEV.yml @@ -31,6 +31,8 @@ jobs: name: Deploy Docker Image - DEV # Set the agent to run on 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 # ################## From 2c11d4997398276d4aef02bbc204f67567802a91 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 1 Jul 2020 08:49:39 -0500 Subject: [PATCH 3/9] Setting tflint modules to false --- TEMPLATES/.tflint.hcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TEMPLATES/.tflint.hcl b/TEMPLATES/.tflint.hcl index 5bc2209b..9a32d3aa 100644 --- a/TEMPLATES/.tflint.hcl +++ b/TEMPLATES/.tflint.hcl @@ -1,6 +1,6 @@ // https://github.com/terraform-linters/tflint/blob/master/docs/guides/config.md config { - module = true + module = false deep_check = false force = false From 3a4fd9b9951fc98ddc4183bb7860186345144dc7 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 1 Jul 2020 09:45:55 -0500 Subject: [PATCH 4/9] super crazy fix for paths --- lib/linter.sh | 69 ++++++++++++++++++++++----------------------------- 1 file changed, 30 insertions(+), 39 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 9b6d9dd6..e2c79af2 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -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_LINTER_RULES="$DEFAULT_RULES_LOCATION/$RUBY_FILE_NAME" # Path to the ruby lint rules # Coffee Vars -COFFEE_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_FILE_NAME='.coffee-lint.json' # Name of the file +COFFEESCRIPT_LINTER_RULES="$DEFAULT_RULES_LOCATION/$COFFEESCRIPT_FILE_NAME" # Path to the coffeescript lint rules # Javascript Vars 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 @@ -297,34 +297,25 @@ GetLinterRules() ################ # Pull in vars # ################ - FILE_NAME="$1" # Name fo the linter file - FILE_LOCATION="$2" # Location of the linter file + LANGUAGE_NAME="$1" # Name of the language were looking for + + ####################################################### + # 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 # ##################################### - if [ -f "$GITHUB_WORKSPACE/$LINTER_RULES_PATH/$FILE_NAME" ]; then + if [ -f "$GITHUB_WORKSPACE/$LINTER_RULES_PATH/$LANGUAGE_FILE_NAME" ]; then 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 # - #################################### - CP_CMD=$(cp "$GITHUB_WORKSPACE/$LINTER_RULES_PATH/$FILE_NAME" "$FILE_LOCATION" 2>&1) - - ################### - # 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 + ######################################## + # Update the path to the file location # + ######################################## + ((LANGUAGE_LINTER_RULES))="$GITHUB_WORKSPACE/$LINTER_RULES_PATH/$LANGUAGE_FILE_NAME" else ######################################################## # No user default provided, using the template default # @@ -788,33 +779,33 @@ GetValidationInfo # Get the linter rules # ######################## # Get YML rules -GetLinterRules "$YAML_FILE_NAME" "$YAML_LINTER_RULES" +GetLinterRules "YAML" # Get Markdown rules -GetLinterRules "$MD_FILE_NAME" "$MD_LINTER_RULES" +GetLinterRules "MD" # Get Python rules -GetLinterRules "$PYTHON_FILE_NAME" "$PYTHON_LINTER_RULES" +GetLinterRules "PYTHON" # Get Ruby rules -GetLinterRules "$RUBY_FILE_NAME" "$RUBY_LINTER_RULES" +GetLinterRules "RUBY" # Get Coffeescript rules -GetLinterRules "$COFFEE_FILE_NAME" "$COFFEESCRIPT_LINTER_RULES" +GetLinterRules "COFFEESCRIPT" # Get Ansible rules -GetLinterRules "$ANSIBLE_FILE_NAME" "$ANSIBLE_LINTER_RULES" +GetLinterRules "ANSIBLE" # Get JavaScript rules -GetLinterRules "$JAVASCRIPT_FILE_NAME" "$JAVASCRIPT_LINTER_RULES" +GetLinterRules "JAVASCRIPT" # Get TypeScript rules -GetLinterRules "$TYPESCRIPT_FILE_NAME" "$TYPESCRIPT_LINTER_RULES" +GetLinterRules "TYPESCRIPT" # Get Golang rules -GetLinterRules "$GO_FILE_NAME" "$GO_LINTER_RULES" +GetLinterRules "GO" # Get Docker rules -GetLinterRules "$DOCKER_FILE_NAME" "$DOCKER_LINTER_RULES" +GetLinterRules "DOCKER" # Get Terraform rules -GetLinterRules "$TERRAFORM_FILE_NAME" "$TERRAFORM_LINTER_RULES" +GetLinterRules "TERRAFORM" # Get PowerShell rules -GetLinterRules "$POWERSHELL_FILE_NAME" "$POWERSHELL_LINTER_RULES" +GetLinterRules "POWERSHELL" # Get CSS rules -GetLinterRules "$CSS_FILE_NAME" "$CSS_LINTER_RULES" +GetLinterRules "CSS" # Get CFN rules -GetLinterRules "$CFN_FILE_NAME" "$CFN_LINTER_RULES" +GetLinterRules "CFN" ################################# # Check if were in verbose mode # @@ -1133,7 +1124,7 @@ if [ "$VALIDATE_POWERSHELL" == "true" ]; then # For POWERSHELL, ensure PSScriptAnalyzer module is available # ############################################################### ValidatePowershellModules - + ############################# # Lint the powershell files # ############################# From 6859aa5a8243af12c7602ee26dc301d66d7ead96 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 1 Jul 2020 11:38:26 -0500 Subject: [PATCH 5/9] the sword and the stone --- lib/linter.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index e2c79af2..e4f005c0 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -315,13 +315,13 @@ GetLinterRules() ######################################## # Update the path to the file location # ######################################## - ((LANGUAGE_LINTER_RULES))="$GITHUB_WORKSPACE/$LINTER_RULES_PATH/$LANGUAGE_FILE_NAME" + declare "$LANGUAGE_LINTER_RULES=$GITHUB_WORKSPACE/$LINTER_RULES_PATH/$LANGUAGE_FILE_NAME" else ######################################################## # No user default provided, using the template default # ######################################################## 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 } From 11608866b71000da4fdca278dbbda7067c23116e Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 1 Jul 2020 11:59:00 -0500 Subject: [PATCH 6/9] fixed more bad logic --- lib/buildFileList.sh | 13 +++++++------ lib/linter.sh | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index c10284c8..96127e73 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -100,11 +100,11 @@ function BuildFileList() ##################### # 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 # ################################ - FILE_ARRAY_CFN+=("$FILE") + FILE_ARRAY_YML+=("$FILE") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## @@ -118,11 +118,12 @@ function BuildFileList() # Append the file to the array # ################################ FILE_ARRAY_CFN+=("$FILE") + + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 fi - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 ###################### # Get the JSON files # ###################### diff --git a/lib/linter.sh b/lib/linter.sh index e4f005c0..fa657826 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -991,7 +991,7 @@ if [ "$VALIDATE_ANSIBLE" == "true" ]; then # 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 # 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 ###################### From 048cc499913abd0200122716a484bd6b11aeea12 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 1 Jul 2020 13:38:40 -0500 Subject: [PATCH 7/9] have i solved the riddle? --- lib/linter.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index fa657826..7a95e9c9 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -308,20 +308,20 @@ GetLinterRules() ##################################### # Validate we have the linter rules # ##################################### - if [ -f "$GITHUB_WORKSPACE/$LINTER_RULES_PATH/$LANGUAGE_FILE_NAME" ]; then + if [ -f "$GITHUB_WORKSPACE/$LINTER_RULES_PATH/${!LANGUAGE_FILE_NAME}" ]; then echo "----------------------------------------------" - echo "User provided file:[$LANGUAGE_FILE_NAME], setting rules file..." + echo "User provided file:[${!LANGUAGE_FILE_NAME}], setting rules file..." ######################################## # Update the path to the file location # ######################################## - declare "$LANGUAGE_LINTER_RULES=$GITHUB_WORKSPACE/$LINTER_RULES_PATH/$LANGUAGE_FILE_NAME" + declare "${LANGUAGE_LINTER_RULES}=$GITHUB_WORKSPACE/$LINTER_RULES_PATH/${!LANGUAGE_FILE_NAME}" else ######################################################## # No user default provided, using the template default # ######################################################## if [[ "$ACTIONS_RUNNER_DEBUG" == "true" ]]; then - echo " -> Codebase does NOT have file:[$LINTER_RULES_PATH/$LANGUAGE_FILE_NAME], using Default rules at:[$LANGUAGE_LINTER_RULES]" + echo " -> Codebase does NOT have file:[$LINTER_RULES_PATH/${!LANGUAGE_FILE_NAME}], using Default rules at:[${!LANGUAGE_LINTER_RULES}]" fi fi } From 7a5a7867649db5fe7b698a6bf9f625edc8e3e366 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Wed, 1 Jul 2020 14:43:48 -0500 Subject: [PATCH 8/9] Use -C with all git commands --- lib/buildFileList.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index 96127e73..60ca0f8f 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -26,7 +26,7 @@ function BuildFileList() ################################################################################# # 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 # @@ -417,7 +417,7 @@ function BuildFileList() ######################################### # 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 # From cee9c71797cf6f1889fa64e294d88911f805450e Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 1 Jul 2020 14:48:40 -0500 Subject: [PATCH 9/9] fixed bug in openAPI path --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index 7a95e9c9..dddc2a55 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -417,7 +417,7 @@ DetectOpenAPIFile() ############################### # 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 #