2020-06-23 12:02:45 -04:00
|
|
|
#!/usr/bin/env bash
|
2019-10-21 10:12:50 -04:00
|
|
|
|
|
|
|
################################################################################
|
2020-02-03 11:27:40 -05:00
|
|
|
################################################################################
|
2020-06-24 12:47:47 -04:00
|
|
|
########### Super-Linter (Lint all the code) @admiralawkbar ####################
|
2020-02-03 11:27:40 -05:00
|
|
|
################################################################################
|
2019-10-21 10:12:50 -04:00
|
|
|
################################################################################
|
|
|
|
|
2020-06-29 10:55:59 -04:00
|
|
|
#########################
|
|
|
|
# Source Function Files #
|
|
|
|
#########################
|
2020-06-30 10:56:15 -04:00
|
|
|
# shellcheck source=/dev/null
|
2020-07-27 17:11:33 -04:00
|
|
|
source /action/lib/log.sh # Source the function script(s)
|
2020-07-01 15:00:05 -04:00
|
|
|
# shellcheck source=/dev/null
|
2020-07-01 17:40:40 -04:00
|
|
|
source /action/lib/buildFileList.sh # Source the function script(s)
|
2020-06-30 10:56:15 -04:00
|
|
|
# shellcheck source=/dev/null
|
2020-07-01 17:40:40 -04:00
|
|
|
source /action/lib/validation.sh # Source the function script(s)
|
2020-06-30 10:56:15 -04:00
|
|
|
# shellcheck source=/dev/null
|
2020-07-01 17:40:40 -04:00
|
|
|
source /action/lib/worker.sh # Source the function script(s)
|
2020-06-29 10:55:59 -04:00
|
|
|
|
2019-10-21 10:12:50 -04:00
|
|
|
###########
|
2019-10-21 12:05:55 -04:00
|
|
|
# GLOBALS #
|
2019-10-21 10:12:50 -04:00
|
|
|
###########
|
2019-10-21 15:12:37 -04:00
|
|
|
# Default Vars
|
2020-07-30 16:18:24 -04:00
|
|
|
DEFAULT_RULES_LOCATION='/action/lib/.automation' # Default rules files location
|
2020-07-31 10:07:44 -04:00
|
|
|
GITHUB_API_URL='https://api.github.com' # GitHub API root url
|
2020-07-21 14:50:04 -04:00
|
|
|
# Ansible Vars
|
2020-08-06 11:53:42 -04:00
|
|
|
ANSIBLE_FILE_NAME='.ansible-lint.yml' # Name of the file
|
2020-07-30 16:18:24 -04:00
|
|
|
ANSIBLE_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${ANSIBLE_FILE_NAME}" # Path to the Ansible lint rules
|
2020-07-21 14:50:04 -04:00
|
|
|
# Azure Resource Manager Vars
|
2020-07-30 16:18:24 -04:00
|
|
|
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
|
2020-06-19 12:41:19 -04:00
|
|
|
# Cloudformation Vars
|
2020-08-06 11:53:42 -04:00
|
|
|
CLOUDFORMATION_FILE_NAME='.cfnlintrc.yml' # Name of the file
|
2020-07-30 16:18:24 -04:00
|
|
|
CLOUDFORMATION_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CLOUDFORMATION_FILE_NAME}" # Path to the cloudformation lint rules
|
2020-07-21 14:50:04 -04:00
|
|
|
# Clojure Vars
|
2020-07-30 16:18:24 -04:00
|
|
|
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
|
2019-10-21 15:12:37 -04:00
|
|
|
# Coffee Vars
|
2020-08-27 10:00:54 -04:00
|
|
|
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
|
2020-07-21 14:50:04 -04:00
|
|
|
# CSS Vars
|
2020-08-25 10:05:23 -04:00
|
|
|
CSS_FILE_NAME="${CSS_FILE_NAME:-.stylelintrc.json}" # Name of the file
|
2020-07-30 16:18:24 -04:00
|
|
|
CSS_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CSS_FILE_NAME}" # Path to the CSS lint rules
|
2020-07-21 14:50:04 -04:00
|
|
|
# Dart Vars
|
2020-08-06 11:53:42 -04:00
|
|
|
DART_FILE_NAME='analysis_options.yml' # Name of the file
|
2020-07-30 16:18:24 -04:00
|
|
|
DART_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DART_FILE_NAME}" # Path to the DART lint rules
|
2020-08-13 12:03:13 -04:00
|
|
|
# Dockerfile Vars
|
|
|
|
DOCKERFILE_FILE_NAME='.dockerfilelintrc' # Name of the file
|
|
|
|
DOCKERFILE_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DOCKERFILE_FILE_NAME}" # Path to the Docker lint rules
|
|
|
|
# Dockerfile Hadolint Vars
|
2020-08-25 10:55:30 -04:00
|
|
|
DOCKERFILE_HADOLINT_FILE_NAME="${DOCKERFILE_HADOLINT_FILE_NAME:-.hadolint.yml}" # Name of the file
|
2020-08-13 12:03:13 -04:00
|
|
|
DOCKERFILE_HADOLINT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DOCKERFILE_HADOLINT_FILE_NAME}" # Path to the Docker lint rules
|
2020-02-28 10:51:29 -05:00
|
|
|
# Golang Vars
|
2020-08-06 11:53:42 -04:00
|
|
|
GO_FILE_NAME='.golangci.yml' # Name of the file
|
2020-07-30 16:18:24 -04:00
|
|
|
GO_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${GO_FILE_NAME}" # Path to the Go lint rules
|
2020-07-14 10:28:58 -04:00
|
|
|
# Groovy Vars
|
2020-07-30 16:18:24 -04:00
|
|
|
GROOVY_FILE_NAME='.groovylintrc.json' # Name of the file
|
|
|
|
GROOVY_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${GROOVY_FILE_NAME}" # Path to the Groovy lint rules
|
2020-07-21 14:50:04 -04:00
|
|
|
# HTML Vars
|
2020-07-30 16:18:24 -04:00
|
|
|
HTML_FILE_NAME='.htmlhintrc' # Name of the file
|
|
|
|
HTML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${HTML_FILE_NAME}" # Path to the CSS lint rules
|
2020-08-05 14:35:14 -04:00
|
|
|
# Java Vars
|
|
|
|
JAVA_FILE_NAME="sun_checks.xml" # Name of the Java config file
|
|
|
|
JAVA_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${JAVA_FILE_NAME}" # Path to the Java lint rules
|
2020-07-21 14:50:04 -04:00
|
|
|
# Javascript Vars
|
2020-08-06 11:53:42 -04:00
|
|
|
JAVASCRIPT_FILE_NAME="${JAVASCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file
|
2020-07-30 16:18:24 -04:00
|
|
|
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
|
2020-07-21 14:50:04 -04:00
|
|
|
# Default linter path
|
2020-07-30 16:18:24 -04:00
|
|
|
LINTER_RULES_PATH="${LINTER_RULES_PATH:-.github/linters}" # Linter Path Directory
|
2020-08-18 18:54:32 -04:00
|
|
|
# LaTeX Vars
|
2020-08-31 15:34:14 -04:00
|
|
|
LATEX_FILE_NAME='.chktexrc' # Name of the file
|
|
|
|
LATEX_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${LATEX_FILE_NAME}" # Path to the Latex lint rules
|
2020-07-24 13:27:54 -04:00
|
|
|
# Lua Vars
|
2020-07-30 16:18:24 -04:00
|
|
|
LUA_FILE_NAME='.luacheckrc' # Name of the file
|
|
|
|
LUA_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${LUA_FILE_NAME}" # Path to the Lua lint rules
|
2020-07-21 14:50:04 -04:00
|
|
|
# MD Vars
|
2020-08-07 01:51:59 -04:00
|
|
|
MARKDOWN_FILE_NAME="${MARKDOWN_CONFIG_FILE:-.markdown-lint.yml}" # Name of the file
|
2020-07-30 16:18:24 -04:00
|
|
|
MARKDOWN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${MARKDOWN_FILE_NAME}" # Path to the markdown lint rules
|
2020-06-25 02:13:19 -04:00
|
|
|
# OpenAPI Vars
|
2020-08-06 11:53:42 -04:00
|
|
|
OPENAPI_FILE_NAME='.openapirc.yml' # Name of the file
|
2020-07-30 16:18:24 -04:00
|
|
|
OPENAPI_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${OPENAPI_FILE_NAME}" # Path to the OpenAPI lint rules
|
2020-07-26 15:30:45 -04:00
|
|
|
# PHPCS Vars
|
2020-08-03 15:43:38 -04:00
|
|
|
PHP_PHPCS_FILE_NAME='phpcs.xml' # Name of the file
|
|
|
|
PHP_PHPCS_LINTER_RULES="${GITHUB_WORKSPACE}/${PHP_PHPCS_FILE_NAME}" # Path to the PHP CodeSniffer lint rules in the repository
|
|
|
|
if [ ! -f "$PHP_PHPCS_LINTER_RULES" ]; then
|
|
|
|
PHP_PHPCS_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PHP_PHPCS_FILE_NAME}" # Path to the PHP CodeSniffer lint rules
|
|
|
|
fi
|
|
|
|
# PHPStan Vars
|
|
|
|
PHP_PHPSTAN_FILE_NAME='phpstan.neon' # Name of the file
|
|
|
|
PHP_PHPSTAN_LINTER_RULES="${GITHUB_WORKSPACE}/${PHP_PHPSTAN_FILE_NAME}" # Path to the PHPStan lint rules in the repository
|
|
|
|
if [ ! -f "$PHP_PHPSTAN_LINTER_RULES" ]; then
|
|
|
|
PHP_PHPSTAN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PHP_PHPSTAN_FILE_NAME}" # Path to the PHPStan lint rules
|
|
|
|
fi
|
2020-07-26 15:30:45 -04:00
|
|
|
# Psalm Vars
|
2020-08-03 15:43:38 -04:00
|
|
|
PHP_PSALM_FILE_NAME='psalm.xml' # Name of the file
|
|
|
|
PHP_PSALM_LINTER_RULES="${GITHUB_WORKSPACE}/${PHP_PSALM_FILE_NAME}" # Path to the Psalm lint rules in the repository
|
|
|
|
if [ ! -f "$PHP_PSALM_LINTER_RULES" ]; then
|
|
|
|
PHP_PSALM_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PHP_PSALM_FILE_NAME}" # Path to the Psalm lint rules
|
2020-07-24 14:54:11 -04:00
|
|
|
fi
|
2020-06-19 12:13:13 -04:00
|
|
|
# Powershell Vars
|
2020-07-30 16:18:24 -04:00
|
|
|
POWERSHELL_FILE_NAME='.powershell-psscriptanalyzer.psd1' # Name of the file
|
2020-07-21 13:09:07 -04:00
|
|
|
POWERSHELL_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${POWERSHELL_FILE_NAME}" # Path to the Powershell lint rules
|
2020-06-28 07:07:51 -04:00
|
|
|
# Protocol Buffers Vars
|
2020-08-06 11:53:42 -04:00
|
|
|
PROTOBUF_FILE_NAME='.protolintrc.yml' # Name of the file
|
2020-07-30 16:18:24 -04:00
|
|
|
PROTOBUF_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PROTOBUF_FILE_NAME}" # Path to the Protocol Buffers lint rules
|
2020-07-21 14:50:04 -04:00
|
|
|
# Python Vars
|
2020-07-30 16:18:24 -04:00
|
|
|
PYTHON_PYLINT_FILE_NAME="${PYTHON_PYLINT_CONFIG_FILE:-.python-lint}" # Name of the file
|
|
|
|
PYTHON_PYLINT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PYTHON_PYLINT_FILE_NAME}" # Path to the python lint rules
|
|
|
|
PYTHON_FLAKE8_FILE_NAME="${PYTHON_FLAKE8_CONFIG_FILE:-.flake8}" # Name of the file
|
|
|
|
PYTHON_FLAKE8_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PYTHON_FLAKE8_FILE_NAME}" # Path to the python lint rules
|
2020-09-02 03:27:32 -04:00
|
|
|
PYTHON_BLACK_FILE_NAME="${PYTHON_BLACK_CONFIG_FILE:-.python-black}" # Name of the file
|
|
|
|
PYTHON_BLACK_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PYTHON_BLACK_FILE_NAME}" # Path to the python lint rules
|
2020-08-15 15:29:22 -04:00
|
|
|
# R Vars
|
2020-08-15 20:18:31 -04:00
|
|
|
R_FILE_NAME='.lintr' # Name of the file
|
|
|
|
R_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${R_FILE_NAME}" # Path to the R lint rules
|
2020-07-21 14:50:04 -04:00
|
|
|
# Ruby Vars
|
2020-08-06 11:53:42 -04:00
|
|
|
RUBY_FILE_NAME="${RUBY_CONFIG_FILE:-.ruby-lint.yml}" # Name of the file
|
2020-07-30 16:18:24 -04:00
|
|
|
RUBY_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${RUBY_FILE_NAME}" # Path to the ruby lint rules
|
2020-08-11 13:30:00 -04:00
|
|
|
# SQL Vars
|
|
|
|
SQL_FILE_NAME=".sql-config.json" # Name of the file
|
|
|
|
SQL_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${SQL_FILE_NAME}" # Path to the SQL lint rules
|
2020-07-21 14:50:04 -04:00
|
|
|
# Terraform Vars
|
2020-07-30 16:18:24 -04:00
|
|
|
TERRAFORM_FILE_NAME='.tflint.hcl' # Name of the file
|
|
|
|
TERRAFORM_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${TERRAFORM_FILE_NAME}" # Path to the Terraform lint rules
|
2020-07-21 14:50:04 -04:00
|
|
|
# Typescript Vars
|
2020-08-06 11:56:06 -04:00
|
|
|
TYPESCRIPT_FILE_NAME="${TYPESCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file
|
2020-07-30 16:18:24 -04:00
|
|
|
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
|
2020-09-03 10:12:49 -04:00
|
|
|
# Version File info
|
|
|
|
VERSION_FILE='/action/lib/linter-versions.txt' # File to store linter versions
|
2020-07-21 14:50:04 -04:00
|
|
|
# YAML Vars
|
2020-08-06 11:56:06 -04:00
|
|
|
YAML_FILE_NAME="${YAML_CONFIG_FILE:-.yaml-lint.yml}" # Name of the file
|
2020-07-30 16:18:24 -04:00
|
|
|
YAML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${YAML_FILE_NAME}" # Path to the yaml lint rules
|
2020-06-18 19:40:41 -04:00
|
|
|
|
2020-04-27 15:13:12 -04:00
|
|
|
#############################
|
|
|
|
# Language array for prints #
|
|
|
|
#############################
|
2020-08-28 12:54:31 -04:00
|
|
|
LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'BASH_EXEC' 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT' 'CSHARP' 'CSS'
|
2020-08-06 11:25:45 -04:00
|
|
|
'DART' 'DOCKERFILE' 'DOCKERFILE_HADOLINT' 'EDITORCONFIG' 'ENV' 'GO' 'GROOVY' 'HTML'
|
2020-08-18 18:54:32 -04:00
|
|
|
'JAVA' 'JAVASCRIPT_ES' 'JAVASCRIPT_STANDARD' 'JSON' 'JSX' 'KOTLIN' 'LATEX' 'LUA' 'MARKDOWN'
|
2020-08-06 11:25:45 -04:00
|
|
|
'OPENAPI' 'PERL' 'PHP_BUILTIN' 'PHP_PHPCS' 'PHP_PHPSTAN' 'PHP_PSALM' 'POWERSHELL'
|
2020-08-31 18:06:15 -04:00
|
|
|
'PROTOBUF' 'PYTHON_BLACK' 'PYTHON_PYLINT' 'PYTHON_FLAKE8' 'R' 'RAKU' 'RUBY' 'SHELL_SHFMT' 'STATES' 'SQL' 'TERRAFORM'
|
2020-08-06 11:25:45 -04:00
|
|
|
'TERRAFORM_TERRASCAN' 'TSX' 'TYPESCRIPT_ES' 'TYPESCRIPT_STANDARD' 'XML' 'YAML')
|
2020-07-21 09:12:28 -04:00
|
|
|
|
|
|
|
############################################
|
|
|
|
# Array for all languages that were linted #
|
|
|
|
############################################
|
|
|
|
LINTED_LANGUAGES_ARRAY=() # Will be filled at run time with all languages that were linted
|
2020-04-27 15:13:12 -04:00
|
|
|
|
2019-10-21 15:12:37 -04:00
|
|
|
###################
|
|
|
|
# GitHub ENV Vars #
|
|
|
|
###################
|
2020-07-30 16:18:24 -04:00
|
|
|
ANSIBLE_DIRECTORY="${ANSIBLE_DIRECTORY}" # Ansible Directory
|
|
|
|
DEFAULT_BRANCH="${DEFAULT_BRANCH:-master}" # Default Git Branch to use (master by default)
|
|
|
|
DISABLE_ERRORS="${DISABLE_ERRORS}" # Boolean to enable warning-only output without throwing errors
|
|
|
|
GITHUB_EVENT_PATH="${GITHUB_EVENT_PATH}" # Github Event Path
|
|
|
|
GITHUB_REPOSITORY="${GITHUB_REPOSITORY}" # GitHub Org/Repo passed from system
|
|
|
|
GITHUB_RUN_ID="${GITHUB_RUN_ID}" # GitHub RUn ID to point to logs
|
|
|
|
GITHUB_SHA="${GITHUB_SHA}" # GitHub sha from the commit
|
|
|
|
GITHUB_TOKEN="${GITHUB_TOKEN}" # GitHub Token passed from environment
|
|
|
|
GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # Github Workspace
|
|
|
|
LOG_FILE="${LOG_FILE:-super-linter.log}" # Default log file name (located in GITHUB_WORKSPACE folder)
|
|
|
|
LOG_LEVEL="${LOG_LEVEL:-VERBOSE}" # Default log level (VERBOSE, DEBUG, TRACE)
|
|
|
|
MULTI_STATUS="${MULTI_STATUS:-true}" # Multiple status are created for each check ran
|
|
|
|
TEST_CASE_RUN="${TEST_CASE_RUN}" # Boolean to validate only test cases
|
|
|
|
VALIDATE_ALL_CODEBASE="${VALIDATE_ALL_CODEBASE}" # Boolean to validate all files
|
|
|
|
VALIDATE_ANSIBLE="${VALIDATE_ANSIBLE}" # Boolean to validate language
|
|
|
|
VALIDATE_ARM="${VALIDATE_ARM}" # Boolean to validate language
|
|
|
|
VALIDATE_BASH="${VALIDATE_BASH}" # Boolean to validate language
|
2020-08-28 10:56:53 -04:00
|
|
|
VALIDATE_BASH_EXEC="${VALIDATE_BASH_EXEC}" # Boolean to validate language
|
2020-07-30 16:18:24 -04:00
|
|
|
VALIDATE_CLOUDFORMATION="${VALIDATE_CLOUDFORMATION}" # Boolean to validate language
|
|
|
|
VALIDATE_CLOJURE="${VALIDATE_CLOJURE}" # Boolean to validate language
|
|
|
|
VALIDATE_COFFEE="${VALIDATE_COFFEE}" # Boolean to validate language
|
2020-08-24 20:40:02 -04:00
|
|
|
VALIDATE_CSHARP="${VALIDATE_CSHARP}" # Boolean to validate language
|
2020-07-30 16:18:24 -04:00
|
|
|
VALIDATE_CSS="${VALIDATE_CSS}" # Boolean to validate language
|
|
|
|
VALIDATE_DART="${VALIDATE_DART}" # Boolean to validate language
|
2020-08-17 03:59:09 -04:00
|
|
|
VALIDATE_DOCKERFILE="${VALIDATE_DOCKERFILE}" # Boolean to validate language
|
|
|
|
VALIDATE_DOCKERFILE_HADOLINT="${VALIDATE_DOCKERFILE_HADOLINT}" # Boolean to validate language
|
2020-07-30 16:18:24 -04:00
|
|
|
VALIDATE_EDITORCONFIG="${VALIDATE_EDITORCONFIG}" # Boolean to validate files with editorconfig
|
|
|
|
VALIDATE_ENV="${VALIDATE_ENV}" # Boolean to validate language
|
|
|
|
VALIDATE_GO="${VALIDATE_GO}" # Boolean to validate language
|
|
|
|
VALIDATE_GROOVY="${VALIDATE_GROOVY}" # Boolean to validate language
|
|
|
|
VALIDATE_HTML="${VALIDATE_HTML}" # Boolean to validate language
|
2020-08-05 12:00:51 -04:00
|
|
|
VALIDATE_JAVA="${VALIDATE_JAVA}" # Boolean to validate language
|
2020-07-30 16:18:24 -04:00
|
|
|
VALIDATE_JAVASCRIPT_ES="${VALIDATE_JAVASCRIPT_ES}" # Boolean to validate language
|
|
|
|
VALIDATE_JAVASCRIPT_STANDARD="${VALIDATE_JAVASCRIPT_STANDARD}" # Boolean to validate language
|
|
|
|
VALIDATE_JSON="${VALIDATE_JSON}" # Boolean to validate language
|
|
|
|
VALIDATE_JSX="${VALIDATE_JSX}" # Boolean to validate language
|
|
|
|
VALIDATE_KOTLIN="${VALIDATE_KOTLIN}" # Boolean to validate language
|
2020-08-18 19:03:12 -04:00
|
|
|
VALIDATE_LATEX="${VALIDATE_LATEX}" # Boolean to validate language
|
2020-07-30 16:18:24 -04:00
|
|
|
VALIDATE_LUA="${VALIDATE_LUA}" # Boolean to validate language
|
|
|
|
VALIDATE_MARKDOWN="${VALIDATE_MD:-}" # Boolean to validate language
|
|
|
|
VALIDATE_OPENAPI="${VALIDATE_OPENAPI}" # Boolean to validate language
|
|
|
|
VALIDATE_PERL="${VALIDATE_PERL}" # Boolean to validate language
|
2020-08-18 18:54:32 -04:00
|
|
|
VALIDATE_PHP_BUILTIN="${VALIDATE_PHP:-$VALIDATE_PHP_BUILTIN}" # Boolean to validate language
|
2020-07-31 09:54:50 -04:00
|
|
|
VALIDATE_PHP_PHPCS="${VALIDATE_PHP_PHPCS}" # Boolean to validate language
|
2020-07-30 16:18:24 -04:00
|
|
|
VALIDATE_PHP_PHPSTAN="${VALIDATE_PHP_PHPSTAN}" # Boolean to validate language
|
2020-08-03 15:43:38 -04:00
|
|
|
VALIDATE_PHP_PSALM="${VALIDATE_PHP_PSALM}" # Boolean to validate language
|
2020-07-30 16:18:24 -04:00
|
|
|
VALIDATE_POWERSHELL="${VALIDATE_POWERSHELL}" # Boolean to validate language
|
|
|
|
VALIDATE_PYTHON_FLAKE8="${VALIDATE_PYTHON_FLAKE8}" # Boolean to validate language
|
2020-08-20 10:44:11 -04:00
|
|
|
VALIDATE_PYTHON_BLACK="${VALIDATE_PYTHON_BLACK}" # Boolean to validate language
|
|
|
|
VALIDATE_PYTHON_PYLINT="${VALIDATE_PYTHON:-$VALIDATE_PYTHON_PYLINT}" # Boolean to validate language
|
2020-08-15 15:29:22 -04:00
|
|
|
VALIDATE_R="${VALIDATE_R}" # Boolean to validate language
|
2020-07-30 16:18:24 -04:00
|
|
|
VALIDATE_RAKU="${VALIDATE_RAKU}" # Boolean to validate language
|
|
|
|
VALIDATE_RUBY="${VALIDATE_RUBY}" # Boolean to validate language
|
|
|
|
VALIDATE_STATES="${VALIDATE_STATES}" # Boolean to validate language
|
2020-08-31 18:06:15 -04:00
|
|
|
VALIDATE_SHELL_SHFMT="${VALIDATE_SHELL_SHFMT}" # Boolean to check Shell files against editorconfig
|
2020-08-06 13:01:36 -04:00
|
|
|
VALIDATE_SQL="${VALIDATE_SQL}" # Boolean to validate language
|
2020-07-30 16:18:24 -04:00
|
|
|
VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM}" # Boolean to validate language
|
|
|
|
VALIDATE_TERRAFORM_TERRASCAN="${VALIDATE_TERRAFORM_TERRASCAN}" # Boolean to validate language
|
|
|
|
VALIDATE_TSX="${VALIDATE_TSX}" # Boolean to validate language
|
|
|
|
VALIDATE_TYPESCRIPT_ES="${VALIDATE_TYPESCRIPT_ES}" # Boolean to validate language
|
|
|
|
VALIDATE_TYPESCRIPT_STANDARD="${VALIDATE_TYPESCRIPT_STANDARD}" # Boolean to validate language
|
|
|
|
VALIDATE_XML="${VALIDATE_XML}" # Boolean to validate language
|
|
|
|
VALIDATE_YAML="${VALIDATE_YAML}" # Boolean to validate language
|
2020-07-22 01:49:31 -04:00
|
|
|
|
2020-02-03 15:54:43 -05:00
|
|
|
##############
|
|
|
|
# Debug Vars #
|
|
|
|
##############
|
2020-07-01 17:40:40 -04:00
|
|
|
RUN_LOCAL="${RUN_LOCAL}" # Boolean to see if we are running locally
|
|
|
|
ACTIONS_RUNNER_DEBUG="${ACTIONS_RUNNER_DEBUG:-false}" # Boolean to see even more info (debug)
|
2019-10-25 12:29:31 -04:00
|
|
|
|
2020-07-30 15:15:42 -04:00
|
|
|
############
|
|
|
|
# Log Vars #
|
|
|
|
############
|
2020-07-30 16:18:24 -04:00
|
|
|
if [[ ${ACTIONS_RUNNER_DEBUG} == true ]]; then LOG_LEVEL="DEBUG"; fi
|
|
|
|
# Boolean to see trace logs
|
|
|
|
LOG_TRACE=$(if [[ ${LOG_LEVEL} == "TRACE" ]]; then echo "true"; fi)
|
2020-07-30 15:15:42 -04:00
|
|
|
export LOG_TRACE
|
2020-07-30 16:18:24 -04:00
|
|
|
# Boolean to see debug logs
|
|
|
|
LOG_DEBUG=$(if [[ ${LOG_LEVEL} == "DEBUG" || ${LOG_LEVEL} == "TRACE" ]]; then echo "true"; fi)
|
2020-07-30 15:15:42 -04:00
|
|
|
export LOG_DEBUG
|
2020-07-30 16:18:24 -04:00
|
|
|
# Boolean to see verbose logs (info function)
|
|
|
|
LOG_VERBOSE=$(if [[ ${LOG_LEVEL} == "VERBOSE" || ${LOG_LEVEL} == "DEBUG" || ${LOG_LEVEL} == "TRACE" ]]; then echo "true"; fi)
|
2020-07-30 15:15:42 -04:00
|
|
|
export LOG_VERBOSE
|
|
|
|
|
2019-10-25 12:29:31 -04:00
|
|
|
################
|
|
|
|
# Default Vars #
|
|
|
|
################
|
2020-07-01 17:40:40 -04:00
|
|
|
DEFAULT_VALIDATE_ALL_CODEBASE='true' # Default value for validate all files
|
|
|
|
DEFAULT_WORKSPACE="${DEFAULT_WORKSPACE:-/tmp/lint}" # Default workspace if running locally
|
|
|
|
DEFAULT_RUN_LOCAL='false' # Default value for debugging locally
|
|
|
|
DEFAULT_TEST_CASE_RUN='false' # Flag to tell code to run only test cases
|
2020-07-30 16:18:24 -04:00
|
|
|
DEFAULT_IFS="${IFS}" # Get the Default IFS for updating
|
2020-06-29 11:34:23 -04:00
|
|
|
|
|
|
|
###############################################################
|
|
|
|
# Default Vars that are called in Subs and need to be ignored #
|
|
|
|
###############################################################
|
2020-07-30 16:18:24 -04:00
|
|
|
DEFAULT_DISABLE_ERRORS='false' # Default to enabling errors
|
|
|
|
export DEFAULT_DISABLE_ERRORS # Workaround SC2034
|
|
|
|
RAW_FILE_ARRAY=() # Array of all files that were changed
|
|
|
|
export RAW_FILE_ARRAY # Workaround SC2034
|
|
|
|
READ_ONLY_CHANGE_FLAG=0 # Flag set to 1 if files changed are not txt or md
|
|
|
|
export READ_ONLY_CHANGE_FLAG # Workaround SC2034
|
|
|
|
TEST_CASE_FOLDER='.automation/test' # Folder for test cases we should always ignore
|
|
|
|
export TEST_CASE_FOLDER # Workaround SC2034
|
|
|
|
DEFAULT_ANSIBLE_DIRECTORY="${GITHUB_WORKSPACE}/ansible" # Default Ansible Directory
|
|
|
|
export DEFAULT_ANSIBLE_DIRECTORY # Workaround SC2034
|
|
|
|
WARNING_ARRAY_TEST=() # Array of warning linters that did not have an expected test result.
|
|
|
|
export WARNING_ARRAY_TEST # Workaround SC2034
|
2019-10-21 12:05:55 -04:00
|
|
|
|
2020-06-23 10:25:12 -04:00
|
|
|
##############
|
|
|
|
# Format #
|
|
|
|
##############
|
|
|
|
OUTPUT_FORMAT="${OUTPUT_FORMAT}" # Output format to be generated. Default none
|
|
|
|
OUTPUT_FOLDER="${OUTPUT_FOLDER:-super-linter.report}" # Folder where the reports are generated. Default super-linter.report
|
2020-07-06 13:06:58 -04:00
|
|
|
OUTPUT_DETAILS="${OUTPUT_DETAILS:-simpler}" # What level of details. (simpler or detailed). Default simpler
|
2020-08-18 10:51:38 -04:00
|
|
|
REPORT_OUTPUT_FOLDER="${GITHUB_WORKSPACE}/${OUTPUT_FOLDER}" # Location for the report folder
|
2020-06-23 10:25:12 -04:00
|
|
|
|
2019-10-25 15:22:57 -04:00
|
|
|
##########################
|
|
|
|
# Array of changed files #
|
|
|
|
##########################
|
2020-07-20 15:07:56 -04:00
|
|
|
FILE_ARRAY_ARM=() # Array of files to check
|
2020-07-01 17:40:40 -04:00
|
|
|
FILE_ARRAY_BASH=() # Array of files to check
|
2020-07-22 15:41:37 -04:00
|
|
|
FILE_ARRAY_CLOUDFORMATION=() # Array of files to check
|
2020-07-20 15:07:56 -04:00
|
|
|
FILE_ARRAY_CLOJURE=() # Array of files to check
|
2020-07-01 17:40:40 -04:00
|
|
|
FILE_ARRAY_COFFEESCRIPT=() # Array of files to check
|
2020-08-24 20:43:50 -04:00
|
|
|
FILE_ARRAY_CSHARP=() # Array of files to check
|
2020-07-20 15:07:56 -04:00
|
|
|
FILE_ARRAY_CSS=() # Array of files to check
|
|
|
|
FILE_ARRAY_DART=() # Array of files to check
|
2020-08-04 14:53:32 -04:00
|
|
|
FILE_ARRAY_DOCKERFILE=() # Array of files to check
|
2020-07-20 15:07:56 -04:00
|
|
|
FILE_ARRAY_ENV=() # Array of files to check
|
|
|
|
FILE_ARRAY_GO=() # Array of files to check
|
2020-07-22 12:44:20 -04:00
|
|
|
FILE_ARRAY_GROOVY=() # Array of files to check
|
2020-07-20 15:07:56 -04:00
|
|
|
FILE_ARRAY_HTML=() # Array of files to check
|
2020-07-22 03:10:19 -04:00
|
|
|
FILE_ARRAY_JAVA=() # Array of files to check
|
2020-07-01 17:40:40 -04:00
|
|
|
FILE_ARRAY_JAVASCRIPT_ES=() # Array of files to check
|
|
|
|
FILE_ARRAY_JAVASCRIPT_STANDARD=() # Array of files to check
|
2020-07-20 15:07:56 -04:00
|
|
|
FILE_ARRAY_JSON=() # Array of files to check
|
2020-07-07 11:02:56 -04:00
|
|
|
FILE_ARRAY_JSX=() # Array of files to check
|
2020-07-20 15:07:56 -04:00
|
|
|
FILE_ARRAY_KOTLIN=() # Array of files to check
|
2020-08-18 18:54:32 -04:00
|
|
|
FILE_ARRAY_LATEX=() # Array of files to check
|
2020-07-24 13:27:54 -04:00
|
|
|
FILE_ARRAY_LUA=() # Array of files to check
|
2020-07-21 09:52:30 -04:00
|
|
|
FILE_ARRAY_MARKDOWN=() # Array of files to check
|
2020-07-20 15:07:56 -04:00
|
|
|
FILE_ARRAY_OPENAPI=() # Array of files to check
|
|
|
|
FILE_ARRAY_PERL=() # Array of files to check
|
2020-07-26 15:01:29 -04:00
|
|
|
FILE_ARRAY_PHP_BUILTIN=() # Array of files to check
|
|
|
|
FILE_ARRAY_PHP_PHPCS=() # Array of files to check
|
2020-07-24 14:54:11 -04:00
|
|
|
FILE_ARRAY_PHP_PHPSTAN=() # Array of files to check
|
2020-07-26 15:01:29 -04:00
|
|
|
FILE_ARRAY_PHP_PSALM=() # Array of files to check
|
2020-07-20 15:07:56 -04:00
|
|
|
FILE_ARRAY_POWERSHELL=() # Array of files to check
|
|
|
|
FILE_ARRAY_PROTOBUF=() # Array of files to check
|
2020-08-20 10:44:11 -04:00
|
|
|
FILE_ARRAY_PYTHON_BLACK=() # Array of files to check
|
2020-07-21 20:58:23 -04:00
|
|
|
FILE_ARRAY_PYTHON_PYLINT=() # Array of files to check
|
|
|
|
FILE_ARRAY_PYTHON_FLAKE8=() # Array of files to check
|
2020-08-17 12:27:31 -04:00
|
|
|
FILE_ARRAY_R=() # Array of files to check
|
2020-07-20 15:07:56 -04:00
|
|
|
FILE_ARRAY_RAKU=() # Array of files to check
|
|
|
|
FILE_ARRAY_RUBY=() # Array of files to check
|
2020-07-21 14:50:04 -04:00
|
|
|
FILE_ARRAY_STATES=() # Array of files to check
|
2020-08-06 13:01:36 -04:00
|
|
|
FILE_ARRAY_SQL=() # Array of files to check
|
2020-07-20 15:07:56 -04:00
|
|
|
FILE_ARRAY_TERRAFORM=() # Array of files to check
|
2020-07-07 11:02:56 -04:00
|
|
|
FILE_ARRAY_TSX=() # Array of files to check
|
2020-07-01 17:40:40 -04:00
|
|
|
FILE_ARRAY_TYPESCRIPT_ES=() # Array of files to check
|
|
|
|
FILE_ARRAY_TYPESCRIPT_STANDARD=() # Array of files to check
|
2020-07-20 15:07:56 -04:00
|
|
|
FILE_ARRAY_XML=() # Array of files to check
|
2020-07-24 12:20:22 -04:00
|
|
|
FILE_ARRAY_YAML=() # Array of files to check
|
2019-10-25 15:22:57 -04:00
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
############
|
|
|
|
# Counters #
|
|
|
|
############
|
2020-07-22 16:41:08 -04:00
|
|
|
ERRORS_FOUND_ANSIBLE=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_ANSIBLE # Workaround SC2034
|
|
|
|
ERRORS_FOUND_ARM=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_ARM # Workaround SC2034
|
|
|
|
ERRORS_FOUND_BASH=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_BASH # Workaround SC2034
|
2020-08-28 10:56:53 -04:00
|
|
|
ERRORS_FOUND_BASH_EXEC=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_BASH_EXEC # Workaround SC2034
|
2020-07-22 16:41:08 -04:00
|
|
|
ERRORS_FOUND_CLOUDFORMATION=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_CLOUDFORMATION # Workaround SC2034
|
|
|
|
ERRORS_FOUND_CLOJURE=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_CLOJURE # Workaround SC2034
|
2020-08-24 20:58:25 -04:00
|
|
|
ERRORS_FOUND_CSHARP=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_CSHARP # Workaround SC2034
|
2020-07-22 16:41:08 -04:00
|
|
|
ERRORS_FOUND_CSS=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_CSS # Workaround SC2034
|
|
|
|
ERRORS_FOUND_COFFEESCRIPT=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_COFFEESCRIPT # Workaround SC2034
|
|
|
|
ERRORS_FOUND_DART=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_DART # Workaround SC2034
|
2020-08-04 14:53:32 -04:00
|
|
|
ERRORS_FOUND_DOCKERFILE=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_DOCKERFILE # Workaround SC2034
|
|
|
|
ERRORS_FOUND_DOCKERFILE_HADOLINT=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_DOCKERFILE_HADOLINT # Workaround SC2034
|
2020-08-06 11:25:45 -04:00
|
|
|
ERRORS_FOUND_EDITORCONFIG=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_EDITORCONFIG # Workaround SC2034
|
2020-07-22 16:41:08 -04:00
|
|
|
ERRORS_FOUND_ENV=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_ENV # Workaround SC2034
|
|
|
|
ERRORS_FOUND_GO=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_GO # Workaround SC2034
|
2020-07-23 10:08:35 -04:00
|
|
|
ERRORS_FOUND_GROOVY=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_GROOVY # Workaround SC2034
|
2020-07-22 16:41:08 -04:00
|
|
|
ERRORS_FOUND_HTML=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_HTML # Workaround SC2034
|
2020-08-20 10:44:11 -04:00
|
|
|
ERRORS_FOUND_JAVA=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_JAVA # Workaround SC2034
|
2020-07-22 16:41:08 -04:00
|
|
|
ERRORS_FOUND_JAVASCRIPT_STANDARD=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_JAVASCRIPT_STANDARD # Workaround SC2034
|
|
|
|
ERRORS_FOUND_JAVASCRIPT_ES=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_JAVASCRIPT_ES # Workaround SC2034
|
|
|
|
ERRORS_FOUND_JSON=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_JSON # Workaround SC2034
|
|
|
|
ERRORS_FOUND_JSX=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_JSX # Workaround SC2034
|
|
|
|
ERRORS_FOUND_KOTLIN=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_KOTLIN # Workaround SC2034
|
2020-08-18 18:54:32 -04:00
|
|
|
ERRORS_FOUND_LATEX=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_LATEX=0 # Workaround SC2034
|
2020-07-24 13:27:54 -04:00
|
|
|
ERRORS_FOUND_LUA=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_LUA=0 # Workaround SC2034
|
2020-07-22 16:41:08 -04:00
|
|
|
ERRORS_FOUND_MARKDOWN=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_MARKDOWN # Workaround SC2034
|
|
|
|
ERRORS_FOUND_OPENAPI=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_OPENAPI # Workaround SC2034
|
|
|
|
ERRORS_FOUND_PERL=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_PERL # Workaround SC2034
|
2020-07-26 15:01:29 -04:00
|
|
|
ERRORS_FOUND_PHP_BUILTIN=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_PHP_BUILTIN # Workaround SC2034
|
|
|
|
ERRORS_FOUND_PHP_PHPCS=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_PHP_PHPCS # Workaround SC2034
|
2020-07-24 14:54:11 -04:00
|
|
|
ERRORS_FOUND_PHP_PHPSTAN=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_PHP_PHPSTAN # Workaround SC2034
|
2020-07-26 15:01:29 -04:00
|
|
|
ERRORS_FOUND_PHP_PSALM=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_PHP_PSALM # Workaround SC2034
|
2020-07-22 16:41:08 -04:00
|
|
|
ERRORS_FOUND_POWERSHELL=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_POWERSHELL # Workaround SC2034
|
|
|
|
ERRORS_FOUND_PROTOBUF=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_PROTOBUF # Workaround SC2034
|
2020-08-20 10:44:11 -04:00
|
|
|
ERRORS_FOUND_PYTHON_BLACK=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_PYTHON_BLACK # Workaround SC2034
|
2020-07-21 20:58:23 -04:00
|
|
|
ERRORS_FOUND_PYTHON_PYLINT=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_PYTHON_PYLINT # Workaround SC2034
|
|
|
|
ERRORS_FOUND_PYTHON_FLAKE8=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_PYTHON_FLAKE8 # Workaround SC2034
|
2020-08-15 15:29:22 -04:00
|
|
|
ERRORS_FOUND_R=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_R # Workaround SC2034
|
2020-07-22 16:41:08 -04:00
|
|
|
ERRORS_FOUND_RAKU=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_RAKU # Workaround SC2034
|
|
|
|
ERRORS_FOUND_RUBY=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_RUBY # Workaround SC2034
|
2020-08-31 18:06:15 -04:00
|
|
|
ERRORS_FOUND_SHELL_SHFMT=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_SHELL_SHFMT
|
2020-07-22 16:41:08 -04:00
|
|
|
ERRORS_FOUND_STATES=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_STATES # Workaround SC2034
|
2020-08-06 13:01:36 -04:00
|
|
|
ERRORS_FOUND_SQL=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_SQL # Workaround SC2034
|
2020-07-22 16:41:08 -04:00
|
|
|
ERRORS_FOUND_TERRAFORM=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_TERRAFORM # Workaround SC2034
|
2020-07-22 21:40:43 -04:00
|
|
|
ERRORS_FOUND_TERRAFORM_TERRASCAN=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_TERRAFORM_TERRASCAN # Workaround SC2034
|
2020-07-22 16:41:08 -04:00
|
|
|
ERRORS_FOUND_TSX=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_TSX # Workaround SC2034
|
|
|
|
ERRORS_FOUND_TYPESCRIPT_STANDARD=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_TYPESCRIPT_STANDARD # Workaround SC2034
|
|
|
|
ERRORS_FOUND_TYPESCRIPT_ES=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_TYPESCRIPT_ES # Workaround SC2034
|
|
|
|
ERRORS_FOUND_XML=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_XML # Workaround SC2034
|
2020-07-24 12:20:22 -04:00
|
|
|
ERRORS_FOUND_YAML=0 # Count of errors found
|
|
|
|
export ERRORS_FOUND_YAML # Workaround SC2034
|
2019-10-21 15:12:37 -04:00
|
|
|
|
2019-10-21 10:12:50 -04:00
|
|
|
################################################################################
|
2019-10-21 12:05:55 -04:00
|
|
|
########################## FUNCTIONS BELOW #####################################
|
2019-10-21 10:12:50 -04:00
|
|
|
################################################################################
|
|
|
|
################################################################################
|
2019-10-21 12:05:55 -04:00
|
|
|
#### Function Header ###########################################################
|
2020-07-01 17:40:40 -04:00
|
|
|
Header() {
|
2020-05-06 11:03:06 -04:00
|
|
|
###############################
|
|
|
|
# Give them the possum action #
|
|
|
|
###############################
|
2020-05-06 11:27:45 -04:00
|
|
|
/bin/bash /action/lib/possum.sh
|
2020-05-06 11:03:06 -04:00
|
|
|
|
|
|
|
##########
|
|
|
|
# Prints #
|
|
|
|
##########
|
2020-07-30 16:39:05 -04:00
|
|
|
info "---------------------------------------------"
|
|
|
|
info "--- GitHub Actions Multi Language Linter ----"
|
2020-09-04 04:09:20 -04:00
|
|
|
info " created date: ${BUILD_DATE}"
|
|
|
|
info " revision: ${BUILD_REVISION}"
|
|
|
|
info " version: ${BUILD_VERSION}"
|
2020-07-30 16:39:05 -04:00
|
|
|
info "---------------------------------------------"
|
|
|
|
info "---------------------------------------------"
|
|
|
|
info "The Super-Linter source code can be found at:"
|
|
|
|
info " - https://github.com/github/super-linter"
|
|
|
|
info "---------------------------------------------"
|
2019-10-21 12:05:55 -04:00
|
|
|
}
|
|
|
|
################################################################################
|
2020-01-08 14:34:05 -05:00
|
|
|
#### Function GetLinterVersions ################################################
|
2020-07-01 17:40:40 -04:00
|
|
|
GetLinterVersions() {
|
2020-01-08 14:34:05 -05:00
|
|
|
#########################
|
|
|
|
# Print version headers #
|
|
|
|
#########################
|
2020-07-30 16:39:05 -04:00
|
|
|
debug "---------------------------------------------"
|
|
|
|
debug "Linter Version Info:"
|
2020-01-08 14:34:05 -05:00
|
|
|
|
2020-09-03 10:12:49 -04:00
|
|
|
################################
|
|
|
|
# Cat the linter versions file #
|
|
|
|
################################
|
2020-09-03 11:12:29 -04:00
|
|
|
CAT_CMD=$(cat "${VERSION_FILE}" 2>&1)
|
2020-01-08 14:34:05 -05:00
|
|
|
|
2020-09-03 10:12:49 -04:00
|
|
|
#######################
|
|
|
|
# Load the error code #
|
|
|
|
#######################
|
|
|
|
ERROR_CODE=$?
|
2020-01-08 14:34:05 -05:00
|
|
|
|
2020-09-03 10:12:49 -04:00
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
|
|
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
|
|
|
# Failure
|
|
|
|
warn "Failed to view version file:[${VERSION_FILE}]"
|
|
|
|
else
|
|
|
|
# Success
|
2020-09-03 11:12:29 -04:00
|
|
|
debug "${CAT_CMD}"
|
2020-09-03 10:12:49 -04:00
|
|
|
fi
|
2020-07-06 09:18:09 -04:00
|
|
|
|
2020-07-02 17:31:16 -04:00
|
|
|
#########################
|
|
|
|
# Print version footers #
|
|
|
|
#########################
|
2020-07-30 16:39:05 -04:00
|
|
|
debug "---------------------------------------------"
|
2020-01-08 14:34:05 -05:00
|
|
|
}
|
|
|
|
################################################################################
|
2019-10-21 12:05:55 -04:00
|
|
|
#### Function GetLinterRules ###################################################
|
2020-07-01 17:40:40 -04:00
|
|
|
GetLinterRules() {
|
2019-10-21 12:05:55 -04:00
|
|
|
# Need to validate the rules files exist
|
2020-02-03 11:27:40 -05:00
|
|
|
|
|
|
|
################
|
|
|
|
# Pull in vars #
|
|
|
|
################
|
2020-07-21 13:09:07 -04:00
|
|
|
LANGUAGE_NAME="${1}" # Name of the language were looking for
|
2020-07-01 10:45:55 -04:00
|
|
|
|
|
|
|
#######################################################
|
|
|
|
# Need to create the variables for the real variables #
|
|
|
|
#######################################################
|
|
|
|
LANGUAGE_FILE_NAME="${LANGUAGE_NAME}_FILE_NAME"
|
|
|
|
LANGUAGE_LINTER_RULES="${LANGUAGE_NAME}_LINTER_RULES"
|
2020-02-03 11:27:40 -05:00
|
|
|
|
2020-08-06 11:30:10 -04:00
|
|
|
##########################
|
|
|
|
# Get the file extension #
|
|
|
|
##########################
|
|
|
|
FILE_EXTENSION=$(echo "${!LANGUAGE_FILE_NAME}" | rev | cut -d'.' -f1 | rev)
|
|
|
|
FILE_NAME=$(echo "${!LANGUAGE_FILE_NAME}" | rev | cut -d'.' -f2 | rev)
|
|
|
|
|
|
|
|
###############################
|
|
|
|
# Set the secondary file name #
|
|
|
|
###############################
|
|
|
|
SECONDARY_FILE_NAME=''
|
|
|
|
|
|
|
|
#################################
|
|
|
|
# Check for secondary file name #
|
|
|
|
#################################
|
|
|
|
if [[ $FILE_EXTENSION == 'yml' ]]; then
|
|
|
|
# Need to see if yaml also exists
|
|
|
|
SECONDARY_FILE_NAME="$FILE_NAME.yaml"
|
|
|
|
elif [[ $FILE_EXTENSION == 'yaml' ]]; then
|
|
|
|
# need to see if yml also exists
|
|
|
|
SECONDARY_FILE_NAME="$FILE_NAME.yml"
|
|
|
|
fi
|
|
|
|
|
2020-02-03 11:27:40 -05:00
|
|
|
#####################################
|
|
|
|
# Validate we have the linter rules #
|
|
|
|
#####################################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ -f "${GITHUB_WORKSPACE}/${LINTER_RULES_PATH}/${!LANGUAGE_FILE_NAME}" ]; then
|
2020-07-30 16:39:05 -04:00
|
|
|
info "----------------------------------------------"
|
|
|
|
info "User provided file:[${!LANGUAGE_FILE_NAME}], setting rules file..."
|
2019-10-22 13:21:42 -04:00
|
|
|
|
2020-07-01 10:45:55 -04:00
|
|
|
########################################
|
|
|
|
# Update the path to the file location #
|
|
|
|
########################################
|
2020-07-21 13:09:07 -04:00
|
|
|
eval "${LANGUAGE_LINTER_RULES}=${GITHUB_WORKSPACE}/${LINTER_RULES_PATH}/${!LANGUAGE_FILE_NAME}"
|
2019-10-23 10:51:13 -04:00
|
|
|
else
|
2020-08-06 11:30:10 -04:00
|
|
|
# Check if we have secondary name to check
|
|
|
|
if [ -n "$SECONDARY_FILE_NAME" ]; then
|
|
|
|
# We have a secondary name to validate
|
|
|
|
if [ -f "${GITHUB_WORKSPACE}/${LINTER_RULES_PATH}/${SECONDARY_FILE_NAME}" ]; then
|
|
|
|
info "----------------------------------------------"
|
|
|
|
info "User provided file:[${SECONDARY_FILE_NAME}], setting rules file..."
|
|
|
|
|
|
|
|
########################################
|
|
|
|
# Update the path to the file location #
|
|
|
|
########################################
|
|
|
|
eval "${LANGUAGE_LINTER_RULES}=${GITHUB_WORKSPACE}/${LINTER_RULES_PATH}/${SECONDARY_FILE_NAME}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
########################################################
|
|
|
|
# No user default provided, using the template default #
|
|
|
|
########################################################
|
|
|
|
debug " -> Codebase does NOT have file:[${LINTER_RULES_PATH}/${!LANGUAGE_FILE_NAME}], using Default rules at:[${!LANGUAGE_LINTER_RULES}]"
|
2019-10-22 13:21:42 -04:00
|
|
|
fi
|
2020-02-03 11:27:40 -05:00
|
|
|
}
|
|
|
|
################################################################################
|
|
|
|
#### Function GetStandardRules #################################################
|
2020-07-01 17:40:40 -04:00
|
|
|
GetStandardRules() {
|
2020-04-02 13:42:07 -04:00
|
|
|
################
|
|
|
|
# Pull In Vars #
|
|
|
|
################
|
2020-07-21 13:09:07 -04:00
|
|
|
LINTER="${1}" # Type: javascript | typescript
|
2020-04-02 13:42:07 -04:00
|
|
|
|
2020-02-03 11:27:40 -05:00
|
|
|
#########################################################################
|
|
|
|
# Need to get the ENV vars from the linter rules to run in command line #
|
|
|
|
#########################################################################
|
|
|
|
# Copy orig IFS to var
|
2020-07-21 13:09:07 -04:00
|
|
|
ORIG_IFS="${IFS}"
|
2020-02-03 11:27:40 -05:00
|
|
|
# Set the IFS to newline
|
|
|
|
IFS=$'\n'
|
2019-11-06 16:45:44 -05:00
|
|
|
|
2020-02-03 11:27:40 -05:00
|
|
|
#########################################
|
|
|
|
# Get list of all environment variables #
|
|
|
|
#########################################
|
|
|
|
# Only env vars that are marked as true
|
2020-04-02 13:42:07 -04:00
|
|
|
GET_ENV_ARRAY=()
|
2020-07-21 13:09:07 -04:00
|
|
|
if [[ ${LINTER} == "javascript" ]]; then
|
|
|
|
mapfile -t GET_ENV_ARRAY < <(yq .env "${JAVASCRIPT_LINTER_RULES}" | grep true)
|
|
|
|
elif [[ ${LINTER} == "typescript" ]]; then
|
|
|
|
mapfile -t GET_ENV_ARRAY < <(yq .env "${TYPESCRIPT_LINTER_RULES}" | grep true)
|
2020-04-02 13:42:07 -04:00
|
|
|
fi
|
2019-11-06 16:45:44 -05:00
|
|
|
|
2020-02-03 11:27:40 -05:00
|
|
|
#######################
|
|
|
|
# Load the error code #
|
|
|
|
#######################
|
|
|
|
ERROR_CODE=$?
|
2019-11-06 16:45:44 -05:00
|
|
|
|
2020-02-03 11:27:40 -05:00
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
2020-02-03 11:27:40 -05:00
|
|
|
# ERROR
|
2020-07-30 16:39:05 -04:00
|
|
|
error "Failed to gain list of ENV vars to load!"
|
|
|
|
fatal "[${GET_ENV_ARRAY[*]}]"
|
2019-11-06 16:45:44 -05:00
|
|
|
fi
|
2020-01-10 14:33:28 -05:00
|
|
|
|
2020-02-03 11:27:40 -05:00
|
|
|
##########################
|
|
|
|
# Set IFS back to normal #
|
|
|
|
##########################
|
|
|
|
# Set IFS back to Orig
|
2020-07-21 13:09:07 -04:00
|
|
|
IFS="${ORIG_IFS}"
|
2020-01-10 14:33:28 -05:00
|
|
|
|
2020-02-03 11:27:40 -05:00
|
|
|
######################
|
|
|
|
# Set the env string #
|
|
|
|
######################
|
|
|
|
ENV_STRING=''
|
2020-01-10 14:33:28 -05:00
|
|
|
|
2020-02-03 11:27:40 -05:00
|
|
|
#############################
|
|
|
|
# Pull out the envs to load #
|
|
|
|
#############################
|
2020-07-01 17:40:40 -04:00
|
|
|
for ENV in "${GET_ENV_ARRAY[@]}"; do
|
2020-02-03 11:27:40 -05:00
|
|
|
#############################
|
|
|
|
# remove spaces from return #
|
|
|
|
#############################
|
|
|
|
ENV="$(echo -e "${ENV}" | tr -d '[:space:]')"
|
|
|
|
################################
|
|
|
|
# Get the env to add to string #
|
|
|
|
################################
|
|
|
|
ENV="$(echo "${ENV}" | cut -d'"' -f2)"
|
2020-07-30 16:39:05 -04:00
|
|
|
debug "ENV:[${ENV}]"
|
2020-02-03 11:27:40 -05:00
|
|
|
ENV_STRING+="--env ${ENV} "
|
|
|
|
done
|
2020-01-10 14:33:28 -05:00
|
|
|
|
2020-06-21 00:03:30 -04:00
|
|
|
#########################################
|
|
|
|
# Remove trailing and ending whitespace #
|
|
|
|
#########################################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [[ ${LINTER} == "javascript" ]]; then
|
2020-04-02 13:42:07 -04:00
|
|
|
JAVASCRIPT_STANDARD_LINTER_RULES="$(echo -e "${ENV_STRING}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
|
2020-07-21 13:09:07 -04:00
|
|
|
elif [[ ${LINTER} == "typescript" ]]; then
|
2020-04-02 13:42:07 -04:00
|
|
|
TYPESCRIPT_STANDARD_LINTER_RULES="$(echo -e "${ENV_STRING}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
|
|
|
|
fi
|
2019-10-21 12:05:55 -04:00
|
|
|
}
|
2020-06-25 02:13:19 -04:00
|
|
|
################################################################################
|
|
|
|
#### Function DetectOpenAPIFile ################################################
|
2020-07-01 17:40:40 -04:00
|
|
|
DetectOpenAPIFile() {
|
2020-06-26 09:26:36 -04:00
|
|
|
################
|
|
|
|
# Pull in vars #
|
|
|
|
################
|
2020-07-21 13:09:07 -04:00
|
|
|
FILE="${1}"
|
2020-06-26 09:26:36 -04:00
|
|
|
|
|
|
|
###############################
|
|
|
|
# Check the file for keywords #
|
|
|
|
###############################
|
2020-07-21 13:09:07 -04:00
|
|
|
grep -E '"openapi":|"swagger":|^openapi:|^swagger:' "${FILE}" > /dev/null
|
2020-06-26 09:26:36 -04:00
|
|
|
|
|
|
|
#######################
|
|
|
|
# Load the error code #
|
|
|
|
#######################
|
|
|
|
ERROR_CODE=$?
|
|
|
|
|
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ ${ERROR_CODE} -eq 0 ]; then
|
2020-06-26 09:26:36 -04:00
|
|
|
########################
|
|
|
|
# Found string in file #
|
|
|
|
########################
|
2020-07-01 17:40:40 -04:00
|
|
|
return 0
|
2020-06-25 02:13:19 -04:00
|
|
|
else
|
2020-06-26 09:26:36 -04:00
|
|
|
###################
|
|
|
|
# No string match #
|
|
|
|
###################
|
2020-07-01 17:40:40 -04:00
|
|
|
return 1
|
2020-06-25 02:13:19 -04:00
|
|
|
fi
|
|
|
|
}
|
2020-06-29 15:38:24 -04:00
|
|
|
################################################################################
|
2020-07-06 09:18:09 -04:00
|
|
|
#### Function DetectARMFile ####################################################
|
2020-07-06 09:29:36 -04:00
|
|
|
DetectARMFile() {
|
2020-07-02 17:31:16 -04:00
|
|
|
################
|
|
|
|
# Pull in vars #
|
|
|
|
################
|
2020-07-21 13:09:07 -04:00
|
|
|
FILE="${1}" # Name of the file/path we are validating
|
2020-07-02 17:31:16 -04:00
|
|
|
|
|
|
|
###############################
|
|
|
|
# Check the file for keywords #
|
|
|
|
###############################
|
2020-07-21 13:09:07 -04:00
|
|
|
grep -E 'schema.management.azure.com' "${FILE}" > /dev/null
|
2020-07-02 17:31:16 -04:00
|
|
|
|
|
|
|
#######################
|
|
|
|
# Load the error code #
|
|
|
|
#######################
|
|
|
|
ERROR_CODE=$?
|
|
|
|
|
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ ${ERROR_CODE} -eq 0 ]; then
|
2020-07-02 17:31:16 -04:00
|
|
|
########################
|
|
|
|
# Found string in file #
|
|
|
|
########################
|
2020-07-06 09:18:09 -04:00
|
|
|
return 0
|
2020-07-02 17:31:16 -04:00
|
|
|
else
|
|
|
|
###################
|
|
|
|
# No string match #
|
|
|
|
###################
|
2020-07-06 09:18:09 -04:00
|
|
|
return 1
|
2020-07-02 17:31:16 -04:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
################################################################################
|
2020-06-19 12:41:19 -04:00
|
|
|
#### Function DetectCloudFormationFile #########################################
|
2020-07-01 17:40:40 -04:00
|
|
|
DetectCloudFormationFile() {
|
2020-06-29 15:49:20 -04:00
|
|
|
################
|
|
|
|
# Pull in Vars #
|
|
|
|
################
|
2020-07-21 13:09:07 -04:00
|
|
|
FILE="${1}" # File that we need to validate
|
2020-06-29 15:49:20 -04:00
|
|
|
|
2020-06-29 15:38:24 -04:00
|
|
|
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-formats.html
|
2020-06-26 15:43:44 -04:00
|
|
|
# AWSTemplateFormatVersion is optional
|
2020-06-29 15:49:20 -04:00
|
|
|
#######################################
|
|
|
|
# Check if file has AWS Template info #
|
|
|
|
#######################################
|
2020-07-23 11:18:54 -04:00
|
|
|
if grep -q 'AWSTemplateFormatVersion' "${FILE}" > /dev/null; then
|
2020-06-29 15:49:20 -04:00
|
|
|
# Found it
|
2020-06-19 12:41:19 -04:00
|
|
|
return 0
|
|
|
|
fi
|
2020-06-29 15:49:20 -04:00
|
|
|
|
2020-07-23 11:18:54 -04:00
|
|
|
#####################################
|
|
|
|
# See if it contains AWS References #
|
|
|
|
#####################################
|
|
|
|
if grep -q -E '(AWS|Alexa|Custom)::' "${FILE}" > /dev/null; then
|
2020-06-29 15:49:20 -04:00
|
|
|
# Found it
|
2020-06-26 15:43:44 -04:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
2020-07-22 15:07:08 -04:00
|
|
|
#####################################################
|
|
|
|
# No identifiers of a CLOUDFORMATION template found #
|
|
|
|
#####################################################
|
2020-06-26 15:43:44 -04:00
|
|
|
return 1
|
2020-06-19 12:41:19 -04:00
|
|
|
}
|
2020-07-21 14:50:04 -04:00
|
|
|
################################################################################
|
|
|
|
#### Function DetectAWSStatesFIle ##############################################
|
|
|
|
DetectAWSStatesFIle() {
|
|
|
|
################
|
|
|
|
# Pull in Vars #
|
|
|
|
################
|
2020-07-21 15:39:14 -04:00
|
|
|
FILE="${1}" # File that we need to validate
|
2020-06-19 12:41:19 -04:00
|
|
|
|
2020-07-21 14:50:04 -04:00
|
|
|
# https://states-language.net/spec.html#example
|
2020-06-29 15:49:20 -04:00
|
|
|
###############################
|
|
|
|
# check if file has resources #
|
|
|
|
###############################
|
2020-07-21 15:39:14 -04:00
|
|
|
if grep '"Resource": *"arn"*' "${FILE}"; then
|
2020-06-29 15:49:20 -04:00
|
|
|
# Found it
|
2020-06-26 15:43:44 -04:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
2020-07-21 14:50:04 -04:00
|
|
|
#################################################
|
|
|
|
# No identifiers of a AWS States Language found #
|
|
|
|
#################################################
|
2020-06-26 15:43:44 -04:00
|
|
|
return 1
|
2020-06-19 12:41:19 -04:00
|
|
|
}
|
2020-01-09 17:08:01 -05:00
|
|
|
################################################################################
|
2019-10-21 15:12:37 -04:00
|
|
|
#### Function GetGitHubVars ####################################################
|
2020-07-01 17:40:40 -04:00
|
|
|
GetGitHubVars() {
|
2019-10-21 15:12:37 -04:00
|
|
|
##########
|
|
|
|
# Prints #
|
|
|
|
##########
|
2020-07-30 16:39:05 -04:00
|
|
|
info "--------------------------------------------"
|
|
|
|
info "Gathering GitHub information..."
|
2019-10-21 15:12:37 -04:00
|
|
|
|
2020-02-04 12:49:07 -05:00
|
|
|
###############################
|
|
|
|
# Get the Run test cases flag #
|
|
|
|
###############################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ -z "${TEST_CASE_RUN}" ]; then
|
2020-02-04 12:49:07 -05:00
|
|
|
##################################
|
|
|
|
# No flag passed, set to default #
|
|
|
|
##################################
|
2020-07-21 13:09:07 -04:00
|
|
|
TEST_CASE_RUN="${DEFAULT_TEST_CASE_RUN}"
|
2020-02-04 12:49:07 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
###############################
|
|
|
|
# Convert string to lowercase #
|
|
|
|
###############################
|
2020-07-21 12:09:05 -04:00
|
|
|
TEST_CASE_RUN="${TEST_CASE_RUN,,}"
|
2020-02-04 12:49:07 -05:00
|
|
|
|
2020-01-09 11:29:18 -05:00
|
|
|
##########################
|
|
|
|
# Get the run local flag #
|
|
|
|
##########################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ -z "${RUN_LOCAL}" ]; then
|
2020-01-09 11:29:18 -05:00
|
|
|
##################################
|
|
|
|
# No flag passed, set to default #
|
|
|
|
##################################
|
2020-07-21 13:09:07 -04:00
|
|
|
RUN_LOCAL="${DEFAULT_RUN_LOCAL}"
|
2019-10-21 15:12:37 -04:00
|
|
|
fi
|
|
|
|
|
2020-01-09 11:29:18 -05:00
|
|
|
###############################
|
|
|
|
# Convert string to lowercase #
|
|
|
|
###############################
|
2020-07-21 12:09:05 -04:00
|
|
|
RUN_LOCAL="${RUN_LOCAL,,}"
|
2020-02-04 12:49:07 -05:00
|
|
|
|
2020-01-09 11:29:18 -05:00
|
|
|
#################################
|
|
|
|
# Check if were running locally #
|
|
|
|
#################################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [[ ${RUN_LOCAL} != "false" ]]; then
|
2020-01-09 11:29:18 -05:00
|
|
|
##########################################
|
|
|
|
# We are running locally for a debug run #
|
|
|
|
##########################################
|
2020-07-30 16:39:05 -04:00
|
|
|
info "NOTE: ENV VAR [RUN_LOCAL] has been set to:[true]"
|
|
|
|
info "bypassing GitHub Actions variables..."
|
2020-06-19 13:31:53 -04:00
|
|
|
|
|
|
|
############################
|
|
|
|
# Set the GITHUB_WORKSPACE #
|
|
|
|
############################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ -z "${GITHUB_WORKSPACE}" ]; then
|
|
|
|
GITHUB_WORKSPACE="${DEFAULT_WORKSPACE}"
|
2020-06-19 13:31:53 -04:00
|
|
|
fi
|
2020-06-29 10:55:59 -04:00
|
|
|
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ ! -d "${GITHUB_WORKSPACE}" ]; then
|
2020-07-30 16:39:05 -04:00
|
|
|
fatal "Provided volume is not a directory!"
|
2020-07-06 17:57:30 -04:00
|
|
|
fi
|
|
|
|
|
2020-08-18 10:51:38 -04:00
|
|
|
################################
|
|
|
|
# Set the report output folder #
|
|
|
|
################################
|
|
|
|
REPORT_OUTPUT_FOLDER="${DEFAULT_WORKSPACE}/${OUTPUT_FOLDER}"
|
|
|
|
|
2020-07-30 16:39:05 -04:00
|
|
|
info "Linting all files in mapped directory:[${DEFAULT_WORKSPACE}]"
|
2020-01-09 11:29:18 -05:00
|
|
|
|
|
|
|
# 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 VALIDATE_ALL_CODEBASE #
|
|
|
|
#################################
|
2020-07-21 13:09:07 -04:00
|
|
|
VALIDATE_ALL_CODEBASE="${DEFAULT_VALIDATE_ALL_CODEBASE}"
|
2019-10-21 15:12:37 -04:00
|
|
|
else
|
2020-01-09 11:29:18 -05:00
|
|
|
############################
|
|
|
|
# Validate we have a value #
|
|
|
|
############################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ -z "${GITHUB_SHA}" ]; then
|
2020-07-30 16:39:05 -04:00
|
|
|
error "Failed to get [GITHUB_SHA]!"
|
|
|
|
fatal "[${GITHUB_SHA}]"
|
2020-01-09 11:29:18 -05:00
|
|
|
else
|
2020-07-30 16:39:05 -04:00
|
|
|
info "Successfully found:${F[W]}[GITHUB_SHA]${F[B]}, value:${F[W]}[${GITHUB_SHA}]"
|
2020-01-09 11:29:18 -05:00
|
|
|
fi
|
2019-10-21 15:12:37 -04:00
|
|
|
|
2020-01-09 11:29:18 -05:00
|
|
|
############################
|
|
|
|
# Validate we have a value #
|
|
|
|
############################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ -z "${GITHUB_WORKSPACE}" ]; then
|
2020-07-30 16:39:05 -04:00
|
|
|
error "Failed to get [GITHUB_WORKSPACE]!"
|
|
|
|
fatal "[${GITHUB_WORKSPACE}]"
|
2020-01-09 11:29:18 -05:00
|
|
|
else
|
2020-07-30 16:39:05 -04:00
|
|
|
info "Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[${GITHUB_WORKSPACE}]"
|
2020-01-09 11:29:18 -05:00
|
|
|
fi
|
2019-10-21 15:12:37 -04:00
|
|
|
|
2020-01-09 11:29:18 -05:00
|
|
|
############################
|
|
|
|
# Validate we have a value #
|
|
|
|
############################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ -z "${GITHUB_EVENT_PATH}" ]; then
|
2020-07-30 16:39:05 -04:00
|
|
|
error "Failed to get [GITHUB_EVENT_PATH]!"
|
|
|
|
fatal "[${GITHUB_EVENT_PATH}]"
|
2020-01-09 11:29:18 -05:00
|
|
|
else
|
2020-07-30 16:39:05 -04:00
|
|
|
info "Successfully found:${F[W]}[GITHUB_EVENT_PATH]${F[B]}, value:${F[W]}[${GITHUB_EVENT_PATH}]${F[B]}"
|
2020-01-09 11:29:18 -05:00
|
|
|
fi
|
2019-10-21 15:12:37 -04:00
|
|
|
|
2020-01-09 11:29:18 -05:00
|
|
|
##################################################
|
|
|
|
# Need to pull the GitHub Vars from the env file #
|
|
|
|
##################################################
|
|
|
|
|
|
|
|
######################
|
|
|
|
# Get the GitHub Org #
|
|
|
|
######################
|
2020-07-21 13:09:07 -04:00
|
|
|
GITHUB_ORG=$(jq -r '.repository.owner.login' < "${GITHUB_EVENT_PATH}")
|
2020-01-09 11:29:18 -05:00
|
|
|
|
|
|
|
############################
|
|
|
|
# Validate we have a value #
|
|
|
|
############################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ -z "${GITHUB_ORG}" ]; then
|
2020-07-30 16:39:05 -04:00
|
|
|
error "Failed to get [GITHUB_ORG]!"
|
|
|
|
fatal "[${GITHUB_ORG}]"
|
2020-01-09 11:29:18 -05:00
|
|
|
else
|
2020-07-30 16:39:05 -04:00
|
|
|
info "Successfully found:${F[W]}[GITHUB_ORG]${F[B]}, value:${F[W]}[${GITHUB_ORG}]"
|
2020-01-09 11:29:18 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
#######################
|
|
|
|
# Get the GitHub Repo #
|
|
|
|
#######################
|
2020-07-21 13:09:07 -04:00
|
|
|
GITHUB_REPO=$(jq -r '.repository.name' < "${GITHUB_EVENT_PATH}")
|
2020-01-09 11:29:18 -05:00
|
|
|
|
|
|
|
############################
|
|
|
|
# Validate we have a value #
|
|
|
|
############################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ -z "${GITHUB_REPO}" ]; then
|
2020-07-30 16:39:05 -04:00
|
|
|
error "Failed to get [GITHUB_REPO]!"
|
|
|
|
fatal "[${GITHUB_REPO}]"
|
2020-01-09 11:29:18 -05:00
|
|
|
else
|
2020-07-30 16:39:05 -04:00
|
|
|
info "Successfully found:${F[W]}[GITHUB_REPO]${F[B]}, value:${F[W]}[${GITHUB_REPO}]"
|
2020-01-09 11:29:18 -05:00
|
|
|
fi
|
2019-10-21 15:12:37 -04:00
|
|
|
fi
|
2020-07-20 15:07:56 -04:00
|
|
|
|
|
|
|
############################
|
|
|
|
# Validate we have a value #
|
|
|
|
############################
|
2020-07-22 12:59:46 -04:00
|
|
|
if [ -z "${GITHUB_TOKEN}" ] && [[ ${RUN_LOCAL} == "false" ]]; then
|
2020-07-30 16:39:05 -04:00
|
|
|
error "Failed to get [GITHUB_TOKEN]!"
|
|
|
|
error "[${GITHUB_TOKEN}]"
|
|
|
|
error "Please set a [GITHUB_TOKEN] from the main workflow environment to take advantage of multiple status reports!"
|
2020-07-21 11:21:08 -04:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Need to set MULTI_STATUS to false as we cant hit API endpoints without token #
|
|
|
|
################################################################################
|
|
|
|
MULTI_STATUS='false'
|
2020-07-20 15:07:56 -04:00
|
|
|
else
|
2020-07-30 16:39:05 -04:00
|
|
|
info "Successfully found:${F[W]}[GITHUB_TOKEN]"
|
2020-07-20 15:07:56 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
###############################
|
|
|
|
# Convert string to lowercase #
|
|
|
|
###############################
|
2020-07-21 12:09:05 -04:00
|
|
|
MULTI_STATUS="${MULTI_STATUS,,}"
|
2020-07-20 15:07:56 -04:00
|
|
|
|
|
|
|
#######################################################################
|
|
|
|
# Check to see if the multi status is set, and we have a token to use #
|
|
|
|
#######################################################################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ "${MULTI_STATUS}" == "true" ] && [ -n "${GITHUB_TOKEN}" ]; then
|
2020-07-20 15:07:56 -04:00
|
|
|
############################
|
|
|
|
# Validate we have a value #
|
|
|
|
############################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ -z "${GITHUB_REPOSITORY}" ]; then
|
2020-07-30 16:39:05 -04:00
|
|
|
error "Failed to get [GITHUB_REPOSITORY]!"
|
|
|
|
fatal "[${GITHUB_REPOSITORY}]"
|
2020-07-20 15:07:56 -04:00
|
|
|
else
|
2020-07-30 16:39:05 -04:00
|
|
|
info "Successfully found:${F[W]}[GITHUB_REPOSITORY]${F[B]}, value:${F[W]}[${GITHUB_REPOSITORY}]"
|
2020-07-20 15:07:56 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
############################
|
|
|
|
# Validate we have a value #
|
|
|
|
############################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ -z "${GITHUB_RUN_ID}" ]; then
|
2020-07-30 16:39:05 -04:00
|
|
|
error "Failed to get [GITHUB_RUN_ID]!"
|
|
|
|
fatal "[${GITHUB_RUN_ID}]"
|
2020-01-09 11:29:18 -05:00
|
|
|
else
|
2020-07-30 16:39:05 -04:00
|
|
|
info "Successfully found:${F[W]}[GITHUB_RUN_ID]${F[B]}, value:${F[W]}[${GITHUB_RUN_ID}]"
|
2020-01-09 11:29:18 -05:00
|
|
|
fi
|
2019-10-21 15:12:37 -04:00
|
|
|
fi
|
2020-04-27 13:21:38 -04:00
|
|
|
}
|
|
|
|
################################################################################
|
2020-07-01 08:49:17 -04:00
|
|
|
#### Function ValidatePowershellModules ########################################
|
2020-07-01 17:40:40 -04:00
|
|
|
function ValidatePowershellModules() {
|
2020-07-01 08:49:17 -04:00
|
|
|
VALIDATE_PSSA_MODULE=$(pwsh -c "(Get-Module -Name PSScriptAnalyzer -ListAvailable | Select-Object -First 1).Name" 2>&1)
|
|
|
|
# If module found, ensure Invoke-ScriptAnalyzer command is available
|
2020-07-21 13:09:07 -04:00
|
|
|
if [[ ${VALIDATE_PSSA_MODULE} == "PSScriptAnalyzer" ]]; then
|
2020-07-01 08:49:17 -04:00
|
|
|
VALIDATE_PSSA_CMD=$(pwsh -c "(Get-Command Invoke-ScriptAnalyzer | Select-Object -First 1).Name" 2>&1)
|
|
|
|
else
|
2020-07-30 16:39:05 -04:00
|
|
|
fatal "Failed to find module."
|
2020-07-01 08:49:17 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
#########################################
|
|
|
|
# validate we found the script analyzer #
|
|
|
|
#########################################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [[ ${VALIDATE_PSSA_CMD} != "Invoke-ScriptAnalyzer" ]]; then
|
2020-07-30 16:39:05 -04:00
|
|
|
fatal "Failed to find module."
|
2020-07-01 08:49:17 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
#######################
|
|
|
|
# Load the error code #
|
|
|
|
#######################
|
|
|
|
ERROR_CODE=$?
|
|
|
|
|
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
2020-07-01 08:49:17 -04:00
|
|
|
# Failed
|
2020-07-30 16:39:05 -04:00
|
|
|
error "Failed find module [PSScriptAnalyzer] for [${LINTER_NAME}] in system!"
|
|
|
|
fatal "[PSSA_MODULE ${VALIDATE_PSSA_MODULE}] [PSSA_CMD ${VALIDATE_PSSA_CMD}]"
|
2020-07-01 08:49:17 -04:00
|
|
|
else
|
|
|
|
# Success
|
2020-07-30 16:39:05 -04:00
|
|
|
debug "Successfully found module ${F[W]}[${VALIDATE_PSSA_MODULE}]${F[B]} in system"
|
|
|
|
debug "Successfully found command ${F[W]}[${VALIDATE_PSSA_CMD}]${F[B]} in system"
|
2020-07-01 08:49:17 -04:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
################################################################################
|
2020-07-20 15:07:56 -04:00
|
|
|
#### Function CallStatusAPI ####################################################
|
|
|
|
CallStatusAPI() {
|
|
|
|
####################
|
|
|
|
# Pull in the vars #
|
|
|
|
####################
|
2020-07-30 16:39:05 -04:00
|
|
|
LANGUAGE="${1}" # langauge that was validated
|
|
|
|
STATUS="${2}" # success | error
|
2020-07-20 15:07:56 -04:00
|
|
|
SUCCESS_MSG='No errors were found in the linting process'
|
|
|
|
FAIL_MSG='Errors were detected, please view logs'
|
2020-07-30 16:39:05 -04:00
|
|
|
MESSAGE='' # Message to send to status API
|
2020-07-20 15:07:56 -04:00
|
|
|
|
|
|
|
######################################
|
|
|
|
# Check the status to create message #
|
|
|
|
######################################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ "${STATUS}" == "success" ]; then
|
2020-07-20 15:07:56 -04:00
|
|
|
# Success
|
2020-07-21 13:09:07 -04:00
|
|
|
MESSAGE="${SUCCESS_MSG}"
|
2020-07-20 15:07:56 -04:00
|
|
|
else
|
|
|
|
# Failure
|
2020-07-21 13:09:07 -04:00
|
|
|
MESSAGE="${FAIL_MSG}"
|
2020-07-20 15:07:56 -04:00
|
|
|
fi
|
|
|
|
|
2020-07-21 11:13:15 -04:00
|
|
|
##########################################################
|
|
|
|
# Check to see if were enabled for multi Status mesaages #
|
|
|
|
##########################################################
|
2020-08-19 15:18:49 -04:00
|
|
|
if [ "${MULTI_STATUS}" == "true" ] && [ -n "${GITHUB_TOKEN}" ] && [ -n "${GITHUB_REPOSITORY}" ]; then
|
2020-07-21 11:13:15 -04:00
|
|
|
##############################################
|
|
|
|
# Call the status API to create status check #
|
|
|
|
##############################################
|
|
|
|
SEND_STATUS_CMD=$(curl -f -s -X POST \
|
2020-07-21 13:09:07 -04:00
|
|
|
--url "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/statuses/${GITHUB_SHA}" \
|
2020-07-21 11:13:15 -04:00
|
|
|
-H 'accept: application/vnd.github.v3+json' \
|
2020-07-21 13:09:07 -04:00
|
|
|
-H "authorization: Bearer ${GITHUB_TOKEN}" \
|
2020-07-21 11:13:15 -04:00
|
|
|
-H 'content-type: application/json' \
|
2020-07-21 13:09:07 -04:00
|
|
|
-d "{ \"state\": \"${STATUS}\",
|
|
|
|
\"target_url\": \"https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}\",
|
|
|
|
\"description\": \"${MESSAGE}\", \"context\": \"--> Linted: ${LANGUAGE}\"
|
2020-07-21 11:13:15 -04:00
|
|
|
}" 2>&1)
|
2020-07-20 15:07:56 -04:00
|
|
|
|
2020-07-21 11:13:15 -04:00
|
|
|
#######################
|
|
|
|
# Load the error code #
|
|
|
|
#######################
|
|
|
|
ERROR_CODE=$?
|
2020-07-20 15:07:56 -04:00
|
|
|
|
2020-07-21 11:13:15 -04:00
|
|
|
##############################
|
|
|
|
# Check the shell for errors #
|
|
|
|
##############################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ "${ERROR_CODE}" -ne 0 ]; then
|
2020-07-21 11:13:15 -04:00
|
|
|
# ERROR
|
2020-07-30 16:39:05 -04:00
|
|
|
info "ERROR! Failed to call GitHub Status API!"
|
|
|
|
info "ERROR:[${SEND_STATUS_CMD}]"
|
2020-07-21 11:13:15 -04:00
|
|
|
# Not going to fail the script on this yet...
|
2020-07-01 08:49:17 -04:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
################################################################################
|
2020-07-22 15:49:26 -04:00
|
|
|
#### Function Reports ##########################################################
|
|
|
|
Reports() {
|
2020-07-30 16:39:05 -04:00
|
|
|
info "----------------------------------------------"
|
|
|
|
info "----------------------------------------------"
|
|
|
|
info "Generated reports:"
|
|
|
|
info "----------------------------------------------"
|
|
|
|
info "----------------------------------------------"
|
2020-04-27 15:13:12 -04:00
|
|
|
|
2020-06-23 10:25:12 -04:00
|
|
|
###################################
|
|
|
|
# Prints output report if enabled #
|
|
|
|
###################################
|
2020-07-30 16:39:05 -04:00
|
|
|
if [ -z "${FORMAT_REPORT}" ]; then
|
|
|
|
info "Reports generated in folder ${REPORT_OUTPUT_FOLDER}"
|
2020-08-18 10:51:38 -04:00
|
|
|
#############################################
|
|
|
|
# Print info on reports that were generated #
|
|
|
|
#############################################
|
2020-08-31 18:06:15 -04:00
|
|
|
if [ -d "${REPORT_OUTPUT_FOLDER}" ]; then
|
|
|
|
info "Contents of report folder:"
|
|
|
|
OUTPUT_CONTENTS_CMD=$(ls "${REPORT_OUTPUT_FOLDER}")
|
|
|
|
info "$OUTPUT_CONTENTS_CMD"
|
|
|
|
else
|
|
|
|
warn "Report output folder (${REPORT_OUTPUT_FOLDER}) does NOT exist."
|
|
|
|
fi
|
2020-06-23 10:25:12 -04:00
|
|
|
fi
|
|
|
|
|
2020-07-22 15:49:26 -04:00
|
|
|
################################
|
|
|
|
# Prints for warnings if found #
|
|
|
|
################################
|
|
|
|
for TEST in "${WARNING_ARRAY_TEST[@]}"; do
|
2020-07-30 16:39:05 -04:00
|
|
|
warn "Expected file to compare with was not found for ${TEST}"
|
2020-07-22 15:49:26 -04:00
|
|
|
done
|
|
|
|
}
|
|
|
|
################################################################################
|
|
|
|
#### Function Footer ###########################################################
|
|
|
|
Footer() {
|
2020-07-30 16:39:05 -04:00
|
|
|
info "----------------------------------------------"
|
|
|
|
info "----------------------------------------------"
|
|
|
|
info "The script has completed"
|
|
|
|
info "----------------------------------------------"
|
|
|
|
info "----------------------------------------------"
|
2020-07-22 15:49:26 -04:00
|
|
|
|
2020-07-21 09:23:32 -04:00
|
|
|
####################################################
|
|
|
|
# Need to clean up the lanuage array of duplicates #
|
|
|
|
####################################################
|
2020-08-27 15:12:24 -04:00
|
|
|
mapfile -t UNIQUE_LINTED_ARRAY < <(for LANG in "${LINTED_LANGUAGES_ARRAY[@]}"; do echo "${LANG}"; done | sort -u)
|
2020-07-21 09:23:32 -04:00
|
|
|
|
2020-04-27 15:13:12 -04:00
|
|
|
##############################
|
|
|
|
# Prints for errors if found #
|
|
|
|
##############################
|
2020-07-01 17:40:40 -04:00
|
|
|
for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do
|
2020-04-27 15:13:12 -04:00
|
|
|
###########################
|
|
|
|
# Build the error counter #
|
|
|
|
###########################
|
2020-07-21 13:09:07 -04:00
|
|
|
ERROR_COUNTER="ERRORS_FOUND_${LANGUAGE}"
|
2020-04-27 15:13:12 -04:00
|
|
|
|
|
|
|
##################
|
|
|
|
# Print if not 0 #
|
|
|
|
##################
|
2020-07-30 16:39:05 -04:00
|
|
|
if [[ ${!ERROR_COUNTER} -ne 0 ]]; then
|
2020-07-21 09:12:28 -04:00
|
|
|
# We found errors in the language
|
2020-07-20 15:07:56 -04:00
|
|
|
###################
|
|
|
|
# Print the goods #
|
|
|
|
###################
|
2020-07-30 16:39:05 -04:00
|
|
|
error "ERRORS FOUND${NC} in ${LANGUAGE}:[${!ERROR_COUNTER}]"
|
2020-07-20 15:07:56 -04:00
|
|
|
|
|
|
|
#########################################
|
|
|
|
# Create status API for Failed language #
|
|
|
|
#########################################
|
2020-07-21 13:09:07 -04:00
|
|
|
CallStatusAPI "${LANGUAGE}" "error"
|
2020-07-22 15:59:03 -04:00
|
|
|
######################################
|
|
|
|
# Check if we validated the langauge #
|
|
|
|
######################################
|
2020-08-24 15:12:37 -04:00
|
|
|
elif [[ ${!ERROR_COUNTER} -eq 0 ]]; then
|
|
|
|
if CheckInArray "${LANGUAGE}"; then
|
2020-07-21 09:12:28 -04:00
|
|
|
# No errors found when linting the language
|
2020-07-22 15:59:03 -04:00
|
|
|
CallStatusAPI "${LANGUAGE}" "success"
|
2020-04-27 15:13:12 -04:00
|
|
|
fi
|
2020-08-24 15:22:39 -04:00
|
|
|
fi
|
2020-04-27 15:13:12 -04:00
|
|
|
done
|
|
|
|
|
2020-06-18 15:24:47 -04:00
|
|
|
##################################
|
|
|
|
# Exit with 0 if errors disabled #
|
|
|
|
##################################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ "${DISABLE_ERRORS}" == "true" ]; then
|
2020-07-30 16:39:05 -04:00
|
|
|
warn "Exiting with exit code:[0] as:[DISABLE_ERRORS] was set to:[${DISABLE_ERRORS}]"
|
2020-06-18 15:24:47 -04:00
|
|
|
exit 0
|
2020-07-22 15:49:26 -04:00
|
|
|
fi
|
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
###############################
|
|
|
|
# Exit with 1 if errors found #
|
|
|
|
###############################
|
2020-07-22 15:49:26 -04:00
|
|
|
# Loop through all languages
|
|
|
|
for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do
|
|
|
|
# build the variable
|
|
|
|
ERRORS_FOUND_LANGUAGE="ERRORS_FOUND_${LANGUAGE}"
|
|
|
|
# Check if error was found
|
2020-07-30 16:39:05 -04:00
|
|
|
if [[ ${!ERRORS_FOUND_LANGUAGE} -ne 0 ]]; then
|
2020-07-22 15:49:26 -04:00
|
|
|
# Failed exit
|
2020-07-30 16:39:05 -04:00
|
|
|
fatal "Exiting with errors found!"
|
2020-07-22 15:49:26 -04:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
########################
|
|
|
|
# Footer prints Exit 0 #
|
|
|
|
########################
|
2020-07-30 16:39:05 -04:00
|
|
|
notice "All file(s) linted successfully with no errors detected"
|
|
|
|
info "----------------------------------------------"
|
2020-07-22 15:49:26 -04:00
|
|
|
# Successful exit
|
|
|
|
exit 0
|
2019-10-21 10:12:50 -04:00
|
|
|
}
|
2020-08-24 15:12:37 -04:00
|
|
|
################################################################################
|
|
|
|
#### Function CheckInArray #####################################################
|
|
|
|
CheckInArray() {
|
|
|
|
###############
|
|
|
|
# Pull in Var #
|
|
|
|
###############
|
|
|
|
NEEDLE="$1" # Language we need to match
|
|
|
|
|
|
|
|
######################################
|
|
|
|
# Check if Language was in the array #
|
|
|
|
######################################
|
|
|
|
for LANG in "${UNIQUE_LINTED_ARRAY[@]}"; do
|
|
|
|
if [[ "${LANG}" == "${NEEDLE}" ]]; then
|
|
|
|
############
|
|
|
|
# Found it #
|
|
|
|
############
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
done
|
2020-06-21 03:16:45 -04:00
|
|
|
|
2020-08-24 15:12:37 -04:00
|
|
|
###################
|
|
|
|
# Did not find it #
|
|
|
|
###################
|
|
|
|
return 1
|
|
|
|
}
|
2020-07-27 17:11:33 -04:00
|
|
|
################################################################################
|
|
|
|
#### Function Cleanup ##########################################################
|
|
|
|
cleanup() {
|
2020-07-30 16:39:05 -04:00
|
|
|
local -ri EXIT_CODE=$?
|
2020-07-27 17:11:33 -04:00
|
|
|
|
2020-07-30 16:39:05 -04:00
|
|
|
sh -c "cat ${LOG_TEMP} >> ${GITHUB_WORKSPACE}/${LOG_FILE}" || true
|
2020-07-27 17:11:33 -04:00
|
|
|
|
2020-07-30 16:39:05 -04:00
|
|
|
exit ${EXIT_CODE}
|
|
|
|
trap - 0 1 2 3 6 14 15
|
2019-10-21 10:12:50 -04:00
|
|
|
}
|
2020-07-27 17:11:33 -04:00
|
|
|
trap 'cleanup' 0 1 2 3 6 14 15
|
2019-10-21 10:12:50 -04:00
|
|
|
################################################################################
|
2019-10-21 12:05:55 -04:00
|
|
|
############################### MAIN ###########################################
|
2019-10-21 10:12:50 -04:00
|
|
|
################################################################################
|
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
##########
|
|
|
|
# Header #
|
|
|
|
##########
|
|
|
|
Header
|
|
|
|
|
2020-06-23 10:25:12 -04:00
|
|
|
##############################################################
|
|
|
|
# check flag for validating the report folder does not exist #
|
|
|
|
##############################################################
|
|
|
|
if [ -n "${OUTPUT_FORMAT}" ]; then
|
2020-07-30 16:39:05 -04:00
|
|
|
if [ -d "${REPORT_OUTPUT_FOLDER}" ]; then
|
|
|
|
error "ERROR! Found ${REPORT_OUTPUT_FOLDER}"
|
|
|
|
fatal "Please remove the folder and try again."
|
2020-06-23 10:25:12 -04:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2019-10-21 15:12:37 -04:00
|
|
|
#######################
|
2020-06-19 01:44:26 -04:00
|
|
|
# Get GitHub Env Vars #
|
2019-10-21 15:12:37 -04:00
|
|
|
#######################
|
2020-06-19 01:44:26 -04:00
|
|
|
# Need to pull in all the GitHub variables
|
2019-10-21 15:12:37 -04:00
|
|
|
# needed to connect back and update checks
|
|
|
|
GetGitHubVars
|
|
|
|
|
2020-06-20 23:55:10 -04:00
|
|
|
#########################################
|
|
|
|
# Get the languages we need to validate #
|
|
|
|
#########################################
|
2020-04-27 14:47:11 -04:00
|
|
|
GetValidationInfo
|
2020-04-27 13:21:38 -04:00
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
########################
|
|
|
|
# Get the linter rules #
|
|
|
|
########################
|
2020-03-11 15:18:21 -04:00
|
|
|
# Get Ansible rules
|
2020-07-01 10:45:55 -04:00
|
|
|
GetLinterRules "ANSIBLE"
|
2020-07-02 17:31:16 -04:00
|
|
|
# Get ARM rules
|
2020-07-03 08:28:08 -04:00
|
|
|
GetLinterRules "ARM"
|
2020-07-22 15:07:08 -04:00
|
|
|
# Get CLOUDFORMATION rules
|
|
|
|
GetLinterRules "CLOUDFORMATION"
|
2020-07-23 13:52:43 -04:00
|
|
|
# Get Coffeescript rules
|
|
|
|
GetLinterRules "COFFEESCRIPT"
|
2020-06-18 19:40:41 -04:00
|
|
|
# Get CSS rules
|
2020-07-01 10:45:55 -04:00
|
|
|
GetLinterRules "CSS"
|
2020-07-06 04:17:20 -04:00
|
|
|
# Get DART rules
|
|
|
|
GetLinterRules "DART"
|
2020-07-23 13:52:43 -04:00
|
|
|
# Get Docker rules
|
2020-08-04 15:41:10 -04:00
|
|
|
GetLinterRules "DOCKERFILE"
|
|
|
|
# Get Docker rules
|
|
|
|
GetLinterRules "DOCKERFILE_HADOLINT"
|
2020-07-23 13:52:43 -04:00
|
|
|
# Get Golang rules
|
|
|
|
GetLinterRules "GO"
|
|
|
|
# Get Groovy rules
|
|
|
|
GetLinterRules "GROOVY"
|
2020-07-04 18:14:27 -04:00
|
|
|
# Get HTML rules
|
|
|
|
GetLinterRules "HTML"
|
2020-08-05 14:35:14 -04:00
|
|
|
# get Java rules
|
2020-08-05 14:38:35 -04:00
|
|
|
GetLinterRules "JAVA"
|
2020-07-23 13:52:43 -04:00
|
|
|
# Get JavaScript rules
|
|
|
|
GetLinterRules "JAVASCRIPT"
|
2020-08-18 18:54:32 -04:00
|
|
|
# Get LATEX rules
|
|
|
|
GetLinterRules "LATEX"
|
2020-07-24 13:27:54 -04:00
|
|
|
# Get LUA rules
|
|
|
|
GetLinterRules "LUA"
|
2020-07-23 13:52:43 -04:00
|
|
|
# Get Markdown rules
|
|
|
|
GetLinterRules "MARKDOWN"
|
2020-08-06 10:39:45 -04:00
|
|
|
# Get PHPCS rules
|
|
|
|
GetLinterRules "PHP_PHPCS"
|
|
|
|
# Get PHP_PHPSTAN rules
|
|
|
|
GetLinterRules "PHP_PHPSTAN"
|
|
|
|
# Get PHP_PSALM rules
|
|
|
|
GetLinterRules "PHP_PSALM"
|
2020-07-23 13:52:43 -04:00
|
|
|
# Get PowerShell rules
|
|
|
|
GetLinterRules "POWERSHELL"
|
2020-07-23 11:41:17 -04:00
|
|
|
# Get Python pylint rules
|
|
|
|
GetLinterRules "PYTHON_PYLINT"
|
|
|
|
# Get Python flake8 rules
|
|
|
|
GetLinterRules "PYTHON_FLAKE8"
|
2020-09-02 10:26:01 -04:00
|
|
|
# Get Python black rules
|
|
|
|
GetLinterRules "PYTHON_BLACK"
|
2020-08-15 15:29:22 -04:00
|
|
|
# Get R rules
|
|
|
|
GetLinterRules "R"
|
2020-07-23 13:52:43 -04:00
|
|
|
# Get Ruby rules
|
|
|
|
GetLinterRules "RUBY"
|
2020-08-11 13:30:00 -04:00
|
|
|
# Get SQL rules
|
|
|
|
GetLinterRules "SQL"
|
2020-07-23 13:52:43 -04:00
|
|
|
# Get Terraform rules
|
|
|
|
GetLinterRules "TERRAFORM"
|
|
|
|
# Get TypeScript rules
|
|
|
|
GetLinterRules "TYPESCRIPT"
|
2020-07-24 12:20:22 -04:00
|
|
|
# Get YAML rules
|
2020-07-23 13:52:43 -04:00
|
|
|
GetLinterRules "YAML"
|
2020-02-03 11:27:40 -05:00
|
|
|
|
2020-07-30 15:15:42 -04:00
|
|
|
##################################
|
|
|
|
# Get and print all version info #
|
|
|
|
##################################
|
|
|
|
GetLinterVersions
|
2020-01-08 14:34:05 -05:00
|
|
|
|
2020-02-04 12:49:07 -05:00
|
|
|
###########################################
|
|
|
|
# Check to see if this is a test case run #
|
|
|
|
###########################################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [[ ${TEST_CASE_RUN} != "false" ]]; then
|
2020-07-20 15:07:56 -04:00
|
|
|
|
|
|
|
#############################################
|
|
|
|
# Set the multi status to off for test runs #
|
|
|
|
#############################################
|
|
|
|
MULTI_STATUS='false'
|
|
|
|
|
2020-02-04 12:49:07 -05:00
|
|
|
###########################
|
|
|
|
# Run only the test cases #
|
|
|
|
###########################
|
|
|
|
# Code will exit from inside this loop
|
|
|
|
RunTestCases
|
|
|
|
fi
|
2020-06-29 16:38:33 -04:00
|
|
|
|
2020-02-03 11:27:40 -05:00
|
|
|
#############################################
|
|
|
|
# check flag for validation of all codebase #
|
|
|
|
#############################################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ "${VALIDATE_ALL_CODEBASE}" == "false" ]; then
|
2020-02-03 11:27:40 -05:00
|
|
|
########################################
|
|
|
|
# Get list of files changed if env set #
|
|
|
|
########################################
|
2019-10-25 12:29:31 -04:00
|
|
|
BuildFileList
|
|
|
|
fi
|
2019-10-21 15:12:37 -04:00
|
|
|
|
2020-07-23 13:52:43 -04:00
|
|
|
###################
|
|
|
|
# ANSIBLE LINTING #
|
|
|
|
###################
|
|
|
|
if [ "${VALIDATE_ANSIBLE}" == "true" ]; then
|
|
|
|
##########################
|
|
|
|
# Lint the Ansible files #
|
|
|
|
##########################
|
|
|
|
# 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 "${ANSIBLE_LINTER_RULES}" # Passing rules but not needed, dont want to exclude unused var
|
2019-10-25 12:29:31 -04:00
|
|
|
fi
|
2019-10-21 12:05:55 -04:00
|
|
|
|
2020-07-23 13:52:43 -04:00
|
|
|
########################
|
|
|
|
# ARM Template LINTING #
|
|
|
|
########################
|
|
|
|
if [ "${VALIDATE_ARM}" == "true" ]; then
|
|
|
|
# If we are validating all codebase we need to build file list because not every json file is an ARM file
|
|
|
|
if [ "${VALIDATE_ALL_CODEBASE}" == "true" ]; then
|
|
|
|
###############################################################################
|
|
|
|
# Set the file seperator to newline to allow for grabbing objects with spaces #
|
|
|
|
###############################################################################
|
|
|
|
IFS=$'\n'
|
2019-10-21 10:12:50 -04:00
|
|
|
|
2020-08-06 20:49:23 -04:00
|
|
|
mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" -path "*/node_modules" -prune -o -type f -regex ".*\.\(json\)\$" 2>&1)
|
2020-07-23 13:52:43 -04:00
|
|
|
for FILE in "${LIST_FILES[@]}"; do
|
|
|
|
if DetectARMFile "${FILE}"; then
|
|
|
|
FILE_ARRAY_ARM+=("${FILE}")
|
|
|
|
fi
|
|
|
|
done
|
2019-10-21 10:12:50 -04:00
|
|
|
|
2020-07-23 13:52:43 -04:00
|
|
|
###########################
|
|
|
|
# Set IFS back to default #
|
|
|
|
###########################
|
|
|
|
IFS="${DEFAULT_IFS}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
###############################
|
|
|
|
# Lint the ARM Template files #
|
|
|
|
###############################
|
2020-02-03 15:54:43 -05:00
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-07-23 13:52:43 -04:00
|
|
|
LintCodebase "ARM" "arm-ttk" "Import-Module ${ARM_TTK_PSD1} ; \${config} = \$(Import-PowerShellDataFile -Path ${ARM_LINTER_RULES}) ; Test-AzTemplate @config -TemplatePath" "disabledfileext" "${FILE_ARRAY_ARM[@]}"
|
2019-10-25 12:29:31 -04:00
|
|
|
fi
|
2019-10-21 12:05:55 -04:00
|
|
|
|
2020-02-03 11:27:40 -05:00
|
|
|
################
|
|
|
|
# BASH LINTING #
|
|
|
|
################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ "${VALIDATE_BASH}" == "true" ]; then
|
2020-02-03 11:27:40 -05:00
|
|
|
#######################
|
|
|
|
# Lint the bash files #
|
|
|
|
#######################
|
2020-02-03 15:54:43 -05:00
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-08-31 17:44:35 -04:00
|
|
|
LintCodebase "BASH" "shellcheck" "shellcheck --color --external-sources" "disabledfileext" "${FILE_ARRAY_BASH[@]}"
|
2019-10-25 12:29:31 -04:00
|
|
|
fi
|
2019-10-21 12:05:55 -04:00
|
|
|
|
2020-08-28 10:56:53 -04:00
|
|
|
#####################
|
2020-08-28 11:12:02 -04:00
|
|
|
# BASH_EXEC LINTING #
|
2020-08-28 10:56:53 -04:00
|
|
|
#####################
|
|
|
|
if [ "${VALIDATE_BASH_EXEC}" == "true" ]; then
|
|
|
|
#######################
|
|
|
|
# Lint the bash files #
|
|
|
|
#######################
|
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-08-31 17:44:35 -04:00
|
|
|
LintCodebase "BASH_EXEC" "bash-exec" "bash-exec" "disabledfileext" "${FILE_ARRAY_BASH[@]}"
|
2019-10-25 12:29:31 -04:00
|
|
|
fi
|
2019-10-21 12:05:55 -04:00
|
|
|
|
2020-07-22 15:07:08 -04:00
|
|
|
##########################
|
|
|
|
# CLOUDFORMATION LINTING #
|
|
|
|
##########################
|
|
|
|
if [ "${VALIDATE_CLOUDFORMATION}" == "true" ]; then
|
2020-07-23 09:05:16 -04:00
|
|
|
# If we are validating all codebase we need to build file list because not every yml/json file is an CLOUDFORMATION file
|
2020-07-23 01:30:12 -04:00
|
|
|
if [ "${VALIDATE_ALL_CODEBASE}" == "true" ]; then
|
|
|
|
###############################################################################
|
|
|
|
# Set the file seperator to newline to allow for grabbing objects with spaces #
|
|
|
|
###############################################################################
|
|
|
|
IFS=$'\n'
|
|
|
|
|
2020-08-06 20:49:23 -04:00
|
|
|
mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" -path "*/node_modules" -prune -o -type f -regex ".*\.\(yml\|yaml\|json\)\$" 2>&1)
|
2020-07-23 01:30:12 -04:00
|
|
|
for FILE in "${LIST_FILES[@]}"; do
|
|
|
|
if DetectCloudFormationFile "${FILE}"; then
|
2020-07-23 09:05:16 -04:00
|
|
|
FILE_ARRAY_CLOUDFORMATION+=("${FILE}")
|
2020-07-23 01:30:12 -04:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
###########################
|
|
|
|
# Set IFS back to default #
|
|
|
|
###########################
|
|
|
|
IFS="${DEFAULT_IFS}"
|
|
|
|
fi
|
2019-10-21 12:05:55 -04:00
|
|
|
|
2020-06-19 12:41:19 -04:00
|
|
|
#################################
|
|
|
|
# Lint the CloudFormation files #
|
|
|
|
#################################
|
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-07-23 09:05:16 -04:00
|
|
|
LintCodebase "CLOUDFORMATION" "cfn-lint" "cfn-lint --config-file ${CLOUDFORMATION_LINTER_RULES}" "disabledfileext" "${FILE_ARRAY_CLOUDFORMATION[@]}"
|
2020-06-19 12:41:19 -04:00
|
|
|
fi
|
|
|
|
|
2020-07-23 13:52:43 -04:00
|
|
|
###################
|
|
|
|
# CLOJURE LINTING #
|
|
|
|
###################
|
|
|
|
if [ "${VALIDATE_CLOJURE}" == "true" ]; then
|
|
|
|
#################################
|
|
|
|
# Get Clojure standard rules #
|
|
|
|
#################################
|
|
|
|
GetStandardRules "clj-kondo"
|
|
|
|
#########################
|
|
|
|
# Lint the Clojure files #
|
|
|
|
#########################
|
|
|
|
LintCodebase "CLOJURE" "clj-kondo" "clj-kondo --config ${CLOJURE_LINTER_RULES} --lint" ".*\.\(clj\|cljs\|cljc\|edn\)\$" "${FILE_ARRAY_CLOJURE[@]}"
|
2019-10-25 12:29:31 -04:00
|
|
|
fi
|
2019-10-21 12:05:55 -04:00
|
|
|
|
2020-07-23 13:52:43 -04:00
|
|
|
########################
|
|
|
|
# COFFEESCRIPT LINTING #
|
|
|
|
########################
|
|
|
|
if [ "${VALIDATE_COFFEE}" == "true" ]; then
|
|
|
|
#########################
|
|
|
|
# Lint the coffee files #
|
|
|
|
#########################
|
2020-07-05 22:21:13 -04:00
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-07-23 13:52:43 -04:00
|
|
|
LintCodebase "COFFEESCRIPT" "coffeelint" "coffeelint -f ${COFFEESCRIPT_LINTER_RULES}" ".*\.\(coffee\)\$" "${FILE_ARRAY_COFFEESCRIPT[@]}"
|
|
|
|
fi
|
|
|
|
|
2020-08-24 20:40:02 -04:00
|
|
|
##################
|
|
|
|
# CSHARP LINTING #
|
|
|
|
##################
|
|
|
|
if [ "${VALIDATE_CSHARP}" == "true" ]; then
|
|
|
|
#########################
|
|
|
|
# Lint the C# files #
|
|
|
|
#########################
|
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-08-28 15:08:08 -04:00
|
|
|
LintCodebase "CSHARP" "dotnet-format" "dotnet-format --folder --check --exclude / --include" ".*\.\(cs\)\$" "${FILE_ARRAY_CSHARP[@]}"
|
2020-08-24 20:40:02 -04:00
|
|
|
fi
|
|
|
|
|
2020-07-23 13:52:43 -04:00
|
|
|
###############
|
|
|
|
# CSS LINTING #
|
|
|
|
###############
|
|
|
|
if [ "${VALIDATE_CSS}" == "true" ]; then
|
|
|
|
#################################
|
|
|
|
# Get CSS standard rules #
|
|
|
|
#################################
|
|
|
|
GetStandardRules "stylelint"
|
|
|
|
#############################
|
|
|
|
# Lint the CSS files #
|
|
|
|
#############################
|
2020-08-13 08:58:06 -04:00
|
|
|
LintCodebase "CSS" "stylelint" "stylelint --config ${CSS_LINTER_RULES}" ".*\.\(css\|scss\|sass\)\$" "${FILE_ARRAY_CSS[@]}"
|
2020-07-05 22:21:13 -04:00
|
|
|
fi
|
|
|
|
|
2020-06-18 13:53:24 -04:00
|
|
|
################
|
2020-07-23 13:52:43 -04:00
|
|
|
# DART LINTING #
|
2020-06-18 13:53:24 -04:00
|
|
|
################
|
2020-07-23 13:52:43 -04:00
|
|
|
if [ "${VALIDATE_DART}" == "true" ]; then
|
2020-06-18 13:53:24 -04:00
|
|
|
#######################
|
2020-07-23 13:52:43 -04:00
|
|
|
# Lint the Dart files #
|
2020-06-18 13:53:24 -04:00
|
|
|
#######################
|
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-07-23 13:52:43 -04:00
|
|
|
LintCodebase "DART" "dart" "dartanalyzer --fatal-infos --fatal-warnings --options ${DART_LINTER_RULES}" ".*\.\(dart\)\$" "${FILE_ARRAY_DART[@]}"
|
2020-06-18 13:53:24 -04:00
|
|
|
fi
|
|
|
|
|
2020-07-23 13:52:43 -04:00
|
|
|
##################
|
|
|
|
# DOCKER LINTING #
|
|
|
|
##################
|
2020-08-14 04:38:26 -04:00
|
|
|
if [ "${VALIDATE_DOCKERFILE}" == "true" ]; then
|
2020-07-23 13:52:43 -04:00
|
|
|
#########################
|
|
|
|
# Lint the docker files #
|
|
|
|
#########################
|
2020-02-03 15:54:43 -05:00
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-07-23 13:52:43 -04:00
|
|
|
# NOTE: dockerfilelint's "-c" option expects the folder *containing* the DOCKER_LINTER_RULES file
|
2020-08-04 17:13:20 -04:00
|
|
|
LintCodebase "DOCKERFILE" "dockerfilelint" "dockerfilelint -c $(dirname ${DOCKERFILE_LINTER_RULES})" ".*\(Dockerfile\)\$" "${FILE_ARRAY_DOCKERFILE[@]}"
|
2020-08-04 14:53:32 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
###########################
|
|
|
|
# DOCKER LINTING HADOLINT #
|
|
|
|
###########################
|
2020-08-14 04:38:26 -04:00
|
|
|
if [ "${VALIDATE_DOCKERFILE_HADOLINT}" == "true" ]; then
|
2020-08-04 14:53:32 -04:00
|
|
|
#########################
|
|
|
|
# Lint the docker files #
|
|
|
|
#########################
|
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-08-04 17:13:20 -04:00
|
|
|
LintCodebase "DOCKERFILE_HADOLINT" "hadolint" "hadolint -c ${DOCKERFILE_HADOLINT_LINTER_RULES}" ".*\(Dockerfile\)\$" "${FILE_ARRAY_DOCKERFILE[@]}"
|
2019-10-25 12:29:31 -04:00
|
|
|
fi
|
2019-10-21 12:05:55 -04:00
|
|
|
|
2020-02-03 11:27:40 -05:00
|
|
|
########################
|
2020-07-23 13:52:43 -04:00
|
|
|
# EDITORCONFIG LINTING #
|
2020-02-03 11:27:40 -05:00
|
|
|
########################
|
2020-07-23 13:52:43 -04:00
|
|
|
if [ "${VALIDATE_EDITORCONFIG}" == "true" ]; then
|
|
|
|
####################################
|
|
|
|
# Lint the files with editorconfig #
|
|
|
|
####################################
|
2020-02-03 15:54:43 -05:00
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-07-23 13:52:43 -04:00
|
|
|
LintCodebase "EDITORCONFIG" "editorconfig-checker" "editorconfig-checker" "^.*$" "${FILE_ARRAY_ENV[@]}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
###############
|
|
|
|
# ENV LINTING #
|
|
|
|
###############
|
|
|
|
if [ "${VALIDATE_ENV}" == "true" ]; then
|
|
|
|
#######################
|
|
|
|
# Lint the env files #
|
|
|
|
#######################
|
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
|
|
|
LintCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\).*\$" "${FILE_ARRAY_ENV[@]}"
|
2019-10-25 12:29:31 -04:00
|
|
|
fi
|
2019-10-21 12:05:55 -04:00
|
|
|
|
2020-02-28 10:51:29 -05:00
|
|
|
##################
|
|
|
|
# GOLANG LINTING #
|
|
|
|
##################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ "${VALIDATE_GO}" == "true" ]; then
|
2020-02-28 10:51:29 -05:00
|
|
|
#########################
|
|
|
|
# Lint the golang files #
|
|
|
|
#########################
|
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-07-21 13:09:07 -04:00
|
|
|
LintCodebase "GO" "golangci-lint" "golangci-lint run -c ${GO_LINTER_RULES}" ".*\.\(go\)\$" "${FILE_ARRAY_GO[@]}"
|
2020-02-28 10:51:29 -05:00
|
|
|
fi
|
|
|
|
|
2020-07-14 10:28:58 -04:00
|
|
|
##################
|
|
|
|
# GROOVY LINTING #
|
|
|
|
##################
|
|
|
|
if [ "$VALIDATE_GROOVY" == "true" ]; then
|
|
|
|
#########################
|
|
|
|
# Lint the groovy files #
|
|
|
|
#########################
|
2020-03-11 15:18:21 -04:00
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-07-23 13:52:43 -04:00
|
|
|
LintCodebase "GROOVY" "npm-groovy-lint" "npm-groovy-lint -c $GROOVY_LINTER_RULES --failon error" ".*\.\(groovy\|jenkinsfile\|gradle\)\$" "${FILE_ARRAY_GROOVY[@]}"
|
2020-03-11 15:18:21 -04:00
|
|
|
fi
|
|
|
|
|
2020-07-23 13:52:43 -04:00
|
|
|
################
|
|
|
|
# HTML LINTING #
|
|
|
|
################
|
|
|
|
if [ "${VALIDATE_HTML}" == "true" ]; then
|
|
|
|
###########################
|
|
|
|
# Get HTML standard rules #
|
|
|
|
###########################
|
|
|
|
GetStandardRules "htmlhint"
|
|
|
|
#######################
|
|
|
|
# Lint the HTML files #
|
|
|
|
#######################
|
|
|
|
LintCodebase "HTML" "htmlhint" "htmlhint --config ${HTML_LINTER_RULES}" ".*\.\(html\)\$" "${FILE_ARRAY_HTML[@]}"
|
2019-10-25 12:29:31 -04:00
|
|
|
fi
|
2019-10-22 13:21:42 -04:00
|
|
|
|
2020-08-05 14:35:14 -04:00
|
|
|
################
|
|
|
|
# JAVA LINTING #
|
|
|
|
################
|
|
|
|
if [ "$VALIDATE_JAVA" == "true" ]; then
|
|
|
|
#######################
|
|
|
|
# Lint the JAVA files #
|
|
|
|
#######################
|
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-08-05 15:53:48 -04:00
|
|
|
LintCodebase "JAVA" "checkstyle" "java -jar /usr/bin/checkstyle -c ${JAVA_LINTER_RULES}" ".*\.\(java\)\$" "${FILE_ARRAY_JAVA[@]}"
|
2020-08-05 14:35:14 -04:00
|
|
|
fi
|
|
|
|
|
2020-02-03 11:27:40 -05:00
|
|
|
######################
|
|
|
|
# JAVASCRIPT LINTING #
|
|
|
|
######################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ "${VALIDATE_JAVASCRIPT_ES}" == "true" ]; then
|
2020-04-02 13:42:07 -04:00
|
|
|
#############################
|
|
|
|
# Lint the Javascript files #
|
|
|
|
#############################
|
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-07-21 13:09:07 -04:00
|
|
|
LintCodebase "JAVASCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" ".*\.\(js\)\$" "${FILE_ARRAY_JAVASCRIPT_ES[@]}"
|
2020-04-02 13:42:07 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
######################
|
|
|
|
# JAVASCRIPT LINTING #
|
|
|
|
######################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ "${VALIDATE_JAVASCRIPT_STANDARD}" == "true" ]; then
|
2020-02-03 11:27:40 -05:00
|
|
|
#################################
|
|
|
|
# Get Javascript standard rules #
|
|
|
|
#################################
|
2020-04-02 13:48:35 -04:00
|
|
|
GetStandardRules "javascript"
|
2020-02-03 11:27:40 -05:00
|
|
|
#############################
|
|
|
|
# Lint the Javascript files #
|
|
|
|
#############################
|
2020-02-03 15:54:43 -05:00
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-07-21 13:09:07 -04:00
|
|
|
LintCodebase "JAVASCRIPT_STANDARD" "standard" "standard ${JAVASCRIPT_STANDARD_LINTER_RULES}" ".*\.\(js\)\$" "${FILE_ARRAY_JAVASCRIPT_STANDARD[@]}"
|
2020-04-02 13:42:07 -04:00
|
|
|
fi
|
|
|
|
|
2020-07-23 13:52:43 -04:00
|
|
|
################
|
|
|
|
# JSON LINTING #
|
|
|
|
################
|
|
|
|
if [ "${VALIDATE_JSON}" == "true" ]; then
|
|
|
|
#######################
|
|
|
|
# Lint the json files #
|
|
|
|
#######################
|
2020-07-07 11:02:56 -04:00
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-07-23 13:52:43 -04:00
|
|
|
LintCodebase "JSON" "jsonlint" "jsonlint" ".*\.\(json\)\$" "${FILE_ARRAY_JSON[@]}"
|
2020-06-18 19:40:41 -04:00
|
|
|
fi
|
|
|
|
|
2020-06-20 06:02:14 -04:00
|
|
|
###############
|
2020-07-24 09:20:41 -04:00
|
|
|
# JSX LINTING #
|
2020-06-20 06:02:14 -04:00
|
|
|
###############
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ "${VALIDATE_JSX}" == "true" ]; then
|
2020-07-24 09:20:41 -04:00
|
|
|
######################
|
|
|
|
# Lint the JSX files #
|
|
|
|
######################
|
2020-06-19 13:32:07 -04:00
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-07-21 13:09:07 -04:00
|
|
|
LintCodebase "JSX" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" ".*\.\(jsx\)\$" "${FILE_ARRAY_JSX[@]}"
|
2020-06-19 13:32:07 -04:00
|
|
|
fi
|
|
|
|
|
2020-06-21 03:59:18 -04:00
|
|
|
##################
|
|
|
|
# KOTLIN LINTING #
|
|
|
|
##################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ "${VALIDATE_KOTLIN}" == "true" ]; then
|
2020-06-21 03:59:18 -04:00
|
|
|
#######################
|
|
|
|
# Lint the Kotlin files #
|
|
|
|
#######################
|
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-06-29 11:34:23 -04:00
|
|
|
LintCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$" "${FILE_ARRAY_KOTLIN[@]}"
|
2020-06-19 13:32:07 -04:00
|
|
|
fi
|
|
|
|
|
2020-08-18 18:54:32 -04:00
|
|
|
#################
|
|
|
|
# LATEX LINTING #
|
|
|
|
#################
|
|
|
|
if [ "${VALIDATE_LATEX}" == "true" ]; then
|
|
|
|
########################
|
|
|
|
# Lint the LATEX files #
|
|
|
|
########################
|
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-08-19 10:28:41 -04:00
|
|
|
LintCodebase "LATEX" "chktex" "chktex -q -l ${LATEX_LINTER_RULES}" ".*\.\(tex\)\$" "${FILE_ARRAY_LATEX[@]}"
|
2020-08-18 18:54:32 -04:00
|
|
|
fi
|
|
|
|
|
2020-07-24 13:27:54 -04:00
|
|
|
###############
|
|
|
|
# LUA LINTING #
|
|
|
|
###############
|
|
|
|
if [ "${VALIDATE_LUA}" == "true" ]; then
|
|
|
|
######################
|
|
|
|
# Lint the Lua files #
|
|
|
|
######################
|
2020-06-21 03:16:45 -04:00
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-07-24 13:27:54 -04:00
|
|
|
LintCodebase "LUA" "lua" "luacheck --config ${LUA_LINTER_RULES}" ".*\.\(lua\)\$" "${FILE_ARRAY_LUA[@]}"
|
2020-06-21 03:16:45 -04:00
|
|
|
fi
|
|
|
|
|
2020-07-23 13:52:43 -04:00
|
|
|
####################
|
|
|
|
# MARKDOWN LINTING #
|
|
|
|
####################
|
|
|
|
if [ "${VALIDATE_MARKDOWN}" == "true" ]; then
|
|
|
|
###########################
|
|
|
|
# Lint the Markdown Files #
|
|
|
|
###########################
|
2020-06-21 03:16:45 -04:00
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-07-23 13:52:43 -04:00
|
|
|
LintCodebase "MARKDOWN" "markdownlint" "markdownlint -c ${MARKDOWN_LINTER_RULES}" ".*\.\(md\)\$" "${FILE_ARRAY_MARKDOWN[@]}"
|
2020-06-21 03:16:45 -04:00
|
|
|
fi
|
|
|
|
|
2020-07-23 13:52:43 -04:00
|
|
|
###################
|
|
|
|
# OPENAPI LINTING #
|
|
|
|
###################
|
|
|
|
if [ "${VALIDATE_OPENAPI}" == "true" ]; then
|
|
|
|
# If we are validating all codebase we need to build file list because not every yml/json file is an OpenAPI file
|
|
|
|
if [ "${VALIDATE_ALL_CODEBASE}" == "true" ]; then
|
|
|
|
###############################################################################
|
|
|
|
# Set the file seperator to newline to allow for grabbing objects with spaces #
|
|
|
|
###############################################################################
|
|
|
|
IFS=$'\n'
|
2020-07-06 04:17:20 -04:00
|
|
|
|
2020-08-06 20:49:23 -04:00
|
|
|
mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" -path "*/node_modules" -prune -o -type f -regex ".*\.\(yml\|yaml\|json\)\$" 2>&1)
|
2020-07-23 13:52:43 -04:00
|
|
|
for FILE in "${LIST_FILES[@]}"; do
|
|
|
|
if DetectOpenAPIFile "${FILE}"; then
|
|
|
|
FILE_ARRAY_OPENAPI+=("${FILE}")
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
###########################
|
|
|
|
# Set IFS back to default #
|
|
|
|
###########################
|
|
|
|
IFS="${DEFAULT_IFS}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
##########################
|
|
|
|
# Lint the OpenAPI files #
|
|
|
|
##########################
|
2020-02-03 15:54:43 -05:00
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-07-23 13:52:43 -04:00
|
|
|
LintCodebase "OPENAPI" "spectral" "spectral lint -r ${OPENAPI_LINTER_RULES}" "disabledfileext" "${FILE_ARRAY_OPENAPI[@]}"
|
2020-01-09 17:08:01 -05:00
|
|
|
fi
|
|
|
|
|
2020-07-23 13:52:43 -04:00
|
|
|
################
|
|
|
|
# PERL LINTING #
|
|
|
|
################
|
|
|
|
if [ "${VALIDATE_PERL}" == "true" ]; then
|
2020-07-06 04:17:20 -04:00
|
|
|
#######################
|
2020-07-23 13:52:43 -04:00
|
|
|
# Lint the perl files #
|
2020-07-06 04:17:20 -04:00
|
|
|
#######################
|
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-08-07 08:58:40 -04:00
|
|
|
LintCodebase "PERL" "perl" "perlcritic" ".*\.\(pl\|pm\|t\)\$" "${FILE_ARRAY_PERL[@]}"
|
2020-07-06 04:17:20 -04:00
|
|
|
fi
|
|
|
|
|
2020-07-23 13:52:43 -04:00
|
|
|
################
|
|
|
|
# PHP LINTING #
|
|
|
|
################
|
2020-07-26 15:01:29 -04:00
|
|
|
if [ "${VALIDATE_PHP_BUILTIN}" == "true" ]; then
|
|
|
|
################################################
|
|
|
|
# Lint the PHP files using built-in PHP linter #
|
|
|
|
################################################
|
2020-02-03 15:54:43 -05:00
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-07-26 15:01:29 -04:00
|
|
|
LintCodebase "PHP_BUILTIN" "php" "php -l" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_BUILTIN[@]}"
|
2020-01-09 17:08:01 -05:00
|
|
|
fi
|
|
|
|
|
2020-07-26 15:01:29 -04:00
|
|
|
if [ "${VALIDATE_PHP_PHPCS}" == "true" ]; then
|
|
|
|
############################################
|
|
|
|
# Lint the PHP files using PHP CodeSniffer #
|
|
|
|
############################################
|
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-07-26 15:30:45 -04:00
|
|
|
LintCodebase "PHP_PHPCS" "phpcs" "phpcs --standard=${PHP_PHPCS_LINTER_RULES}" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_PHPCS[@]}"
|
2020-01-09 17:08:01 -05:00
|
|
|
fi
|
|
|
|
|
2020-08-03 15:43:38 -04:00
|
|
|
if [ "${VALIDATE_PHP_PHPSTAN}" == "true" ]; then
|
2020-06-28 07:07:51 -04:00
|
|
|
#######################
|
2020-08-03 15:43:38 -04:00
|
|
|
# Lint the PHP files using PHPStan #
|
2020-06-28 07:07:51 -04:00
|
|
|
#######################
|
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-08-04 13:24:15 -04:00
|
|
|
LintCodebase "PHP_PHPSTAN" "phpstan" "phpstan analyse --no-progress --no-ansi -c ${PHP_PHPSTAN_LINTER_RULES}" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_PHPSTAN[@]}"
|
2020-08-03 15:43:38 -04:00
|
|
|
fi
|
|
|
|
|
2020-07-26 15:01:29 -04:00
|
|
|
if [ "${VALIDATE_PHP_PSALM}" == "true" ]; then
|
|
|
|
##################################
|
|
|
|
# Lint the PHP files using Psalm #
|
|
|
|
##################################
|
2020-06-28 07:07:51 -04:00
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-07-26 15:30:45 -04:00
|
|
|
LintCodebase "PHP_PSALM" "psalm" "psalm --config=${PHP_PSALM_LINTER_RULES}" ".*\.\(php\)\$" "${FILE_ARRAY_PHP_PSALM[@]}"
|
2020-06-28 07:07:51 -04:00
|
|
|
fi
|
|
|
|
|
2020-06-19 12:13:13 -04:00
|
|
|
######################
|
|
|
|
# POWERSHELL LINTING #
|
|
|
|
######################
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ "${VALIDATE_POWERSHELL}" == "true" ]; then
|
2020-07-01 08:49:17 -04:00
|
|
|
###############################################################
|
|
|
|
# For POWERSHELL, ensure PSScriptAnalyzer module is available #
|
|
|
|
###############################################################
|
|
|
|
ValidatePowershellModules
|
2020-07-01 15:33:20 -04:00
|
|
|
|
2020-06-19 12:13:13 -04:00
|
|
|
#############################
|
|
|
|
# Lint the powershell files #
|
|
|
|
#############################
|
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-07-21 13:09:07 -04:00
|
|
|
LintCodebase "POWERSHELL" "pwsh" "Invoke-ScriptAnalyzer -EnableExit -Settings ${POWERSHELL_LINTER_RULES} -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "${FILE_ARRAY_POWERSHELL[@]}"
|
2020-06-19 12:13:13 -04:00
|
|
|
fi
|
|
|
|
|
2020-07-23 13:52:43 -04:00
|
|
|
####################
|
|
|
|
# PROTOBUF LINTING #
|
|
|
|
####################
|
|
|
|
if [ "${VALIDATE_PROTOBUF}" == "true" ]; then
|
|
|
|
#######################
|
|
|
|
# Lint the Protocol Buffers files #
|
|
|
|
#######################
|
2020-07-02 17:31:16 -04:00
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-07-23 13:52:43 -04:00
|
|
|
LintCodebase "PROTOBUF" "protolint" "protolint lint --config_path ${PROTOBUF_LINTER_RULES}" ".*\.\(proto\)\$" "${FILE_ARRAY_PROTOBUF[@]}"
|
2020-07-02 17:31:16 -04:00
|
|
|
fi
|
|
|
|
|
2020-08-20 10:44:11 -04:00
|
|
|
########################
|
|
|
|
# PYTHON BLACK LINTING #
|
|
|
|
########################
|
|
|
|
if [ "${VALIDATE_PYTHON_BLACK}" == "true" ]; then
|
|
|
|
#########################
|
|
|
|
# Lint the python files #
|
|
|
|
#########################
|
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-09-02 03:27:32 -04:00
|
|
|
LintCodebase "PYTHON_BLACK" "black" "black --config ${PYTHON_BLACK_LINTER_RULES} --diff --check" ".*\.\(py\)\$" "${FILE_ARRAY_PYTHON_BLACK[@]}"
|
2020-08-20 10:44:11 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
#########################
|
|
|
|
# PYTHON PYLINT LINTING #
|
|
|
|
#########################
|
2020-07-21 20:58:23 -04:00
|
|
|
if [ "${VALIDATE_PYTHON_PYLINT}" == "true" ]; then
|
|
|
|
#########################
|
|
|
|
# Lint the python files #
|
|
|
|
#########################
|
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-07-23 11:55:15 -04:00
|
|
|
LintCodebase "PYTHON_PYLINT" "pylint" "pylint --rcfile ${PYTHON_PYLINT_LINTER_RULES}" ".*\.\(py\)\$" "${FILE_ARRAY_PYTHON_PYLINT[@]}"
|
2020-07-21 20:58:23 -04:00
|
|
|
fi
|
|
|
|
|
2020-08-20 10:44:11 -04:00
|
|
|
#########################
|
|
|
|
# PYTHON FLAKE8 LINTING #
|
|
|
|
#########################
|
2020-07-21 20:58:23 -04:00
|
|
|
if [ "${VALIDATE_PYTHON_FLAKE8}" == "true" ]; then
|
2020-07-23 13:52:43 -04:00
|
|
|
#########################
|
|
|
|
# Lint the python files #
|
|
|
|
#########################
|
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-07-23 11:55:15 -04:00
|
|
|
LintCodebase "PYTHON_FLAKE8" "flake8" "flake8 --config=${PYTHON_FLAKE8_LINTER_RULES}" ".*\.\(py\)\$" "${FILE_ARRAY_PYTHON_FLAKE8[@]}"
|
2020-07-23 13:52:43 -04:00
|
|
|
fi
|
2020-06-25 02:13:19 -04:00
|
|
|
|
2020-08-20 10:44:11 -04:00
|
|
|
#############
|
2020-08-15 15:29:22 -04:00
|
|
|
# R LINTING #
|
2020-08-20 10:44:11 -04:00
|
|
|
#############
|
2020-08-15 15:29:22 -04:00
|
|
|
if [ "${VALIDATE_R}" == "true" ]; then
|
2020-08-17 08:01:25 -04:00
|
|
|
##########################
|
|
|
|
# Check for local config #
|
|
|
|
##########################
|
2020-08-27 15:26:05 -04:00
|
|
|
if [ ! -f "${GITHUB_WORKSPACE}/.lintr" ] && (( ${#FILE_ARRAY_R[@]} )); then
|
2020-08-17 08:01:25 -04:00
|
|
|
info "No .lintr configuration file found, using defaults."
|
2020-08-17 08:14:15 -04:00
|
|
|
cp $R_LINTER_RULES "$GITHUB_WORKSPACE"
|
2020-08-17 08:01:25 -04:00
|
|
|
fi
|
|
|
|
|
2020-08-17 08:14:15 -04:00
|
|
|
######################
|
|
|
|
# Lint the R files #
|
|
|
|
######################
|
2020-08-17 12:27:31 -04:00
|
|
|
LintCodebase "R" "lintr" "lintr::lint(File)" ".*\.\(r\|R\|Rmd\|rmd\)\$" "${FILE_ARRAY_R[@]}"
|
2020-08-15 15:29:22 -04:00
|
|
|
fi
|
|
|
|
|
2020-07-23 13:52:43 -04:00
|
|
|
################
|
|
|
|
# RAKU LINTING #
|
|
|
|
################
|
|
|
|
if [ "${VALIDATE_RAKU}" == "true" ]; then
|
|
|
|
#######################
|
|
|
|
# Lint the raku files #
|
|
|
|
#######################
|
2020-07-30 16:39:05 -04:00
|
|
|
if [ -e "${GITHUB_WORKSPACE}/META6.json" ]; then
|
|
|
|
cd "${GITHUB_WORKSPACE}" && zef install --deps-only --/test .
|
|
|
|
fi
|
2020-06-25 02:13:19 -04:00
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-07-23 13:52:43 -04:00
|
|
|
LintCodebase "RAKU" "raku" "raku -I ${GITHUB_WORKSPACE}/lib -c" ".*\.\(raku\|rakumod\|rakutest\|pm6\|pl6\|p6\)\$" "${FILE_ARRAY_RAKU[@]}"
|
2020-06-25 02:13:19 -04:00
|
|
|
fi
|
|
|
|
|
2020-07-04 18:14:27 -04:00
|
|
|
################
|
2020-07-23 13:52:43 -04:00
|
|
|
# RUBY LINTING #
|
2020-07-04 18:14:27 -04:00
|
|
|
################
|
2020-07-23 13:52:43 -04:00
|
|
|
if [ "${VALIDATE_RUBY}" == "true" ]; then
|
|
|
|
#######################
|
|
|
|
# Lint the ruby files #
|
|
|
|
#######################
|
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
|
|
|
LintCodebase "RUBY" "rubocop" "rubocop -c ${RUBY_LINTER_RULES} --force-exclusion" ".*\.\(rb\)\$" "${FILE_ARRAY_RUBY[@]}"
|
2020-07-04 18:14:27 -04:00
|
|
|
fi
|
|
|
|
|
2020-08-31 17:44:35 -04:00
|
|
|
#################
|
|
|
|
# SHFMT LINTING #
|
|
|
|
#################
|
|
|
|
if [ "${VALIDATE_SHELL_SHFMT}" == "true" ]; then
|
|
|
|
####################################
|
|
|
|
# Lint the files with shfmt #
|
|
|
|
####################################
|
|
|
|
EDITORCONFIG_FILE_PATH="${GITHUB_WORKSPACE}"/.editorconfig
|
|
|
|
if [ -e "$EDITORCONFIG_FILE_PATH" ]; then
|
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-08-31 18:06:15 -04:00
|
|
|
LintCodebase "SHELL_SHFMT" "shfmt" "shfmt -d" ".*\.\(sh\|bash\|dash\|ksh\)\$" "${FILE_ARRAY_BASH[@]}"
|
2020-08-31 17:44:35 -04:00
|
|
|
else
|
|
|
|
###############################
|
|
|
|
# No .editorconfig file found #
|
|
|
|
###############################
|
|
|
|
warn "No .editorconfig found at:[$EDITORCONFIG_FILE_PATH]"
|
|
|
|
debug "skipping shfmt"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2020-07-21 14:50:04 -04:00
|
|
|
######################
|
|
|
|
# AWS STATES LINTING #
|
|
|
|
######################
|
2020-07-21 15:39:14 -04:00
|
|
|
if [ "${VALIDATE_STATES}" == "true" ]; then
|
2020-07-23 01:30:12 -04:00
|
|
|
# If we are validating all codebase we need to build file list because not every json file is an aws states file
|
2020-07-21 13:09:07 -04:00
|
|
|
if [ "${VALIDATE_ALL_CODEBASE}" == "true" ]; then
|
2020-06-26 11:38:02 -04:00
|
|
|
###############################################################################
|
|
|
|
# Set the file seperator to newline to allow for grabbing objects with spaces #
|
|
|
|
###############################################################################
|
|
|
|
IFS=$'\n'
|
|
|
|
|
2020-08-06 20:49:23 -04:00
|
|
|
mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" -path "*/node_modules" -prune -o -type f -regex ".*\.\(json\)\$" 2>&1)
|
2020-07-01 17:40:40 -04:00
|
|
|
for FILE in "${LIST_FILES[@]}"; do
|
2020-07-23 01:30:12 -04:00
|
|
|
if DetectAWSStatesFIle "${FILE}"; then
|
|
|
|
FILE_ARRAY_STATES+=("${FILE}")
|
2020-06-25 02:13:19 -04:00
|
|
|
fi
|
|
|
|
done
|
2020-06-26 11:38:02 -04:00
|
|
|
|
|
|
|
###########################
|
|
|
|
# Set IFS back to default #
|
|
|
|
###########################
|
2020-07-21 13:09:07 -04:00
|
|
|
IFS="${DEFAULT_IFS}"
|
2020-06-25 02:13:19 -04:00
|
|
|
fi
|
|
|
|
|
2020-07-21 14:50:04 -04:00
|
|
|
#########################
|
|
|
|
# Lint the STATES files #
|
|
|
|
#########################
|
2020-07-23 01:30:12 -04:00
|
|
|
LintCodebase "STATES" "asl-validator" "asl-validator --json-path" "disabledfileext" "${FILE_ARRAY_STATES[@]}"
|
2020-07-04 18:14:27 -04:00
|
|
|
fi
|
|
|
|
|
2020-08-06 13:01:36 -04:00
|
|
|
###############
|
|
|
|
# SQL LINTING #
|
|
|
|
###############
|
|
|
|
if [ "${VALIDATE_SQL}" == "true" ]; then
|
|
|
|
######################
|
|
|
|
# Lint the SQL files #
|
|
|
|
######################
|
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-08-11 14:27:30 -04:00
|
|
|
LintCodebase "SQL" "sql-lint" "sql-lint --config ${SQL_LINTER_RULES}" ".*\.\(sql\)\$" "${FILE_ARRAY_SQL[@]}"
|
2020-08-06 13:01:36 -04:00
|
|
|
fi
|
|
|
|
|
2020-07-23 13:52:43 -04:00
|
|
|
#####################
|
|
|
|
# TERRAFORM LINTING #
|
|
|
|
#####################
|
|
|
|
if [ "${VALIDATE_TERRAFORM}" == "true" ]; then
|
|
|
|
############################
|
|
|
|
# Lint the Terraform files #
|
|
|
|
############################
|
2020-06-25 02:13:19 -04:00
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-07-23 13:52:43 -04:00
|
|
|
LintCodebase "TERRAFORM" "tflint" "tflint -c ${TERRAFORM_LINTER_RULES}" ".*\.\(tf\)\$" "${FILE_ARRAY_TERRAFORM[@]}"
|
2020-06-25 02:13:19 -04:00
|
|
|
fi
|
|
|
|
|
2020-07-24 09:20:41 -04:00
|
|
|
###############################
|
2020-07-22 21:40:43 -04:00
|
|
|
# TERRAFORM TERRASCAN LINTING #
|
2020-07-24 09:20:41 -04:00
|
|
|
###############################
|
2020-07-22 21:40:43 -04:00
|
|
|
if [ "${VALIDATE_TERRAFORM_TERRASCAN}" == "true" ]; then
|
|
|
|
############################
|
|
|
|
# Lint the Terraform files #
|
|
|
|
############################
|
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-08-24 15:42:15 -04:00
|
|
|
LintCodebase "TERRAFORM_TERRASCAN" "terrascan" "terrascan scan -p /root/.terrascan/pkg/policies/opa/rego/ -t aws -f " ".*\.\(tf\)\$" "${FILE_ARRAY_TERRAFORM_TERRASCAN[@]}"
|
2020-07-22 21:40:43 -04:00
|
|
|
fi
|
|
|
|
|
2020-07-24 09:20:41 -04:00
|
|
|
###############
|
|
|
|
# TSX LINTING #
|
|
|
|
###############
|
2020-07-23 13:52:43 -04:00
|
|
|
if [ "${VALIDATE_TSX}" == "true" ]; then
|
2020-07-24 09:20:41 -04:00
|
|
|
######################
|
|
|
|
# Lint the TSX files #
|
|
|
|
######################
|
2020-07-23 13:52:43 -04:00
|
|
|
LintCodebase "TSX" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(tsx\)\$" "${FILE_ARRAY_TSX[@]}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
######################
|
|
|
|
# TYPESCRIPT LINTING #
|
|
|
|
######################
|
|
|
|
if [ "${VALIDATE_TYPESCRIPT_ES}" == "true" ]; then
|
|
|
|
#############################
|
|
|
|
# Lint the Typescript files #
|
|
|
|
#############################
|
|
|
|
LintCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(ts\)\$" "${FILE_ARRAY_TYPESCRIPT_ES[@]}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
######################
|
|
|
|
# TYPESCRIPT LINTING #
|
|
|
|
######################
|
|
|
|
if [ "${VALIDATE_TYPESCRIPT_STANDARD}" == "true" ]; then
|
2020-07-04 18:14:27 -04:00
|
|
|
#################################
|
2020-07-23 13:52:43 -04:00
|
|
|
# Get Typescript standard rules #
|
2020-07-04 18:14:27 -04:00
|
|
|
#################################
|
2020-07-23 13:52:43 -04:00
|
|
|
GetStandardRules "typescript"
|
2020-07-04 18:14:27 -04:00
|
|
|
#############################
|
2020-07-23 13:52:43 -04:00
|
|
|
# Lint the Typescript files #
|
2020-07-04 18:14:27 -04:00
|
|
|
#############################
|
2020-07-23 13:52:43 -04:00
|
|
|
LintCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin ${TYPESCRIPT_STANDARD_LINTER_RULES}" ".*\.\(ts\)\$" "${FILE_ARRAY_TYPESCRIPT_STANDARD[@]}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
###############
|
|
|
|
# XML LINTING #
|
|
|
|
###############
|
|
|
|
if [ "${VALIDATE_XML}" == "true" ]; then
|
|
|
|
######################
|
|
|
|
# Lint the XML Files #
|
|
|
|
######################
|
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
|
|
|
LintCodebase "XML" "xmllint" "xmllint" ".*\.\(xml\)\$" "${FILE_ARRAY_XML[@]}"
|
2020-07-04 18:14:27 -04:00
|
|
|
fi
|
|
|
|
|
2020-08-06 11:42:57 -04:00
|
|
|
################
|
2020-07-24 12:20:22 -04:00
|
|
|
# YAML LINTING #
|
2020-08-06 11:42:57 -04:00
|
|
|
################
|
2020-07-23 13:52:43 -04:00
|
|
|
if [ "${VALIDATE_YAML}" == "true" ]; then
|
|
|
|
######################
|
|
|
|
# Lint the Yml Files #
|
|
|
|
######################
|
|
|
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
2020-07-24 12:20:22 -04:00
|
|
|
LintCodebase "YAML" "yamllint" "yamllint -c ${YAML_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "${FILE_ARRAY_YAML[@]}"
|
2020-07-23 13:52:43 -04:00
|
|
|
fi
|
|
|
|
|
2020-07-22 15:49:26 -04:00
|
|
|
###########
|
|
|
|
# Reports #
|
|
|
|
###########
|
|
|
|
Reports
|
|
|
|
|
2019-10-21 12:05:55 -04:00
|
|
|
##########
|
|
|
|
# Footer #
|
|
|
|
##########
|
|
|
|
Footer
|