diff --git a/.automation/test/cfn/reports/expected-CFN.tap b/.automation/test/cfn/reports/expected-CFN.tap deleted file mode 100644 index 98466237..00000000 --- a/.automation/test/cfn/reports/expected-CFN.tap +++ /dev/null @@ -1,22 +0,0 @@ -TAP version 13 -1..8 -not ok 1 - cfn_bad_1.json - --- - message: E3001 Invalid or unsupported Type AWS Route53 HostedZonee for resource DNS in us-east-1\n/tmp/lint/.automation/test/cfn/cfn_bad_1.json 6 10\n - ... -not ok 2 - cfn_bad_2.yaml - --- - message: E3001 Invalid or unsupported Type AWS Route53 HostedZonee for resource DNS in us-east-1\n/tmp/lint/.automation/test/cfn/cfn_bad_2.yaml 5 5\n - ... -not ok 3 - cfn_bad_3.json - --- - message: E3002 Invalid Property Resources/myDNSRecord/Properties/Ttl\n/tmp/lint/.automation/test/cfn/cfn_bad_3.json 11 13\n - ... -not ok 4 - cfn_bad_4.yaml - --- - message: E3002 Invalid Property Resources/myDNSRecord/Properties/Ttl\n/tmp/lint/.automation/test/cfn/cfn_bad_4.yaml 9 7\n - ... -ok 5 - cfn_good_1.json -ok 6 - cfn_good_2.yaml -ok 7 - cfn_good_3.json -ok 8 - cfn_good_4.yaml diff --git a/.automation/test/cfn/README.md b/.automation/test/cloudformation/README.md similarity index 100% rename from .automation/test/cfn/README.md rename to .automation/test/cloudformation/README.md diff --git a/.automation/test/cfn/cfn_bad_1.json b/.automation/test/cloudformation/cloudformation_bad_1.json similarity index 100% rename from .automation/test/cfn/cfn_bad_1.json rename to .automation/test/cloudformation/cloudformation_bad_1.json diff --git a/.automation/test/cfn/cfn_bad_2.yaml b/.automation/test/cloudformation/cloudformation_bad_2.yaml similarity index 100% rename from .automation/test/cfn/cfn_bad_2.yaml rename to .automation/test/cloudformation/cloudformation_bad_2.yaml diff --git a/.automation/test/cfn/cfn_bad_3.json b/.automation/test/cloudformation/cloudformation_bad_3.json similarity index 100% rename from .automation/test/cfn/cfn_bad_3.json rename to .automation/test/cloudformation/cloudformation_bad_3.json diff --git a/.automation/test/cfn/cfn_bad_4.yaml b/.automation/test/cloudformation/cloudformation_bad_4.yaml similarity index 100% rename from .automation/test/cfn/cfn_bad_4.yaml rename to .automation/test/cloudformation/cloudformation_bad_4.yaml diff --git a/.automation/test/cfn/cfn_good_1.json b/.automation/test/cloudformation/cloudformation_good_1.json similarity index 100% rename from .automation/test/cfn/cfn_good_1.json rename to .automation/test/cloudformation/cloudformation_good_1.json diff --git a/.automation/test/cfn/cfn_good_2.yaml b/.automation/test/cloudformation/cloudformation_good_2.yaml similarity index 100% rename from .automation/test/cfn/cfn_good_2.yaml rename to .automation/test/cloudformation/cloudformation_good_2.yaml diff --git a/.automation/test/cfn/cfn_good_3.json b/.automation/test/cloudformation/cloudformation_good_3.json similarity index 100% rename from .automation/test/cfn/cfn_good_3.json rename to .automation/test/cloudformation/cloudformation_good_3.json diff --git a/.automation/test/cfn/cfn_good_4.yaml b/.automation/test/cloudformation/cloudformation_good_4.yaml similarity index 100% rename from .automation/test/cfn/cfn_good_4.yaml rename to .automation/test/cloudformation/cloudformation_good_4.yaml diff --git a/.automation/test/cloudformation/reports/expected-CLOUDFORMATION.tap b/.automation/test/cloudformation/reports/expected-CLOUDFORMATION.tap new file mode 100644 index 00000000..a92e9775 --- /dev/null +++ b/.automation/test/cloudformation/reports/expected-CLOUDFORMATION.tap @@ -0,0 +1,22 @@ +TAP version 13 +1..8 +not ok 1 - cloudformation_bad_1.json + --- + message: E3001 Invalid or unsupported Type AWS Route53 HostedZonee for resource DNS in us-east-1\n/tmp/lint/.automation/test/cloudformation/cloudformation_bad_1.json 6 10\n + ... +not ok 2 - cloudformation_bad_2.yaml + --- + message: E3001 Invalid or unsupported Type AWS Route53 HostedZonee for resource DNS in us-east-1\n/tmp/lint/.automation/test/cloudformation/cloudformation_bad_2.yaml 5 5\n + ... +not ok 3 - cloudformation_bad_3.json + --- + message: E3002 Invalid Property Resources/myDNSRecord/Properties/Ttl\n/tmp/lint/.automation/test/cloudformation/cloudformation_bad_3.json 11 13\n + ... +not ok 4 - cloudformation_bad_4.yaml + --- + message: E3002 Invalid Property Resources/myDNSRecord/Properties/Ttl\n/tmp/lint/.automation/test/cloudformation/cloudformation_bad_4.yaml 9 7\n + ... +ok 5 - cloudformation_good_1.json +ok 6 - cloudformation_good_2.yaml +ok 7 - cloudformation_good_3.json +ok 8 - cloudformation_good_4.yaml diff --git a/Dockerfile b/Dockerfile index 32964e48..cf48d8c7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -209,6 +209,7 @@ ENV ACTIONS_RUNNER_DEBUG=${ACTIONS_RUNNER_DEBUG} \ VALIDATE_ARM=${VALIDATE_ARM} \ VALIDATE_BASH=${VALIDATE_BASH} \ VALIDATE_CLOJURE=${VALIDATE_CLOJURE} \ + VALIDATE_CLOUDFORMATION=${VALIDATE_CLOUDFORMATION} \ VALIDATE_COFFEE=${VALIDATE_COFFEE} \ VALIDATE_CSS=${VALIDATE_CSS} \ VALIDATE_DART=${VALIDATE_DART} \ diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index 858966a0..fb19256e 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -18,7 +18,7 @@ For some linters it is also possible to override rules on a case by case level w - [Shell](#shell) - [Ansible](#ansible) - [YAML](#yaml) -- [AWS CloudFormation templates](#cfn) +- [AWS CloudFormation templates](#aws-cloud-formation) - [Python](#python3) - [JSON](#json) - [Markdown](#markdown) diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index 915ddcfa..2627238c 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -99,9 +99,9 @@ function BuildFileList() { ######### #echo "FILE_TYPE:[${FILE_TYPE}]" - ##################### - # Get the CFN files # - ##################### + ################################ + # Get the CLOUDFORMATION files # + ################################ if [ "${FILE_TYPE}" == "yml" ] || [ "${FILE_TYPE}" == "yaml" ]; then ################################ # Append the file to the array # @@ -119,7 +119,7 @@ function BuildFileList() { ################################ # Append the file to the array # ################################ - FILE_ARRAY_CFN+=("${FILE}") + FILE_ARRAY_CLOUDFORMATION+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # @@ -159,7 +159,7 @@ function BuildFileList() { ################################ # Append the file to the array # ################################ - FILE_ARRAY_CFN+=("${FILE}") + FILE_ARRAY_CLOUDFORMATION+=("${FILE}") fi ############################################ # Check if the file is AWS States Language # diff --git a/lib/linter.sh b/lib/linter.sh index c489a260..516c9d3c 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -22,71 +22,71 @@ source /action/lib/worker.sh # Source the function script(s) # GLOBALS # ########### # Default Vars -DEFAULT_RULES_LOCATION='/action/lib/.automation' # Default rules files location +DEFAULT_RULES_LOCATION='/action/lib/.automation' # Default rules files location # Ansible Vars -ANSIBLE_FILE_NAME='.ansible-lint.yml' # Name of the file -ANSIBLE_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${ANSIBLE_FILE_NAME}" # Path to the Ansible lint rules +ANSIBLE_FILE_NAME='.ansible-lint.yml' # Name of the file +ANSIBLE_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${ANSIBLE_FILE_NAME}" # Path to the Ansible lint rules # Azure Resource Manager Vars -ARM_FILE_NAME='.arm-ttk.psd1' # Name of the file -ARM_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${ARM_FILE_NAME}" # Path to the ARM lint rules +ARM_FILE_NAME='.arm-ttk.psd1' # Name of the file +ARM_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${ARM_FILE_NAME}" # Path to the ARM lint rules # Cloudformation Vars -CFN_FILE_NAME='.cfnlintrc.yml' # Name of the file -CFN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CFN_FILE_NAME}" # Path to the cloudformation lint rules +CLOUDFORMATION_FILE_NAME='.cfnlintrc.yml' # Name of the file +CLOUDFORMATION_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CLOUDFORMATION_FILE_NAME}" # Path to the cloudformation lint rules # Clojure Vars -CLOJURE_FILE_NAME='.clj-kondo/config.edn' # Name of the file -CLOJURE_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CLOJURE_FILE_NAME}" # Path to the Clojure lint rules +CLOJURE_FILE_NAME='.clj-kondo/config.edn' # Name of the file +CLOJURE_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CLOJURE_FILE_NAME}" # Path to the Clojure 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 +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 # CSS Vars -CSS_FILE_NAME='.stylelintrc.json' # Name of the file -CSS_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CSS_FILE_NAME}" # Path to the CSS lint rules +CSS_FILE_NAME='.stylelintrc.json' # Name of the file +CSS_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CSS_FILE_NAME}" # Path to the CSS lint rules # Dart Vars -DART_FILE_NAME='analysis_options.yaml' # Name of the file -DART_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DART_FILE_NAME}" # Path to the DART lint rules +DART_FILE_NAME='analysis_options.yaml' # Name of the file +DART_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DART_FILE_NAME}" # Path to the DART lint rules # Docker Vars -DOCKER_FILE_NAME='.dockerfilelintrc' # Name of the file -DOCKER_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DOCKER_FILE_NAME}" # Path to the Docker lint rules +DOCKER_FILE_NAME='.dockerfilelintrc' # Name of the file +DOCKER_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DOCKER_FILE_NAME}" # Path to the Docker lint rules # Golang Vars -GO_FILE_NAME='.golangci.yml' # Name of the file -GO_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${GO_FILE_NAME}" # Path to the Go lint rules +GO_FILE_NAME='.golangci.yml' # Name of the file +GO_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${GO_FILE_NAME}" # Path to the Go lint rules # HTML Vars -HTML_FILE_NAME='.htmlhintrc' # Name of the file -HTML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${HTML_FILE_NAME}" # Path to the CSS lint rules +HTML_FILE_NAME='.htmlhintrc' # Name of the file +HTML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${HTML_FILE_NAME}" # Path to the CSS 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 -JAVASCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard +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_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard # Default linter path -LINTER_RULES_PATH="${LINTER_RULES_PATH:-.github/linters}" # Linter Path Directory +LINTER_RULES_PATH="${LINTER_RULES_PATH:-.github/linters}" # Linter Path Directory # MD Vars -MARKDOWN_FILE_NAME='.markdown-lint.yml' # Name of the file -MARKDOWN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${MARKDOWN_FILE_NAME}" # Path to the markdown lint rules +MARKDOWN_FILE_NAME='.markdown-lint.yml' # Name of the file +MARKDOWN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${MARKDOWN_FILE_NAME}" # Path to the markdown lint rules # OpenAPI Vars -OPENAPI_FILE_NAME='.openapirc.yml' # Name of the file -OPENAPI_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${OPENAPI_FILE_NAME}" # Path to the OpenAPI lint rules +OPENAPI_FILE_NAME='.openapirc.yml' # Name of the file +OPENAPI_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${OPENAPI_FILE_NAME}" # Path to the OpenAPI lint rules # Powershell Vars -POWERSHELL_FILE_NAME='.powershell-psscriptanalyzer.psd1' # Name of the file -POWERSHELL_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${POWERSHELL_FILE_NAME}" # Path to the Powershell lint rules +POWERSHELL_FILE_NAME='.powershell-psscriptanalyzer.psd1' # Name of the file +POWERSHELL_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${POWERSHELL_FILE_NAME}" # Path to the Powershell lint rules # Protocol Buffers Vars -PROTOBUF_FILE_NAME='.protolintrc.yml' # Name of the file -PROTOBUF_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PROTOBUF_FILE_NAME}" # Path to the Protocol Buffers lint rules +PROTOBUF_FILE_NAME='.protolintrc.yml' # Name of the file +PROTOBUF_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PROTOBUF_FILE_NAME}" # Path to the Protocol Buffers lint rules # Python Vars -PYTHON_FILE_NAME='.python-lint' # Name of the file -PYTHON_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PYTHON_FILE_NAME}" # Path to the python lint rules +PYTHON_FILE_NAME='.python-lint' # Name of the file +PYTHON_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PYTHON_FILE_NAME}" # Path to the python lint rules # Ruby Vars -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_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 # Terraform Vars -TERRAFORM_FILE_NAME='.tflint.hcl' # Name of the file -TERRAFORM_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${TERRAFORM_FILE_NAME}" # Path to the Terraform lint rules +TERRAFORM_FILE_NAME='.tflint.hcl' # Name of the file +TERRAFORM_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${TERRAFORM_FILE_NAME}" # Path to the Terraform lint rules # Typescript Vars -TYPESCRIPT_FILE_NAME="${TYPESCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file -TYPESCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${TYPESCRIPT_FILE_NAME}" # Path to the Typescript lint rules -TYPESCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard +TYPESCRIPT_FILE_NAME="${TYPESCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file +TYPESCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${TYPESCRIPT_FILE_NAME}" # Path to the Typescript lint rules +TYPESCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard # YAML Vars -YAML_FILE_NAME='.yaml-lint.yml' # Name of the file -YAML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${YAML_FILE_NAME}" # Path to the yaml lint rules +YAML_FILE_NAME='.yaml-lint.yml' # Name of the file +YAML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${YAML_FILE_NAME}" # Path to the yaml lint rules ####################################### # Linter array for information prints # @@ -100,7 +100,7 @@ LINTER_ARRAY=('ansible-lint' 'arm-ttk' 'asl-validator' 'cfn-lint' 'clj-kondo' ############################# # Language array for prints # ############################# -LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CFN' 'CLOJURE' 'COFFEESCRIPT' +LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT' 'CSS' 'DART' 'DOCKER' 'ENV' 'GO' 'HTML' 'JAVASCRIPT_ES' 'JAVASCRIPT_STANDARD' 'JSON' 'JSX' 'KOTLIN' 'MARKDOWN' 'OPENAPI' 'PERL' 'PHP' 'POWERSHELL' 'PROTOBUF' 'PYTHON' @@ -130,7 +130,7 @@ VALIDATE_ALL_CODEBASE="${VALIDATE_ALL_CODEBASE}" # Boolean to vali VALIDATE_ANSIBLE="${VALIDATE_ANSIBLE}" # Boolean to validate language VALIDATE_ARM="${VALIDATE_ARM}" # Boolean to validate language VALIDATE_BASH="${VALIDATE_BASH}" # Boolean to validate language -VALIDATE_CFN="${VALIDATE_CLOUDFORMATION}" # Boolean to validate language +VALIDATE_CLOUDFORMATION="${VALIDATE_CLOUDFORMATION}" # Boolean to validate language VALIDATE_CLOJURE="${VALIDATE_CLOJURE}" # Boolean to validate language VALIDATE_COFFEE="${VALIDATE_COFFEE}" # Boolean to validate language VALIDATE_CSS="${VALIDATE_CSS}" # Boolean to validate language @@ -205,7 +205,7 @@ REPORT_OUTPUT_FOLDER="${DEFAULT_WORKSPACE}/${OUTPUT_FOLDER}" # Location for the ########################## FILE_ARRAY_ARM=() # Array of files to check FILE_ARRAY_BASH=() # Array of files to check -FILE_ARRAY_CFN=() # Array of files to check +FILE_ARRAY_CLOUDFORMATION=() # Array of files to check FILE_ARRAY_CLOJURE=() # Array of files to check FILE_ARRAY_COFFEESCRIPT=() # Array of files to check FILE_ARRAY_CSS=() # Array of files to check @@ -242,7 +242,7 @@ FILE_ARRAY_YML=() # Array of files to check ERRORS_FOUND_ANSIBLE=0 # Count of errors found ERRORS_FOUND_ARM=0 # Count of errors found ERRORS_FOUND_BASH=0 # Count of errors found -ERRORS_FOUND_CFN=0 # Count of errors found +ERRORS_FOUND_CLOUDFORMATION=0 # Count of errors found ERRORS_FOUND_CLOJURE=0 # Count of errors found ERRORS_FOUND_CSS=0 # Count of errors found ERRORS_FOUND_COFFEESCRIPT=0 # Count of errors found @@ -574,9 +574,9 @@ DetectCloudFormationFile() { return 0 fi - ########################################## - # No identifiers of a CFN template found # - ########################################## + ##################################################### + # No identifiers of a CLOUDFORMATION template found # + ##################################################### return 1 } ################################################################################ @@ -965,7 +965,7 @@ Footer() { elif [ "${ERRORS_FOUND_ANSIBLE}" -ne 0 ] || [ "${ERRORS_FOUND_ARM}" -ne 0 ] || [ "${ERRORS_FOUND_BASH}" -ne 0 ] || - [ "${ERRORS_FOUND_CFN}" -ne 0 ] || + [ "${ERRORS_FOUND_CLOUDFORMATION}" -ne 0 ] || [ "${ERRORS_FOUND_CLOJURE}" -ne 0 ] || [ "${ERRORS_FOUND_COFFEESCRIPT}" -ne 0 ] || [ "${ERRORS_FOUND_CSS}" -ne 0 ] || @@ -1074,8 +1074,8 @@ GetLinterRules "POWERSHELL" GetLinterRules "ARM" # Get CSS rules GetLinterRules "CSS" -# Get CFN rules -GetLinterRules "CFN" +# Get CLOUDFORMATION rules +GetLinterRules "CLOUDFORMATION" # Get DART rules GetLinterRules "DART" # Get HTML rules @@ -1184,15 +1184,15 @@ if [ "${VALIDATE_PYTHON}" == "true" ]; then LintCodebase "PYTHON" "pylint" "pylint --rcfile ${PYTHON_LINTER_RULES}" ".*\.\(py\)\$" "${FILE_ARRAY_PYTHON[@]}" fi -############### -# CFN LINTING # -############### -if [ "${VALIDATE_CFN}" == "true" ]; then +########################## +# CLOUDFORMATION LINTING # +########################## +if [ "${VALIDATE_CLOUDFORMATION}" == "true" ]; then ################################# # Lint the CloudFormation files # ################################# # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "CFN" "cfn-lint" "cfn-lint --config-file ${CFN_LINTER_RULES}" ".*\.\(json\|yml\|yaml\)\$" "${FILE_ARRAY_CFN[@]}" + LintCodebase "CLOUDFORMATION" "cfn-lint" "cfn-lint --config-file ${CLOUDFORMATION_LINTER_RULES}" ".*\.\(json\|yml\|yaml\)\$" "${FILE_ARRAY_CLOUDFORMATION[@]}" fi ################ diff --git a/lib/validation.sh b/lib/validation.sh index 4fffb249..bf1e7ccb 100755 --- a/lib/validation.sh +++ b/lib/validation.sh @@ -50,6 +50,7 @@ function GetValidationInfo() { VALIDATE_ARM="${VALIDATE_ARM,,}" VALIDATE_BASH="${VALIDATE_BASH,,}" VALIDATE_CLOJURE="${VALIDATE_CLOJURE,,}" + VALIDATE_CLOUDFORMATION="${VALIDATE_CLOUDFORMATION,,}" VALIDATE_COFFEE="${VALIDATE_COFFEE,,}" VALIDATE_CSS="${VALIDATE_CSS,,}" VALIDATE_DART="${VALIDATE_DART,,}" @@ -88,6 +89,7 @@ function GetValidationInfo() { ${VALIDATE_ARM} || -n \ ${VALIDATE_BASH} || -n \ ${VALIDATE_CLOJURE} || -n \ + ${VALIDATE_CLOUDFORMATION} || -n \ ${VALIDATE_COFFEE} || -n \ ${VALIDATE_CSS} || -n \ ${VALIDATE_DART} || -n \ @@ -551,6 +553,20 @@ function GetValidationInfo() { VALIDATE_CLOJURE="true" fi + ############################################## + # Validate if we should check CloudFormation # + ############################################## + if [[ ${ANY_SET} == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z ${VALIDATE_CLOUDFORMATION} ]]; then + # Cloud Formation flag was not set - default to false + VALIDATE_CLOUDFORMATION="false" + fi + else + # No linter flags were set - default all to true + VALIDATE_CLOUDFORMATION="true" + fi + ############################################ # Validate if we should check editorconfig # ############################################ @@ -700,6 +716,11 @@ function GetValidationInfo() { else PRINT_ARRAY+=("- Excluding [CLOJURE] files in code base...") fi + if [[ ${VALIDATE_CLOUDFORMATION} == "true" ]]; then + PRINT_ARRAY+=("- Validating [CLOUDFORMATION] files in code base...") + else + PRINT_ARRAY+=("- Excluding [CLOUDFORMATION] files in code base...") + fi if [[ ${VALIDATE_ENV} == "true" ]]; then PRINT_ARRAY+=("- Validating [ENV] files in code base...") else diff --git a/lib/worker.sh b/lib/worker.sh index f5957f4e..57ee3413 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -557,7 +557,7 @@ function RunTestCases() { TestCodebase "ANSIBLE" "ansible-lint" "ansible-lint -v -c ${ANSIBLE_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "ansible" TestCodebase "ARM" "arm-ttk" "Import-Module ${ARM_TTK_PSD1} ; \${config} = \$(Import-PowerShellDataFile -Path ${ARM_LINTER_RULES}) ; Test-AzTemplate @config -TemplatePath" ".*\.\(json\)\$" "arm" TestCodebase "BASH" "shellcheck" "shellcheck --color" ".*\.\(sh\|bash\|dash\|ksh\)\$" "shell" - TestCodebase "CFN" "cfn-lint" "cfn-lint --config-file ${CFN_LINTER_RULES}" ".*\.\(json\|yml\|yaml\)\$" "cfn" + TestCodebase "CLOUDFORMATION" "cfn-lint" "cfn-lint --config-file ${CLOUDFORMATION_LINTER_RULES}" ".*\.\(json\|yml\|yaml\)\$" "cloudformation" TestCodebase "CLOJURE" "clj-kondo" "clj-kondo --config ${CLOJURE_LINTER_RULES} --lint" ".*\.\(clj\|cljs\|cljc\|edn\)\$" "clojure" TestCodebase "COFFEESCRIPT" "coffeelint" "coffeelint -f ${COFFEESCRIPT_LINTER_RULES}" ".*\.\(coffee\)\$" "coffeescript" TestCodebase "CSS" "stylelint" "stylelint --config ${CSS_LINTER_RULES}" ".*\.\(css\)\$" "css"