diff --git a/Dockerfile b/Dockerfile index 548a1532..fd5a3614 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,39 +13,66 @@ FROM python:alpine # Label the instance and set maintainer # ######################################### LABEL com.github.actions.name="GitHub Super-Linter" \ - com.github.actions.description="Lint your codebase with Github Actions" \ + com.github.actions.description="Lint your code base with Github Actions" \ com.github.actions.icon="code" \ com.github.actions.color="red" \ maintainer="GitHub DevOps " -################## -# Run the Update # -################## +#################### +# Run APK installs # +#################### RUN apk add --no-cache \ - bash git musl-dev jq \ - npm nodejs bash git musl-dev jq gcc curl + bash git musl-dev curl gcc jq \ + npm nodejs \ + libxml2-utils perl \ + ruby ruby-dev ruby-bundler ruby-rdoc make\ + py3-setuptools ansible-lint -RUN pip install --upgrade --no-cache-dir \ - awscli aws-sam-cli yq +##################### +# Run Pip3 Installs # +##################### +RUN pip3 install --upgrade --no-cache-dir \ + yamllint pylint -#################################### -# Setup AWS CLI Command Completion # -#################################### -RUN echo complete -C '/usr/local/bin/aws_completer' aws >> ~/.bashrc +#################### +# Run NPM Installs # +#################### +RUN npm -g install \ + markdownlint-cli \ + jsonlint prettyjson \ + coffeelint + +#################### +# Run GEM installs # +#################### +RUN gem install rubocop + +###################### +# Install shellcheck # +###################### +RUN wget -qO- "https://storage.googleapis.com/shellcheck/shellcheck-stable.linux.x86_64.tar.xz" | tar -xJv \ + && cp "shellcheck-stable/shellcheck" /usr/bin/ ########################################### # Load GitHub Env Vars for Github Actions # ########################################### -ENV GITHUB_SHA=${GITHUB_SHA} -ENV GITHUB_EVENT_PATH=${GITHUB_EVENT_PATH} -ENV GITHUB_WORKSPACE=${GITHUB_WORKSPACE} +ENV GITHUB_SHA=${GITHUB_SHA} \ + GITHUB_EVENT_PATH=${GITHUB_EVENT_PATH} \ + GITHUB_WORKSPACE=${GITHUB_WORKSPACE} -########################### -# Copy files to container # -########################### +############################# +# Copy scripts to container # +############################# COPY lib /action/lib +################################## +# Copy linter rules to container # +################################## +COPY TEMPLATES /action/lib/.automation + ###################### # Set the entrypoint # ###################### ENTRYPOINT ["/action/lib/entrypoint.sh"] + +#CMD tail -f /dev/null diff --git a/README.md b/README.md index 6eda95b5..0a8dcd8d 100644 --- a/README.md +++ b/README.md @@ -3,14 +3,16 @@ This repository is for the **GitHub** Action to run a **Super-Linter**. Developers on **GitHub** can call this Action to lint their code base with the following list of linters: -- Ruby (Rubocop) -- Shell (Shellcheck) -- Ansible (Ansible-lint) -- YAML (Yamllint) -- Python3 (Pylint) -- JSON (JsonLint) -- MarkDown (Markdownlint) -- XML (LibXML) +- **Ruby** (Rubocop) +- **Shell** (Shellcheck) +- **Ansible** (Ansible-lint) +- **YAML** (Yamllint) +- **Python3** (Pylint) +- **JSON** (JsonLint) +- **MarkDown** (Markdownlint) +- **Perl** (Perl) +- **XML** (LibXML) +- **Coffeescript** (coffeelint) ## How to use @@ -78,10 +80,10 @@ jobs: ## How to contribute -If you would like to help contribute to this **Github** Action, please see [CONTRIBUTING](https://github.com/github-services-engineering/super-linter/blob/master/.github/CONTRIBUTING.md) +If you would like to help contribute to this **Github** Action, please see [CONTRIBUTING](https://github.com/github/super-linter/blob/master/.github/CONTRIBUTING.md) -------------------------------------------------------------------------------- ### License -- [License](https://github.com/github-services-engineering/super-linter/blob/master/LICENSE) +- [License](https://github.com/github/super-linter/blob/master/LICENSE) diff --git a/TEMPLATE/README.md b/TEMPLATE/README.md deleted file mode 100644 index 316e55bf..00000000 --- a/TEMPLATE/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# TEMPLATE/aws-config.yml - -The file in this folder is for the user base to use as a template to consume the **GitHub** Action: -- **Deploy-NodeJS-AWS-SAM** - -The user will need to copy the file to the location: - -- `/github/aws-config.yml` in their repository - -The file will be parsed at run time on the local branch to load all variables needed to deploy their **NodeJS** application to **AWS** Serverless utilizing **AWS SAM**. -The **GitHub** Action will inform the user via the **Checks API** on the status and success of the deployment process. diff --git a/TEMPLATE/aws-config.yml b/TEMPLATE/aws-config.yml deleted file mode 100644 index 6028e2c5..00000000 --- a/TEMPLATE/aws-config.yml +++ /dev/null @@ -1,43 +0,0 @@ ---- - -########################################################## -# AWS Configuration file for NodeJS Deploy GitHub Action # -# # -# NOTE: This file holds the variables needed # -# to configure the GitHub Deploy NodeJS # -# on AWS Serverless # -# # -# This file needs to be in the location: # -# - .github/aws-config.yml # -# in your repository to be parsed at run time # -########################################################## - -######################################## -# AWS S3 Bucket for package and deploy # -######################################## -# NOTE: This bucket must exist before the GitHub Action -s3_bucket: - -################################## -# AWS Cloud Formation Stack name # -################################## -# NOTE: Defaults to "mystack" if left empty -aws_stack_name: mystack - -#################### -# AWS SAM Template # -#################### -# NOTE: This is the AWS SAM template.yml file that we need to deploy -# Pathing is from root of repository: -# Example: -# if file is called `template.yml` and is in the root of repository -# under the '.github' folder: -# sam_template: .github/template.yml -sam_template: - -################################ -# region for connection to AWS # -################################ -# Default region is: us-west-2 -# if not provided below -region: us-west-2 diff --git a/TEMPLATES/.ansible-lint.yml b/TEMPLATES/.ansible-lint.yml new file mode 100644 index 00000000..0007c68d --- /dev/null +++ b/TEMPLATES/.ansible-lint.yml @@ -0,0 +1,51 @@ +########################## +########################## +## Ansible Linter rules ## +########################## +########################## + +############################# +# Exclude paths from linter # +############################# +#exclude_paths: + +######################## +# Make output parsable # +######################## +parseable: true + +####################### +# Set output to quiet # +####################### +quiet: true + +##################### +# Path to rules dir # +##################### +#rulesdir: + +################ +# Tags to skip # +################ +skip_list: + - '602' # Allow compare to empty string + - '204' # Allow string length greater that 160 chars + - '301' # False positives for running command shells + - '303' # Allow git commands for push add, etc... + - '305' # Allow use of shell when you want + - '503' # Allow step to run like handler + +################## +# Tags to follow # +################## +#tags: + +############# +# Use rules # +############# +use_default_rules: true + +################# +# Set verbosity # +################# +verbosity: 1 diff --git a/TEMPLATES/.coffee-lint.json b/TEMPLATES/.coffee-lint.json new file mode 100644 index 00000000..053b20dc --- /dev/null +++ b/TEMPLATES/.coffee-lint.json @@ -0,0 +1,135 @@ +{ + "arrow_spacing": { + "level": "ignore" + }, + "braces_spacing": { + "level": "ignore", + "spaces": 0, + "empty_object_spaces": 0 + }, + "camel_case_classes": { + "level": "error" + }, + "coffeescript_error": { + "level": "error" + }, + "colon_assignment_spacing": { + "level": "ignore", + "spacing": { + "left": 0, + "right": 0 + } + }, + "cyclomatic_complexity": { + "level": "ignore", + "value": 10 + }, + "duplicate_key": { + "level": "error" + }, + "empty_constructor_needs_parens": { + "level": "ignore" + }, + "ensure_comprehensions": { + "level": "warn" + }, + "eol_last": { + "level": "ignore" + }, + "indentation": { + "value": 2, + "level": "warn" + }, + "line_endings": { + "level": "ignore", + "value": "unix" + }, + "max_line_length": { + "value": 80, + "level": "ignore", + "limitComments": true + }, + "missing_fat_arrows": { + "level": "ignore", + "is_strict": false + }, + "newlines_after_classes": { + "value": 3, + "level": "ignore" + }, + "no_backticks": { + "level": "error" + }, + "no_debugger": { + "level": "warn", + "console": false + }, + "no_empty_functions": { + "level": "ignore" + }, + "no_empty_param_list": { + "level": "ignore" + }, + "no_implicit_braces": { + "level": "ignore", + "strict": true + }, + "no_implicit_parens": { + "level": "ignore", + "strict": true + }, + "no_interpolation_in_single_quotes": { + "level": "ignore" + }, + "no_nested_string_interpolation": { + "level": "warn" + }, + "no_plusplus": { + "level": "ignore" + }, + "no_private_function_fat_arrows": { + "level": "warn" + }, + "no_stand_alone_at": { + "level": "ignore" + }, + "no_tabs": { + "level": "error" + }, + "no_this": { + "level": "ignore" + }, + "no_throwing_strings": { + "level": "error" + }, + "no_trailing_semicolons": { + "level": "error" + }, + "no_trailing_whitespace": { + "level": "ignore", + "allowed_in_comments": false, + "allowed_in_empty_lines": true + }, + "no_unnecessary_double_quotes": { + "level": "ignore" + }, + "no_unnecessary_fat_arrows": { + "level": "warn" + }, + "non_empty_constructor_needs_parens": { + "level": "ignore" + }, + "prefer_english_operator": { + "level": "ignore", + "doubleNotLevel": "ignore" + }, + "space_operators": { + "level": "ignore" + }, + "spacing_after_comma": { + "level": "ignore" + }, + "transform_messes_up_line_numbers": { + "level": "warn" + } +} diff --git a/TEMPLATES/.markdown-lint.yml b/TEMPLATES/.markdown-lint.yml new file mode 100644 index 00000000..f2dec62f --- /dev/null +++ b/TEMPLATES/.markdown-lint.yml @@ -0,0 +1,35 @@ +--- +########################### +########################### +## Markdown Linter rules ## +########################### +########################### + +# Linter rules doc: +# - https://github.com/DavidAnson/markdownlint +# +# Note: +# To comment out a single error: +# +# any violations you want +# +# + +############### +# Rules by id # +############### +MD004: false # Unordered list style +MD007: + indent: 2 # Unordered list indentation +MD013: + line_length: 808 # Line length +MD026: + punctuation: ".,;:!。,;:" # List of not allowed +MD029: false # Ordered list item prefix +MD033: false # Allow inline HTML +MD036: false # Emphasis used instead of a heading + +################# +# Rules by tags # +################# +blank_lines: false # Error on blank lines diff --git a/TEMPLATES/.python-lint b/TEMPLATES/.python-lint new file mode 100644 index 00000000..8e9cc00e --- /dev/null +++ b/TEMPLATES/.python-lint @@ -0,0 +1,542 @@ +[MASTER] + +# A comma-separated list of package or module names from where C extensions may +# be loaded. Extensions are loading into the active Python interpreter and may +# run arbitrary code +extension-pkg-whitelist= + +# Add files or directories to the blacklist. They should be base names, not +# paths. +ignore=CVS + +# Add files or directories matching the regex patterns to the blacklist. The +# regex matches against base names, not paths. +ignore-patterns= + +# Python code to execute, usually for sys.path manipulation such as +# pygtk.require(). +#init-hook= + +# Use multiple processes to speed up Pylint. +jobs=1 + +# List of plugins (as comma separated values of python modules names) to load, +# usually to register additional checkers. +load-plugins= + +# Pickle collected data for later comparisons. +persistent=yes + +# Specify a configuration file. +#rcfile= + +# When enabled, pylint would attempt to guess common misconfiguration and emit +# user-friendly hints instead of false-positive error messages +suggestion-mode=yes + +# Allow loading of arbitrary C extensions. Extensions are imported into the +# active Python interpreter and may run arbitrary code. +unsafe-load-any-extension=no + + +[MESSAGES CONTROL] + +# Only show warnings with the listed confidence levels. Leave empty to show +# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED +confidence= + +# Disable the message, report, category or checker with the given id(s). You +# can either give multiple identifiers separated by comma (,) or put this +# option multiple times (only on the command line, not in the configuration +# file where it should appear only once).You can also use "--disable=all" to +# disable everything first and then reenable specific checks. For example, if +# you want to run only the similarities checker, you can use "--disable=all +# --enable=similarities". If you want to run only the classes checker, but have +# no Warning level messages displayed, use"--disable=all --enable=classes +# --disable=W" +disable=print-statement, + parameter-unpacking, + unpacking-in-except, + old-raise-syntax, + backtick, + long-suffix, + old-ne-operator, + old-octal-literal, + import-star-module-level, + non-ascii-bytes-literal, + raw-checker-failed, + bad-inline-option, + locally-disabled, + locally-enabled, + file-ignored, + suppressed-message, + useless-suppression, + deprecated-pragma, + apply-builtin, + basestring-builtin, + buffer-builtin, + cmp-builtin, + coerce-builtin, + execfile-builtin, + file-builtin, + long-builtin, + raw_input-builtin, + reduce-builtin, + standarderror-builtin, + unicode-builtin, + xrange-builtin, + coerce-method, + delslice-method, + getslice-method, + setslice-method, + no-absolute-import, + old-division, + dict-iter-method, + dict-view-method, + next-method-called, + metaclass-assignment, + indexing-exception, + raising-string, + reload-builtin, + oct-method, + hex-method, + nonzero-method, + cmp-method, + input-builtin, + round-builtin, + intern-builtin, + unichr-builtin, + map-builtin-not-iterating, + zip-builtin-not-iterating, + range-builtin-not-iterating, + filter-builtin-not-iterating, + using-cmp-argument, + eq-without-hash, + div-method, + idiv-method, + rdiv-method, + exception-message-attribute, + invalid-str-codec, + sys-max-int, + bad-python3-import, + deprecated-string-function, + deprecated-str-translate-call, + deprecated-itertools-function, + deprecated-types-field, + next-method-defined, + dict-items-not-iterating, + dict-keys-not-iterating, + dict-values-not-iterating + +# Enable the message, report, category or checker with the given id(s). You can +# either give multiple identifier separated by comma (,) or put this option +# multiple time (only on the command line, not in the configuration file where +# it should appear only once). See also the "--disable" option for examples. +enable=c-extension-no-member + + +[REPORTS] + +# Python expression which should return a note less than 10 (10 is the highest +# note). You have access to the variables errors warning, statement which +# respectively contain the number of errors / warnings messages and the total +# number of statements analyzed. This is used by the global evaluation report +# (RP0004). +evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) + +# Template used to display messages. This is a python new-style format string +# used to format the message information. See doc for all details +#msg-template= + +# Set the output format. Available formats are text, parseable, colorized, json +# and msvs (visual studio).You can also give a reporter class, eg +# mypackage.mymodule.MyReporterClass. +output-format=text + +# Tells whether to display a full report or only the messages +reports=no + +# Activate the evaluation score. +score=yes + + +[REFACTORING] + +# Maximum number of nested blocks for function / method body +max-nested-blocks=5 + +# Complete name of functions that never returns. When checking for +# inconsistent-return-statements if a never returning function is called then +# it will be considered as an explicit return statement and no message will be +# printed. +never-returning-functions=optparse.Values,sys.exit + + +[VARIABLES] + +# List of additional names supposed to be defined in builtins. Remember that +# you should avoid to define new builtins when possible. +additional-builtins= + +# Tells whether unused global variables should be treated as a violation. +allow-global-unused-variables=yes + +# List of strings which can identify a callback function by name. A callback +# name must start or end with one of those strings. +callbacks=cb_, + _cb + +# A regular expression matching the name of dummy variables (i.e. expectedly +# not used). +dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ + +# Argument names that match this expression will be ignored. Default to name +# with leading underscore +ignored-argument-names=_.*|^ignored_|^unused_ + +# Tells whether we should check for unused import in __init__ files. +init-import=no + +# List of qualified module names which can have objects that can redefine +# builtins. +redefining-builtins-modules=six.moves,past.builtins,future.builtins + + +[LOGGING] + +# Logging modules to check that the string format arguments are in logging +# function parameter format +logging-modules=logging + + +[TYPECHECK] + +# List of decorators that produce context managers, such as +# contextlib.contextmanager. Add to this list to register other decorators that +# produce valid context managers. +contextmanager-decorators=contextlib.contextmanager + +# List of members which are set dynamically and missed by pylint inference +# system, and so shouldn't trigger E1101 when accessed. Python regular +# expressions are accepted. +generated-members= + +# Tells whether missing members accessed in mixin class should be ignored. A +# mixin class is detected if its name ends with "mixin" (case insensitive). +ignore-mixin-members=yes + +# This flag controls whether pylint should warn about no-member and similar +# checks whenever an opaque object is returned when inferring. The inference +# can return multiple potential results while evaluating a Python object, but +# some branches might not be evaluated, which results in partial inference. In +# that case, it might be useful to still emit no-member and other checks for +# the rest of the inferred objects. +ignore-on-opaque-inference=yes + +# List of class names for which member attributes should not be checked (useful +# for classes with dynamically set attributes). This supports the use of +# qualified names. +ignored-classes=optparse.Values,thread._local,_thread._local + +# List of module names for which member attributes should not be checked +# (useful for modules/projects where namespaces are manipulated during runtime +# and thus existing member attributes cannot be deduced by static analysis. It +# supports qualified module names, as well as Unix pattern matching. +ignored-modules= + +# Show a hint with possible names when a member name was not found. The aspect +# of finding the hint is based on edit distance. +missing-member-hint=yes + +# The minimum edit distance a name should have in order to be considered a +# similar match for a missing member name. +missing-member-hint-distance=1 + +# The total number of similar names that should be taken in consideration when +# showing a hint for a missing member. +missing-member-max-choices=1 + + +[MISCELLANEOUS] + +# List of note tags to take in consideration, separated by a comma. +notes=FIXME, + XXX, + TODO + + +[BASIC] + +# Naming style matching correct argument names +argument-naming-style=snake_case + +# Regular expression matching correct argument names. Overrides argument- +# naming-style +#argument-rgx= + +# Naming style matching correct attribute names +attr-naming-style=snake_case + +# Regular expression matching correct attribute names. Overrides attr-naming- +# style +#attr-rgx= + +# Bad variable names which should always be refused, separated by a comma +bad-names=foo, + bar, + baz, + toto, + tutu, + tata + +# Naming style matching correct class attribute names +class-attribute-naming-style=any + +# Regular expression matching correct class attribute names. Overrides class- +# attribute-naming-style +#class-attribute-rgx= + +# Naming style matching correct class names +class-naming-style=PascalCase + +# Regular expression matching correct class names. Overrides class-naming-style +#class-rgx= + +# Naming style matching correct constant names +const-naming-style=UPPER_CASE + +# Regular expression matching correct constant names. Overrides const-naming- +# style +#const-rgx= + +# Minimum line length for functions/classes that require docstrings, shorter +# ones are exempt. +docstring-min-length=-1 + +# Naming style matching correct function names +function-naming-style=snake_case + +# Regular expression matching correct function names. Overrides function- +# naming-style +#function-rgx= + +# Good variable names which should always be accepted, separated by a comma +good-names=i, + j, + k, + ex, + Run, + _ + +# Include a hint for the correct naming format with invalid-name +include-naming-hint=no + +# Naming style matching correct inline iteration names +inlinevar-naming-style=any + +# Regular expression matching correct inline iteration names. Overrides +# inlinevar-naming-style +#inlinevar-rgx= + +# Naming style matching correct method names +method-naming-style=snake_case + +# Regular expression matching correct method names. Overrides method-naming- +# style +#method-rgx= + +# Naming style matching correct module names +module-naming-style=snake_case + +# Regular expression matching correct module names. Overrides module-naming- +# style +#module-rgx= + +# Colon-delimited sets of names that determine each other's naming style when +# the name regexes allow several styles. +name-group= + +# Regular expression which should only match function or class names that do +# not require a docstring. +no-docstring-rgx=^_ + +# List of decorators that produce properties, such as abc.abstractproperty. Add +# to this list to register other decorators that produce valid properties. +property-classes=abc.abstractproperty + +# Naming style matching correct variable names +variable-naming-style=snake_case + +# Regular expression matching correct variable names. Overrides variable- +# naming-style +#variable-rgx= + + +[SPELLING] + +# Limits count of emitted suggestions for spelling mistakes +max-spelling-suggestions=4 + +# Spelling dictionary name. Available dictionaries: none. To make it working +# install python-enchant package. +spelling-dict= + +# List of comma separated words that should not be checked. +spelling-ignore-words= + +# A path to a file that contains private dictionary; one word per line. +spelling-private-dict-file= + +# Tells whether to store unknown words to indicated private dictionary in +# --spelling-private-dict-file option instead of raising a message. +spelling-store-unknown-words=no + + +[FORMAT] + +# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. +expected-line-ending-format= + +# Regexp for a line that is allowed to be longer than the limit. +ignore-long-lines=^\s*(# )??$ + +# Number of spaces of indent required inside a hanging or continued line. +indent-after-paren=4 + +# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 +# tab). +indent-string=' ' + +# Maximum number of characters on a single line. +max-line-length=100 + +# Maximum number of lines in a module +max-module-lines=1000 + +# List of optional constructs for which whitespace checking is disabled. `dict- +# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. +# `trailing-comma` allows a space between comma and closing bracket: (a, ). +# `empty-line` allows space-only lines. +no-space-check=trailing-comma, + dict-separator + +# Allow the body of a class to be on the same line as the declaration if body +# contains single statement. +single-line-class-stmt=no + +# Allow the body of an if to be on the same line as the test if there is no +# else. +single-line-if-stmt=no + + +[SIMILARITIES] + +# Ignore comments when computing similarities. +ignore-comments=yes + +# Ignore docstrings when computing similarities. +ignore-docstrings=yes + +# Ignore imports when computing similarities. +ignore-imports=no + +# Minimum lines number of a similarity. +min-similarity-lines=4 + + +[DESIGN] + +# Maximum number of arguments for function / method +max-args=5 + +# Maximum number of attributes for a class (see R0902). +max-attributes=7 + +# Maximum number of boolean expressions in a if statement +max-bool-expr=5 + +# Maximum number of branch for function / method body +max-branches=12 + +# Maximum number of locals for function / method body +max-locals=15 + +# Maximum number of parents for a class (see R0901). +max-parents=7 + +# Maximum number of public methods for a class (see R0904). +max-public-methods=20 + +# Maximum number of return / yield for function / method body +max-returns=6 + +# Maximum number of statements in function / method body +max-statements=50 + +# Minimum number of public methods for a class (see R0903). +min-public-methods=2 + + +[IMPORTS] + +# Allow wildcard imports from modules that define __all__. +allow-wildcard-with-all=no + +# Analyse import fallback blocks. This can be used to support both Python 2 and +# 3 compatible code, which means that the block might have code that exists +# only in one or another interpreter, leading to false positives when analysed. +analyse-fallback-blocks=no + +# Deprecated modules which should not be used, separated by a comma +deprecated-modules=regsub, + TERMIOS, + Bastion, + rexec + +# Create a graph of external dependencies in the given file (report RP0402 must +# not be disabled) +ext-import-graph= + +# Create a graph of every (i.e. internal and external) dependencies in the +# given file (report RP0402 must not be disabled) +import-graph= + +# Create a graph of internal dependencies in the given file (report RP0402 must +# not be disabled) +int-import-graph= + +# Force import order to recognize a module as part of the standard +# compatibility libraries. +known-standard-library= + +# Force import order to recognize a module as part of a third party library. +known-third-party=enchant + + +[CLASSES] + +# List of method names used to declare (i.e. assign) instance attributes. +defining-attr-methods=__init__, + __new__, + setUp + +# List of member names, which should be excluded from the protected access +# warning. +exclude-protected=_asdict, + _fields, + _replace, + _source, + _make + +# List of valid names for the first argument in a class method. +valid-classmethod-first-arg=cls + +# List of valid names for the first argument in a metaclass class method. +valid-metaclass-classmethod-first-arg=mcs + + +[EXCEPTIONS] + +# Exceptions that will emit a warning when being caught. Defaults to +# "Exception" +overgeneral-exceptions=Exception diff --git a/TEMPLATES/.ruby-lint.yml b/TEMPLATES/.ruby-lint.yml new file mode 100644 index 00000000..e9608eed --- /dev/null +++ b/TEMPLATES/.ruby-lint.yml @@ -0,0 +1,189 @@ +--- +####################### +# Rubocop Config file # +####################### + +################################################################################ +############################## Rails Rules ##################################### +################################################################################ + +# Set the linter to enable rails rules +Rails: + Enabled: true + +################################################################################ +############################# Security Rules ################################### +################################################################################ + +# Security rules +Security/Open: + Enabled: false +################################################################################ +############################# Metrics Rules #################################### +################################################################################ + +# Commonly used screens these days easily fit more than 80 characters. +Metrics/LineLength: + Max: 120 + +# Too short methods lead to extraction of single-use methods, which can make +# the code easier to read (by naming things), but can also clutter the class +Metrics/MethodLength: + Max: 30 + +# The guiding principle of classes is SRP, +# SRP can't be accurately measured by LoC +Metrics/ClassLength: + Max: 1500 + +# Turn off the Assignment Branch Condition size for the case of these scripts +Metrics/AbcSize: + Enabled: false + +# Set the complexity of the metrics +Metrics/PerceivedComplexity: + Max: 10 + +# Set the complexity of the cyle +Metrics/CyclomaticComplexity: + Max: 10 + +################################################################################ +########################## Layout Rules ######################################## +################################################################################ + +# No space makes the method definition shorter and differentiates +# from a regular assignment. +Layout/SpaceAroundEqualsInParameterDefault: + EnforcedStyle: no_space + +# Most readable form. +Layout/AlignHash: + EnforcedHashRocketStyle: table + EnforcedColonStyle: table + +# Indenting the chained dots beneath each other is not supported by this cop, +# see https://github.com/bbatsov/rubocop/issues/1633 +Layout/MultilineOperationIndentation: + Enabled: false + +Layout/SpaceInsideBlockBraces: + # The space here provides no real gain in readability while consuming + # horizontal space that could be used for a better parameter name. + # Also {| differentiates better from a hash than { | does. + SpaceBeforeBlockParameters: false + +# No trailing space differentiates better from the block: +# foo} means hash, foo } means block. +Layout/SpaceInsideHashLiteralBraces: + EnforcedStyle: no_space + +################################################################################ +########################### Style Rules ######################################## +################################################################################ + +# Single quotes being faster is hardly measurable and only affects parse time. +# Enforcing double quotes reduces the times where you need to change them +# when introducing an interpolation. Use single quotes only if their semantics +# are needed. +Style/StringLiterals: + EnforcedStyle: double_quotes + +# We do not need to support Ruby 1.9, so this is good to use. +Style/SymbolArray: + Enabled: true + +# Mixing the styles looks just silly. +Style/HashSyntax: + EnforcedStyle: ruby19_no_mixed_keys + +# has_key? and has_value? are far more readable than key? and value? +Style/PreferredHashMethods: + Enabled: false + +# String#% is by far the least verbose and only object oriented variant. +Style/FormatString: + EnforcedStyle: percent + +Style/CollectionMethods: + Enabled: true + PreferredMethods: + # inject seems more common in the community. + reduce: "inject" + +# Either allow this style or don't. Marking it as safe with parenthesis +# is silly. Let's try to live without them for now. +Style/ParenthesesAroundCondition: + AllowSafeAssignment: false + +# A specialized exception class will take one or more arguments +# and construct the message from it. So both variants make sense. +Style/RaiseArgs: + Enabled: false + +# Fail is an alias of raise. Avoid aliases, +# it's more cognitive load for no gain. The argument that fail +# should be used to abort the program is wrong too, +# there's Kernel#abort for that. +Style/SignalException: + EnforcedStyle: only_raise + +# { ... } for multi-line blocks is okay, follow Weirichs rule instead: +# https://web.archive.org/web/20140221124509/http://onestepback.org/index.cgi/Tech/Ruby/BraceVsDoEnd.rdoc +Style/BlockDelimiters: + Enabled: false + +# do / end blocks should be used for side effects, +# methods that run a block for side effects and have +# a useful return value are rare, assign the return +# value to a local variable for those cases. +Style/MethodCalledOnDoEndBlock: + Enabled: true + +# Enforcing the names of variables? To single letter ones? Just no. +Style/SingleLineBlockParams: + Enabled: false + +# Check with yard instead. +Style/Documentation: + Enabled: false + +# Style preference +Style/MethodDefParentheses: + Enabled: false + +################################################################################ +########################### Linter Rules ####################################### +################################################################################ + +# There are valid cases, for example debugging Cucumber steps, +# also they'll fail CI anyway +Lint/Debugger: + Enabled: false + +# Shadowing outer local variables with block parameters is often useful +# to not reinvent a new name for the same thing, it highlights the relation +# between the outer variable and the parameter. The cases where it's actually +# confusing are rare, and usually bad for other reasons already, for example +# because the method is too long. +Lint/ShadowingOuterLocalVariable: + Enabled: false + +# Suppressing exceptions can be perfectly fine, and be it to avoid to +# explicitly type nil into the rescue since that's what you want to return, +# or suppressing LoadError for optional dependencies +Lint/HandleExceptions: + Enabled: false + +Lint/AssignmentInCondition: + AllowSafeAssignment: false + +################################################################################ +############################ Naming Rules ###################################### +################################################################################ + +# This is just silly. Calling the argument `other` in all cases makes no sense. +Naming/BinaryOperatorParameterName: + Enabled: false + +################################################################################ diff --git a/TEMPLATES/.yaml-lint.yml b/TEMPLATES/.yaml-lint.yml new file mode 100644 index 00000000..faccea80 --- /dev/null +++ b/TEMPLATES/.yaml-lint.yml @@ -0,0 +1,59 @@ +--- +########################################### +# These are the rules used for # +# linting all the yaml files in the stack # +# NOTE: # +# You can disble line with: # +# # yamllint disable-line # +########################################### +rules: + braces: + level: warning + min-spaces-inside: 0 + max-spaces-inside: 0 + min-spaces-inside-empty: 1 + max-spaces-inside-empty: 5 + brackets: + level: warning + min-spaces-inside: 0 + max-spaces-inside: 0 + min-spaces-inside-empty: 1 + max-spaces-inside-empty: 5 + colons: + level: warning + max-spaces-before: 0 + max-spaces-after: 1 + commas: + level: warning + max-spaces-before: 0 + min-spaces-after: 1 + max-spaces-after: 1 + comments: disable + comments-indentation: disable + document-end: disable + document-start: + level: warning + present: true + empty-lines: + level: warning + max: 2 + max-start: 0 + max-end: 0 + hyphens: + level: warning + max-spaces-after: 1 + indentation: + level: warning + spaces: consistent + indent-sequences: true + check-multi-line-strings: false + key-duplicates: enable + line-length: + level: warning + max: 80 + allow-non-breakable-words: true + allow-non-breakable-inline-mappings: true + new-line-at-end-of-file: disable + new-lines: + type: unix + trailing-spaces: disable diff --git a/TEMPLATES/README.md b/TEMPLATES/README.md new file mode 100644 index 00000000..bcd84269 --- /dev/null +++ b/TEMPLATES/README.md @@ -0,0 +1,8 @@ +# TEMPLATES + +The files in this folder are template rules for the linters that will run against your code base. If you chose to copy these to your local repository in the directory: `.github/` they will be used at runtime. If they are not present, they will be used by default in the linter run. + + + +The file(s) will be parsed at run time on the local branch to load all rules needed to run the **Super-Linter** **GitHub** Action. +The **GitHub** Action will inform the user via the **Checks API** on the status and success of the process. diff --git a/lib/entrypoint.sh b/lib/entrypoint.sh old mode 100644 new mode 100755 index ffabfe5f..1fa061d9 --- a/lib/entrypoint.sh +++ b/lib/entrypoint.sh @@ -1,303 +1,1170 @@ #!/bin/bash ################################################################################ -################################################################################ -############# EntryPoint for Docker NodeJS Deploy Serverless ################### -################################################################################ +########### EntryPoint for Super-Linter @AdmiralAwkbar ######################### ################################################################################ -######### -# NOTE: # -######### -# - https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-deploying.html -# - https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html#cli-configure-files-where -# - https://developer.github.com/v3/checks/runs/ - ########### -# Globals # +# GLOBALS # ########### -AWS_REGION='' # AWS region to deploy -S3_BUCKET='' # AWS S3 bucket to package and deploy -AWS_SAM_TEMPLATE='' # Path to the SAM template in the user repository -CHECK_NAME='GitHub AWS Deploy Serverless' # Name of the GitHub Action -CHECK_ID='' # GitHub Check ID that is created -AWS_STACK_NAME='' # AWS Cloud Formation Stack name of SAM -SAM_CMD='sam' # Path to AWS SAM Exec -RUNTIME='' # Runtime for AWS SAM App +# Default Vars +DEFAULT_RULES_LOCATION='/action/lib/.automation' # Default rules files location +# YAML Vars +YAML_FILE_NAME='.yaml-lint.yml' # Name of the file +YAML_LINTER_RULES="$DEFAULT_RULES_LOCATION/$YAML_FILE_NAME" # Path to the yaml lint rules +# MD Vars +MD_FILE_NAME='.markdown-lint.yml' # Name of the file +MD_LINTER_RULES="$DEFAULT_RULES_LOCATION/$MD_FILE_NAME" # Path to the markdown lint rules +# Python Vars +PYTHON_FILE_NAME='.python-lint' # Name of the file +PYTHON_LINTER_RULES="$DEFAULT_RULES_LOCATION/$PYTHON_FILE_NAME" # Path to the python lint rules +# Ruby Vars +RUBY_FILE_NAME='.ruby-lint.yml' # Name of the file +RUBY_LINTER_RULES="$DEFAULT_RULES_LOCATION/$RUBY_FILE_NAME" # Path to the ruby lint rules +# Coffee Vars +COFFEE_FILE_NAME='.coffee-lint.json' # Name of the file +COFFEE_LINTER_RULES="$DEFAULT_RULES_LOCATION/$COFFEE_FILE_NAME" # Path to the coffescript lint rules +# Ansible Vars +ANSIBLE_FILE_NAME='.ansible-lint.yml' # Name of the file +ANSIBLE_LINTER_RULES="$DEFAULT_RULES_LOCATION/$ANSIBLE_FILE_NAME" # Path to the coffescript lint rules ################### # GitHub ENV Vars # ################### -GITHUB_SHA="${GITHUB_SHA}" # GitHub sha from the commit -GITHUB_EVENT_PATH="${GITHUB_EVENT_PATH}" # Github Event Path -GITHUB_TOKEN='' # GitHub token -GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # Github Workspace -GITHUB_URL='https://api.github.com' # GitHub API URL +GITHUB_SHA="${GITHUB_SHA}" # GitHub sha from the commit +GITHUB_EVENT_PATH="${GITHUB_EVENT_PATH}" # Github Event Path +GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # Github Workspace -################### -# AWS Secret Vars # -################### -# shellcheck disable=SC2034 -AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY}" # aws_access_key_id to auth -# shellcheck disable=SC2034 -AWS_SECRET_ACCESS_KEY="${AWS_SECRET_KEY}" # aws_secret_access_key to auth - -############## -# Built Vars # -############## -GITHUB_ORG='' # Name of the GitHub Org -GITHUB_REPO='' # Name of the GitHub repo -USER_CONFIG_FILE="$GITHUB_WORKSPACE/.github/aws-config.yml" # File with users configurations -START_DATE=$(date +"%Y-%m-%dT%H:%M:%SZ") # YYYY-MM-DDTHH:MM:SSZ -FINISHED_DATE='' # YYYY-MM-DDTHH:MM:SSZ when complete -ACTION_CONCLUSTION='' # success, failure, neutral, cancelled, timed_out, or action_required. -ACTION_OUTPUT='' # String to pass back to the user on the output -ERROR_FOUND=0 # Set to 1 if any errors occur in the build before the package and deploy -ERROR_CAUSE='' # String to pass of error that was detected - -################ -# Default Vars # -################ -DEFAULT_OUTPUT='json' # Default Output format -DEFAULT_REGION='us-west-2' # Default region to deploy -LOCAL_CONFIG_FILE='/root/.aws/config' # AWS Config file -AWS_PACKAGED='packaged.yml' # Created SAM Package -DEBUG=0 # Debug=0 OFF | Debug=1 ON -#NVM_SRC='/usr/local/nvm/nvm.sh' # Source for NVM - - -###################################################### -# Variables we need to set in the ~/.aws/credentials # -# aws_access_key_id # -# aws_secret_access_key # -###################################################### - -################################################# -# Variables we need to set in the ~/.aws/config # -# region # -# output # -################################################# +############ +# Counters # +############ +ERRORS_FOUND_YML=0 # Count of errors found +ERRORS_FOUND_JSON=0 # Count of errors found +ERRORS_FOUND_XML=0 # Count of errors found +ERRORS_FOUND_MD=0 # Count of errors found +ERRORS_FOUND_BASH=0 # Count of errors found +ERRORS_FOUND_PERL=0 # Count of errors found +ERRORS_FOUND_RUBY=0 # Count of errors found +ERRORS_FOUND_PYTHON=0 # Count of errors found +ERRORS_FOUND_COFFEE=0 # Count of errors found +ERRORS_FOUND_ANSIBLE=0 # Count of errors found ################################################################################ -######################### SUB ROUTINES BELOW ################################### +########################## FUNCTIONS BELOW ##################################### ################################################################################ ################################################################################ -#### Function ValidateConfigurationFile ######################################## -ValidateConfigurationFile() +#### Function Header ########################################################### +Header() { - ########## - # Prints # - ########## - echo "--------------------------------------------" - echo "Validating input file..." - - #################################################################### - # Validate the config file is in the repository and pull variables # - #################################################################### - if [ ! -f "$USER_CONFIG_FILE" ]; then - # User file not found - echo "ERROR! Failed to find configuration file in user repository!" - ################################################### - # Set the ERROR_FOUND flag to 1 to drop out build # - ################################################### - ERROR_FOUND=1 - ERROR_CAUSE='Failed to find configuration file in user repository!' - else - echo "Success! Found User config file at:[$USER_CONFIG_FILE]" - fi - - ######################################## - # Map the variables to local variables # - ######################################## - - ####################### - ####################### - ## Get the s3_bucket ## - ####################### - ####################### - S3_BUCKET=$(yq -r .s3_bucket "$USER_CONFIG_FILE") - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ $ERROR_CODE -ne 0 ] || [ "$S3_BUCKET" == "null" ]; then - echo "ERROR! Failed to get [s3_bucket]!" - echo "ERROR:[$S3_BUCKET]" - ################################################### - # Set the ERROR_FOUND flag to 1 to drop out build # - ################################################### - ERROR_FOUND=1 - ERROR_CAUSE='Failed to get [s3_bucket]!' - else - echo "Successfully found:[s3_bucket]" - fi - - ############################################ - # Clean any whitespace that may be entered # - ############################################ - S3_BUCKET_NO_WHITESPACE="$(echo "${S3_BUCKET}" | tr -d '[:space:]')" - S3_BUCKET=$S3_BUCKET_NO_WHITESPACE - - ############################ - ############################ - ## Get the AWS Stack Name ## - ############################ - ############################ - AWS_STACK_NAME=$(yq -r .aws_stack_name "$USER_CONFIG_FILE") - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ $ERROR_CODE -ne 0 ] || [ "$AWS_STACK_NAME" == "null" ]; then - echo "ERROR! Failed to get [aws_stack_name]!" - echo "ERROR:[$AWS_STACK_NAME]" - ################################################### - # Set the ERROR_FOUND flag to 1 to drop out build # - ################################################### - ERROR_FOUND=1 - ERROR_CAUSE='Failed to get [aws_stack_name]!' - else - echo "Successfully found:[aws_stack_name]" - fi - - ############################################ - # Clean any whitespace that may be entered # - ############################################ - AWS_STACK_NAME_NO_WHITESPACE="$(echo "${AWS_STACK_NAME}" | tr -d '[:space:]')" - AWS_STACK_NAME=$AWS_STACK_NAME_NO_WHITESPACE - - ############################## - ############################## - ## Get the AWS SAM Template ## - ############################## - ############################## - AWS_SAM_TEMPLATE=$(yq -r .sam_template "$USER_CONFIG_FILE") - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ $ERROR_CODE -ne 0 ] || [ "$AWS_SAM_TEMPLATE" == "null" ]; then - echo "ERROR! Failed to get [sam_template]!" - echo "ERROR:[$AWS_SAM_TEMPLATE]" - ################################################### - # Set the ERROR_FOUND flag to 1 to drop out build # - ################################################### - ERROR_FOUND=1 - ERROR_CAUSE='Failed to get [sam_template]!' - else - echo "Successfully found:[sam_template]" - fi - - ############################################ - # Clean any whitespace that may be entered # - ############################################ - AWS_SAM_TEMPLATE_NO_WHITESPACE="$(echo "${AWS_SAM_TEMPLATE}" | tr -d '[:space:]')" - AWS_SAM_TEMPLATE=$AWS_SAM_TEMPLATE_NO_WHITESPACE - - #################### - #################### - ## Get the region ## - #################### - #################### - AWS_REGION=$(yq -r .region "$USER_CONFIG_FILE") - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ $ERROR_CODE -ne 0 ] || [ "$AWS_REGION" == "null" ]; then - # Error - echo "ERROR! Failed to get [region]!" - echo "ERROR:[$AWS_REGION]" - # Fall back to default - echo "No value provided... Defaulting to:[$DEFAULT_REGION]" - AWS_REGION="$DEFAULT_REGION" - else - echo "Successfully found:[region]" - fi - - ############################################ - # Clean any whitespace that may be entered # - ############################################ - AWS_REGION_NO_WHITESPACE="$(echo "${AWS_REGION}" | tr -d '[:space:]')" - AWS_REGION=$AWS_REGION_NO_WHITESPACE + echo "" + echo "---------------------------------------------" + echo "------ Github Actions Language Linter -------" + echo "---------------------------------------------" + echo "" } ################################################################################ -#### Function CreateLocalConfiguration ######################################### -CreateLocalConfiguration() +#### Function GetLinterRules ################################################### +GetLinterRules() { - ########## - # Prints # - ########## - echo "--------------------------------------------" - echo "Creating local configuration file..." + # Need to validate the rules files exist + ################ + # print header # + ################ + echo "" + echo "----------------------------------------------" + echo "Gathering Linter rules from repository, or defaulting..." + echo "" - ######################################## - # Create the directory if not existant # - ######################################## - MK_DIR_CMD=$(mkdir /root/.aws) + ##################################### + # Validate we have the linter rules # + ##################################### + if [ -f "$GITHUB_WORKSPACE/.github/$YAML_FILE_NAME" ]; then + echo "User provided file:[$YAML_FILE_NAME], setting rules file..." - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? + #################################### + # Move users into default location # + #################################### + MV_CMD=$(mv "$GITHUB_WORKSPACE/.github/$YAML_FILE_NAME" "$YAML_LINTER_RULES" 2>&1) - ############################## - # Check the shell for errors # - ############################## - if [ $ERROR_CODE -ne 0 ]; then - echo "ERROR! Failed to create root directory!" - echo "ERROR:[$MK_DIR_CMD]" - ################################################### - # Set the ERROR_FOUND flag to 1 to drop out build # - ################################################### - ERROR_FOUND=1 - ERROR_CAUSE='Failed to create root directory!' - fi + ################### + # Load Error code # + ################### + ERROR_CODE=$? - ####################################### - # Create the local file ~/.aws/config # - ####################################### - CREATE_CONFIG_CMD=$(echo -e "[default]\nregion=$AWS_REGION\noutput=$DEFAULT_OUTPUT" >> $LOCAL_CONFIG_FILE ) - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ $ERROR_CODE -ne 0 ]; then - echo "ERROR! Failed to create file:[$LOCAL_CONFIG_FILE]!" - echo "ERROR:[$CREATE_CONFIG_CMD]" - ################################################### - # Set the ERROR_FOUND flag to 1 to drop out build # - ################################################### - ERROR_FOUND=1 - ERROR_CAUSE="Failed to create file:[$LOCAL_CONFIG_FILE]!" + ############################## + # Check the shell for errors # + ############################## + if [ $ERROR_CODE -ne 0 ]; then + echo "ERROR! Failed to set file:[$YAML_FILE_NAME] as default!" + echo "ERROR:[$MV_CMD]" + exit 1 + fi else - echo "Successfully created:[$LOCAL_CONFIG_FILE]" + echo "Using Default rules at:[$YAML_LINTER_RULES]" fi + + ##################################### + # Validate we have the linter rules # + ##################################### + if [ -f "$GITHUB_WORKSPACE/.github/$MD_FILE_NAME" ]; then + echo "User provided file:[$MD_FILE_NAME], setting rules file..." + + #################################### + # Move users into default location # + #################################### + MV_CMD=$(mv "$GITHUB_WORKSPACE/.github/$MD_FILE_NAME" "$MD_LINTER_RULES" 2>&1) + + ################### + # Load Error code # + ################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ $ERROR_CODE -ne 0 ]; then + echo "ERROR! Failed to set file:[$MD_FILE_NAME] as default!" + echo "ERROR:[$MV_CMD]" + exit 1 + fi + else + echo "Using Default rules at:[$MD_LINTER_RULES]" + fi + + ##################################### + # Validate we have the linter rules # + ##################################### + if [ -f "$GITHUB_WORKSPACE/.github/$PYTHON_FILE_NAME" ]; then + echo "User provided file:[$PYTHON_FILE_NAME], setting rules file..." + + #################################### + # Move users into default location # + #################################### + MV_CMD=$(mv "$GITHUB_WORKSPACE/.github/$PYTHON_FILE_NAME" "$PYTHON_LINTER_RULES" 2>&1) + + ################### + # Load Error code # + ################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ $ERROR_CODE -ne 0 ]; then + echo "ERROR! Failed to set file:[$PYTHON_FILE_NAME] as default!" + echo "ERROR:[$MV_CMD]" + exit 1 + fi + else + echo "Using Default rules at:[$PYTHON_LINTER_RULES]" + fi + + ##################################### + # Validate we have the linter rules # + ##################################### + if [ -f "$GITHUB_WORKSPACE/.github/$RUBY_FILE_NAME" ]; then + echo "User provided file:[$RUBY_FILE_NAME], setting rules file..." + + #################################### + # Move users into default location # + #################################### + MV_CMD=$(mv "$GITHUB_WORKSPACE/.github/$RUBY_FILE_NAME" "$RUBY_LINTER_RULES" 2>&1) + + ################### + # Load Error code # + ################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ $ERROR_CODE -ne 0 ]; then + echo "ERROR! Failed to set file:[$RUBY_FILE_NAME] as default!" + echo "ERROR:[$MV_CMD]" + exit 1 + fi + else + echo "Using Default rules at:[$RUBY_LINTER_RULES]" + fi + + ##################################### + # Validate we have the linter rules # + ##################################### + if [ -f "$GITHUB_WORKSPACE/.github/$COFFEE_FILE_NAME" ]; then + echo "User provided file:[$COFFEE_FILE_NAME], setting rules file..." + + #################################### + # Move users into default location # + #################################### + MV_CMD=$(mv "$GITHUB_WORKSPACE/.github/$COFFEE_FILE_NAME" "$COFFEE_LINTER_RULES" 2>&1) + + ################### + # Load Error code # + ################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ $ERROR_CODE -ne 0 ]; then + echo "ERROR! Failed to set file:[$COFFEE_FILE_NAME] as default!" + echo "ERROR:[$MV_CMD]" + exit 1 + fi + else + echo "Using Default rules at:[$COFFEE_LINTER_RULES]" + fi + + ##################################### + # Validate we have the linter rules # + ##################################### + if [ -f "$GITHUB_WORKSPACE/.github/$ANSIBLE_FILE_NAME" ]; then + echo "User provided file:[$ANSIBLE_FILE_NAME], setting rules file..." + + #################################### + # Move users into default location # + #################################### + MV_CMD=$(mv "$GITHUB_WORKSPACE/.github/$ANSIBLE_FILE_NAME" "$ANSIBLE_LINTER_RULES" 2>&1) + + ################### + # Load Error code # + ################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ $ERROR_CODE -ne 0 ]; then + echo "ERROR! Failed to set file:[$ANSIBLE_FILE_NAME] as default!" + echo "ERROR:[$MV_CMD]" + exit 1 + fi + else + echo "Using Default rules at:[$ANSIBLE_LINTER_RULES]" + fi +} +################################################################################ +#### Function LintJsonFiles #################################################### +LintJsonFiles() +{ + ################ + # print header # + ################ + echo "" + echo "----------------------------------------------" + echo "Linting JSON files..." + echo "----------------------------------------------" + echo "" + + ###################### + # Name of the linter # + ###################### + LINTER_NAME="jsonlint" + + ####################################### + # Validate we have yamllint installed # + ####################################### + # shellcheck disable=SC2230 + VALIDATE_INSTALL_CMD=$(which "$LINTER_NAME" 2>&1) + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ $ERROR_CODE -ne 0 ]; then + # Failed + echo "ERROR! Failed to find [$LINTER_NAME] in system!" + echo "ERROR:[$VALIDATE_INSTALL_CMD]" + exit 1 + else + # Success + echo "Successfully found binary in system" + echo "Location:[$VALIDATE_INSTALL_CMD]" + fi + + ################################# + # Get list of all files to lint # + ################################# + # shellcheck disable=SC2207 + LIST_FILES=($(cd "$GITHUB_WORKSPACE"; find . -type f -name "*.json" 2>&1)) + + ################## + # Lint the files # + ################## + for FILE in "${LIST_FILES[@]}" + do + ##################### + # Get the file name # + ##################### + FILE_NAME=$(basename "$FILE" 2>&1) + + ####################################### + # Make sure we dont lint node modules # + ####################################### + if [[ $FILE == *"node_modules"* ]]; then + # This is a node modules file + continue + fi + + ############## + # File print # + ############## + echo "---------------------------" + echo "File:[$FILE]" + + ################################ + # Lint the file with the rules # + ################################ + LINT_CMD=$("$LINTER_NAME" "$FILE" 2>&1) + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ $ERROR_CODE -ne 0 ]; then + ######### + # Error # + ######### + echo "ERROR! Found errors in [$LINTER_NAME] linter!" + echo "ERROR:[$LINT_CMD]" + # Increment error count + ((ERRORS_FOUND_JSON++)) + else + ########### + # Success # + ########### + echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully" + fi + done +} +################################################################################ +#### Function LintYmlFiles ##################################################### +LintYmlFiles() +{ + ################ + # print header # + ################ + echo "" + echo "----------------------------------------------" + echo "Linting YAML files..." + echo "----------------------------------------------" + echo "" + + ###################### + # Name of the linter # + ###################### + LINTER_NAME="yamllint" + + ####################################### + # Validate we have yamllint installed # + ####################################### + # shellcheck disable=SC2230 + VALIDATE_INSTALL_CMD=$(which "$LINTER_NAME" 2>&1) + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ $ERROR_CODE -ne 0 ]; then + # Failed + echo "ERROR! Failed to find [$LINTER_NAME] in system!" + echo "ERROR:[$VALIDATE_INSTALL_CMD]" + exit 1 + else + # Success + echo "Successfully found binary in system" + echo "Location:[$VALIDATE_INSTALL_CMD]" + fi + + ################################# + # Get list of all files to lint # + ################################# + # shellcheck disable=SC2207 + LIST_FILES=($(find "$GITHUB_WORKSPACE" -type f \( -name "*.yml" -or -name "*.yaml" \) 2>&1)) + + ################## + # Lint the files # + ################## + for FILE in "${LIST_FILES[@]}" + do + ##################### + # Get the file name # + ##################### + FILE_NAME=$(basename "$FILE" 2>&1) + + ####################################### + # Make sure we dont lint node modules # + ####################################### + # if [[ $FILE == *"node_modules"* ]]; then + # # This is a node modules file + # continue + # fi + + ############## + # File print # + ############## + echo "---------------------------" + echo "File:[$FILE]" + + ################################ + # Lint the file with the rules # + ################################ + LINT_CMD=$("$LINTER_NAME" "$YAML_LINTER_RULES" "$FILE" 2>&1) + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ $ERROR_CODE -ne 0 ]; then + ######### + # Error # + ######### + echo "ERROR! Found errors in [$LINTER_NAME] linter!" + echo "ERROR:[$LINT_CMD]" + # Increment error count + ((ERRORS_FOUND_YML++)) + else + ########### + # Success # + ########### + echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully" + fi + done +} +################################################################################ +#### Function LintXmlFiles ##################################################### +LintXmlFiles() +{ + ################ + # print header # + ################ + echo "" + echo "----------------------------------------------" + echo "Linting XML files..." + echo "----------------------------------------------" + echo "" + + ###################### + # Name of the linter # + ###################### + LINTER_NAME="xmllint" + + ####################################### + # Validate we have yamllint installed # + ####################################### + # shellcheck disable=SC2230 + VALIDATE_INSTALL_CMD=$(which "$LINTER_NAME" 2>&1) + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ $ERROR_CODE -ne 0 ]; then + # Failed + echo "ERROR! Failed to find [$LINTER_NAME] in system!" + echo "ERROR:[$VALIDATE_INSTALL_CMD]" + exit 1 + else + # Success + echo "Successfully found binary in system" + echo "Location:[$VALIDATE_INSTALL_CMD]" + fi + + ################################# + # Get list of all files to lint # + ################################# + # shellcheck disable=SC2207 + LIST_FILES=($(cd "$GITHUB_WORKSPACE"; find . -type f -name "*.xml" 2>&1)) + + ################## + # Lint the files # + ################## + for FILE in "${LIST_FILES[@]}" + do + ##################### + # Get the file name # + ##################### + FILE_NAME=$(basename "$FILE" 2>&1) + + ####################################### + # Make sure we dont lint node modules # + ####################################### + # if [[ $FILE == *"node_modules"* ]]; then + # # This is a node modules file + # continue + # fi + + ############## + # File print # + ############## + echo "---------------------------" + echo "File:[$FILE]" + + ################################ + # Lint the file with the rules # + ################################ + LINT_CMD=$("$LINTER_NAME" "$FILE" 2>&1) + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ $ERROR_CODE -ne 0 ]; then + ######### + # Error # + ######### + echo "ERROR! Found errors in [$LINTER_NAME] linter!" + echo "ERROR:[$LINT_CMD]" + # Increment error count + ((ERRORS_FOUND_XML++)) + else + ########### + # Success # + ########### + echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully" + fi + done +} +################################################################################ +#### Function LintMdFiles ###################################################### +LintMdFiles() +{ + ################ + # print header # + ################ + echo "" + echo "----------------------------------------------" + echo "Linting Markdown files..." + echo "----------------------------------------------" + echo "" + + ###################### + # Name of the linter # + ###################### + LINTER_NAME="markdownlint" + + ####################################### + # Validate we have yamllint installed # + ####################################### + # shellcheck disable=SC2230 + VALIDATE_INSTALL_CMD=$(which "$LINTER_NAME" 2>&1) + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ $ERROR_CODE -ne 0 ]; then + # Failed + echo "ERROR! Failed to find [$LINTER_NAME] in system!" + echo "ERROR:[$VALIDATE_INSTALL_CMD]" + exit 1 + else + # Success + echo "Successfully found binary in system" + echo "Location:[$VALIDATE_INSTALL_CMD]" + fi + + ################################# + # Get list of all files to lint # + ################################# + # shellcheck disable=SC2207 + LIST_FILES=($(cd "$GITHUB_WORKSPACE"; find . -type f -name "*.md" 2>&1)) + + ################## + # Lint the files # + ################## + for FILE in "${LIST_FILES[@]}" + do + ##################### + # Get the file name # + ##################### + FILE_NAME=$(basename "$FILE" 2>&1) + + ####################################### + # Make sure we dont lint node modules # + ####################################### + # if [[ $FILE == *"node_modules"* ]]; then + # # This is a node modules file + # continue + # fi + + ############## + # File print # + ############## + echo "---------------------------" + echo "File:[$FILE]" + + ################################ + # Lint the file with the rules # + ################################ + LINT_CMD=$("$LINTER_NAME" -c "$MD_LINTER_RULES" "$FILE" 2>&1) + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ $ERROR_CODE -ne 0 ]; then + ######### + # Error # + ######### + echo "ERROR! Found errors in [$LINTER_NAME] linter!" + echo "ERROR:[$LINT_CMD]" + # Increment error count + ((ERRORS_FOUND_MD++)) + else + ########### + # Success # + ########### + echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully" + fi + done +} +################################################################################ +#### Function LintBashFiles #################################################### +LintBashFiles() +{ + ################ + # print header # + ################ + echo "" + echo "----------------------------------------------" + echo "Linting Bash files..." + echo "----------------------------------------------" + echo "" + + ###################### + # Name of the linter # + ###################### + LINTER_NAME="shellcheck" + + ######################################### + # Validate we have shellcheck installed # + ######################################### + # shellcheck disable=SC2230 + VALIDATE_INSTALL_CMD=$(which "$LINTER_NAME" 2>&1) + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ $ERROR_CODE -ne 0 ]; then + # Failed + echo "ERROR! Failed to find $LINTER_NAME in system!" + echo "ERROR:[$VALIDATE_INSTALL_CMD]" + exit 1 + else + # Success + echo "Successfully found binary in system" + echo "Location:[$VALIDATE_INSTALL_CMD]" + fi + + ################################# + # Get list of all files to lint # + ################################# + # shellcheck disable=SC2207 + LIST_FILES=($(cd "$GITHUB_WORKSPACE"; find . -type f -name "*.sh" 2>&1)) + + ################## + # Lint the files # + ################## + for FILE in "${LIST_FILES[@]}" + do + + ####################################### + # Make sure we dont lint node modules # + ####################################### + # if [[ $FILE == *"node_modules"* ]]; then + # # This is a node modules file + # continue + # fi + + #################### + # Get the filename # + #################### + FILE_NAME=$(basename "$FILE" 2>&1) + + ############## + # File print # + ############## + echo "---------------------------" + echo "File:[$FILE]" + + ################################ + # Lint the file with the rules # + ################################ + LINT_CMD=$("$LINTER_NAME" "$FILE" 2>&1) + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ $ERROR_CODE -ne 0 ]; then + ######### + # Error # + ######### + echo "ERROR! Found errors in [$LINTER_NAME] linter!" + echo "ERROR:[$LINT_CMD]" + # Increment error count + ((ERRORS_FOUND_BASH++)) + else + ########### + # Success # + ########### + echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully" + fi + done +} +################################################################################ +#### Function LintPythonFiles ################################################## +LintPythonFiles() +{ + ################ + # print header # + ################ + echo "" + echo "----------------------------------------------" + echo "Linting Python files..." + echo "----------------------------------------------" + echo "" + + ###################### + # Name of the linter # + ###################### + LINTER_NAME="pylint" + + ##################################### + # Validate we have pylint installed # + ##################################### + # shellcheck disable=SC2230 + VALIDATE_INSTALL_CMD=$(which "$LINTER_NAME" 2>&1) + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ $ERROR_CODE -ne 0 ]; then + # Failed + echo "ERROR! Failed to find $LINTER_NAME in system!" + echo "ERROR:[$VALIDATE_INSTALL_CMD]" + exit 1 + else + # Success + echo "Successfully found binary in system" + echo "Location:[$VALIDATE_INSTALL_CMD]" + fi + + ################################# + # Get list of all files to lint # + ################################# + # shellcheck disable=SC2207 + LIST_FILES=($(cd "$GITHUB_WORKSPACE"; find . -type f -name "*.py" 2>&1)) + + ################## + # Lint the files # + ################## + for FILE in "${LIST_FILES[@]}" + do + + ####################################### + # Make sure we dont lint node modules # + ####################################### + # if [[ $FILE == *"node_modules"* ]]; then + # # This is a node modules file + # continue + # fi + + #################### + # Get the filename # + #################### + FILE_NAME=$(basename "$FILE" 2>&1) + + ############## + # File print # + ############## + echo "---------------------------" + echo "File:[$FILE]" + + ################################ + # Lint the file with the rules # + ################################ + LINT_CMD=$("$LINTER_NAME" --rcfile "$PYTHON_LINTER_RULES" -E "$FILE" 2>&1) + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ $ERROR_CODE -ne 0 ]; then + ######### + # Error # + ######### + echo "ERROR! Found errors in [$LINTER_NAME] linter!" + echo "ERROR:[$LINT_CMD]" + # Increment error count + ((ERRORS_FOUND_PYTHON++)) + else + ########### + # Success # + ########### + echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully" + fi + done +} +################################################################################ +#### Function LintPerlFiles #################################################### +LintPerlFiles() +{ + ################ + # print header # + ################ + echo "" + echo "----------------------------------------------" + echo "Linting Perl files..." + echo "----------------------------------------------" + echo "" + + ###################### + # Name of the linter # + ###################### + LINTER_NAME="perl" + + ################################### + # Validate we have perl installed # + ################################### + # shellcheck disable=SC2230 + VALIDATE_INSTALL_CMD=$(which "$LINTER_NAME" 2>&1) + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ $ERROR_CODE -ne 0 ]; then + # Failed + echo "ERROR! Failed to find $LINTER_NAME in system!" + echo "ERROR:[$VALIDATE_INSTALL_CMD]" + exit 1 + else + # Success + echo "Successfully found binary in system" + echo "Location:[$VALIDATE_INSTALL_CMD]" + fi + + ################################# + # Get list of all files to lint # + ################################# + # shellcheck disable=SC2207 + LIST_FILES=($(cd "$GITHUB_WORKSPACE"; find . -type f -name "*.pl" 2>&1)) + + ################## + # Lint the files # + ################## + for FILE in "${LIST_FILES[@]}" + do + + ####################################### + # Make sure we dont lint node modules # + ####################################### + # if [[ $FILE == *"node_modules"* ]]; then + # # This is a node modules file + # continue + # fi + + #################### + # Get the filename # + #################### + FILE_NAME=$(basename "$FILE" 2>&1) + + ############## + # File print # + ############## + echo "---------------------------" + echo "File:[$FILE]" + + ################################ + # Lint the file with the rules # + ################################ + LINT_CMD=$("$LINTER_NAME" -Mstrict -cw "$FILE" 2>&1) + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ $ERROR_CODE -ne 0 ]; then + ######### + # Error # + ######### + echo "ERROR! Found errors in [$LINTER_NAME] linter!" + echo "ERROR:[$LINT_CMD]" + # Increment error count + ((ERRORS_FOUND_PERL++)) + else + ########### + # Success # + ########### + echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully" + fi + done +} +################################################################################ +#### Function LintRubyFiles #################################################### +LintRubyFiles() +{ + ################ + # print header # + ################ + echo "" + echo "----------------------------------------------" + echo "Linting Ruby files..." + echo "----------------------------------------------" + echo "" + + ###################### + # Name of the linter # + ###################### + LINTER_NAME="rubocop" + + ################################### + # Validate we have perl installed # + ################################### + # shellcheck disable=SC2230 + VALIDATE_INSTALL_CMD=$(which "$LINTER_NAME" 2>&1) + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ $ERROR_CODE -ne 0 ]; then + # Failed + echo "ERROR! Failed to find $LINTER_NAME in system!" + echo "ERROR:[$VALIDATE_INSTALL_CMD]" + exit 1 + else + # Success + echo "Successfully found binary in system" + echo "Location:[$VALIDATE_INSTALL_CMD]" + fi + + ################################# + # Get list of all files to lint # + ################################# + # shellcheck disable=SC2207 + LIST_FILES=($(cd "$GITHUB_WORKSPACE"; find . -type f -name "*.rb" 2>&1)) + + ################## + # Lint the files # + ################## + for FILE in "${LIST_FILES[@]}" + do + + ####################################### + # Make sure we dont lint node modules # + ####################################### + # if [[ $FILE == *"node_modules"* ]]; then + # # This is a node modules file + # continue + # fi + + #################### + # Get the filename # + #################### + FILE_NAME=$(basename "$FILE" 2>&1) + + ############## + # File print # + ############## + echo "---------------------------" + echo "File:[$FILE]" + + ################################ + # Lint the file with the rules # + ################################ + LINT_CMD=$("$LINTER_NAME" -c "$RUBY_LINTER_RULES" "$FILE" 2>&1) + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ $ERROR_CODE -ne 0 ]; then + ######### + # Error # + ######### + echo "ERROR! Found errors in [$LINTER_NAME] linter!" + echo "ERROR:[$LINT_CMD]" + # Increment error count + ((ERRORS_FOUND_RUBY++)) + else + ########### + # Success # + ########### + echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully" + fi + done +} +################################################################################ +#### Function LintCoffeeFiles ################################################## +LintCoffeeFiles() +{ + ################ + # print header # + ################ + echo "" + echo "----------------------------------------------" + echo "Linting Coffee files..." + echo "----------------------------------------------" + echo "" + + ###################### + # Name of the linter # + ###################### + LINTER_NAME="coffeelint" + + ##################################### + # Validate we have pylint installed # + ##################################### + # shellcheck disable=SC2230 + VALIDATE_INSTALL_CMD=$(which "$LINTER_NAME" 2>&1) + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ $ERROR_CODE -ne 0 ]; then + # Failed + echo "ERROR! Failed to find $LINTER_NAME in system!" + echo "ERROR:[$VALIDATE_INSTALL_CMD]" + exit 1 + else + # Success + echo "Successfully found binary in system" + echo "Location:[$VALIDATE_INSTALL_CMD]" + fi + + ################################# + # Get list of all files to lint # + ################################# + # shellcheck disable=SC2207 + LIST_FILES=($(cd "$GITHUB_WORKSPACE"; find . -type f -name "*.coffee" 2>&1)) + + ################## + # Lint the files # + ################## + for FILE in "${LIST_FILES[@]}" + do + + ####################################### + # Make sure we dont lint node modules # + ####################################### + # if [[ $FILE == *"node_modules"* ]]; then + # # This is a node modules file + # continue + # fi + + #################### + # Get the filename # + #################### + FILE_NAME=$(basename "$FILE" 2>&1) + + ############## + # File print # + ############## + echo "---------------------------" + echo "File:[$FILE]" + + ################################ + # Lint the file with the rules # + ################################ + LINT_CMD=$("$LINTER_NAME" -f "$COFFEE_LINTER_RULES" "$FILE" 2>&1) + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ $ERROR_CODE -ne 0 ]; then + ######### + # Error # + ######### + echo "ERROR! Found errors in [$LINTER_NAME] linter!" + echo "ERROR:[$LINT_CMD]" + # Increment error count + ((ERRORS_FOUND_COFFEE++)) + else + ########### + # Success # + ########### + echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully" + fi + done } ################################################################################ #### Function GetGitHubVars #################################################### @@ -315,41 +1182,18 @@ GetGitHubVars() if [ -z "$GITHUB_SHA" ]; then echo "ERROR! Failed to get [GITHUB_SHA]!" echo "ERROR:[$GITHUB_SHA]" - ################################################### - # Set the ERROR_FOUND flag to 1 to drop out build # - ################################################### - ERROR_FOUND=1 - ERROR_CAUSE='Failed to get [GITHUB_SHA]!' + exit 1 else echo "Successfully found:[GITHUB_SHA]" fi - # ############################ - # # Validate we have a value # - # ############################ - # if [ -z "$GITHUB_TOKEN" ]; then - # echo "ERROR! Failed to get [GITHUB_TOKEN]!" - # echo "ERROR:[$GITHUB_TOKEN]" - # ################################################### - # # Set the ERROR_FOUND flag to 1 to drop out build # - # ################################################### - # ERROR_FOUND=1 - # ERROR_CAUSE='Failed to get [GITHUB_TOKEN]!' - # else - # echo "Successfully found:[GITHUB_TOKEN]" - # fi - ############################ # Validate we have a value # ############################ if [ -z "$GITHUB_WORKSPACE" ]; then echo "ERROR! Failed to get [GITHUB_WORKSPACE]!" echo "ERROR:[$GITHUB_WORKSPACE]" - ################################################### - # Set the ERROR_FOUND flag to 1 to drop out build # - ################################################### - ERROR_FOUND=1 - ERROR_CAUSE='Failed to get [GITHUB_WORKSPACE]!' + exit 1 else echo "Successfully found:[GITHUB_WORKSPACE]" fi @@ -360,11 +1204,7 @@ GetGitHubVars() if [ -z "$GITHUB_EVENT_PATH" ]; then echo "ERROR! Failed to get [GITHUB_EVENT_PATH]!" echo "ERROR:[$GITHUB_EVENT_PATH]" - ################################################### - # Set the ERROR_FOUND flag to 1 to drop out build # - ################################################### - ERROR_FOUND=1 - ERROR_CAUSE='Failed to get [GITHUB_EVENT_PATH]!' + exit 1 else echo "Successfully found:[GITHUB_EVENT_PATH]" fi @@ -385,11 +1225,7 @@ GetGitHubVars() if [ -z "$GITHUB_ORG" ]; then echo "ERROR! Failed to get [GITHUB_ORG]!" echo "ERROR:[$GITHUB_ORG]" - ################################################### - # Set the ERROR_FOUND flag to 1 to drop out build # - ################################################### - ERROR_FOUND=1 - ERROR_CAUSE='Failed to get [GITHUB_ORG]!' + exit 1 else echo "Successfully found:[GITHUB_ORG]" fi @@ -406,31 +1242,36 @@ GetGitHubVars() if [ -z "$GITHUB_REPO" ]; then echo "ERROR! Failed to get [GITHUB_REPO]!" echo "ERROR:[$GITHUB_REPO]" - ################################################### - # Set the ERROR_FOUND flag to 1 to drop out build # - ################################################### - ERROR_FOUND=1 - ERROR_CAUSE='Failed to get [GITHUB_REPO]!' + exit 1 else echo "Successfully found:[GITHUB_REPO]" fi } ################################################################################ -#### Function ValidateAWSCLI ################################################### -ValidateAWSCLI() +#### Function LintAnsibleFiles ################################################# +LintAnsibleFiles() { - ########## - # Prints # - ########## - echo "--------------------------------------------" - echo "Validating AWS information..." + ANSIBLE_DIR="$GITHUB_WORKSPACE/ansible" # Ansible directory - ############################################ - ############################################ - ## Validate we have access to the aws cli ## - ############################################ - ############################################ - VALIDATE_AWS_CMD=$(which aws ) + ################ + # print header # + ################ + echo "" + echo "----------------------------------------------" + echo "Linting Ansible files..." + echo "----------------------------------------------" + echo "" + + ###################### + # Name of the linter # + ###################### + LINTER_NAME="ansible-lint" + + ########################################### + # Validate we have ansible-lint installed # + ########################################### + # shellcheck disable=SC2230 + VALIDATE_INSTALL_CMD=$(which "$LINTER_NAME" 2>&1) ####################### # Load the error code # @@ -441,659 +1282,203 @@ ValidateAWSCLI() # Check the shell for errors # ############################## if [ $ERROR_CODE -ne 0 ]; then - # Error failed to find binary - echo "ERROR! Failed to find aws cli!" - echo "ERROR:[$VALIDATE_AWS_CMD]" - ################################################### - # Set the ERROR_FOUND flag to 1 to drop out build # - ################################################### - ERROR_FOUND=1 - ERROR_CAUSE='Failed to find aws cli!' - else - echo "Successfully validated:[aws cli]" - fi - - ############################################ - ############################################ - ## Validate we have access to the aws cli ## - ############################################ - ############################################ - VALIDATE_SAM_CMD=$(which "$SAM_CMD" ) - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ $ERROR_CODE -ne 0 ]; then - # Error failed to find binary - echo "ERROR! Failed to find aws sam cli!" - echo "ERROR:[$VALIDATE_SAM_CMD]" - ################################################### - # Set the ERROR_FOUND flag to 1 to drop out build # - ################################################### - ERROR_FOUND=1 - ERROR_CAUSE='Failed to find aws sam cli!' - else - echo "Successfully validated:[aws sam cli]" - fi - - ####################################### - ####################################### - ## Validate we can see AWS s3 bucket ## - ####################################### - ####################################### - CHECK_BUCKET_CMD=$(aws s3 ls "$S3_BUCKET" ) - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ $ERROR_CODE -ne 0 ]; then - echo "ERROR! Failed to access AWS S3 bucket:[$S3_BUCKET]" - echo "ERROR:[$CHECK_BUCKET_CMD]" - ################################################### - # Set the ERROR_FOUND flag to 1 to drop out build # - ################################################### - ERROR_FOUND=1 - ERROR_CAUSE="Failed to access AWS S3 bucket:[$S3_BUCKET]" - else - echo "Successfully validated:[aws s3 bucket authorization]" - fi -} -################################################################################ -#### Function CreateCheck ###################################################### -CreateCheck() -{ - ########## - # Prints # - ########## - echo "--------------------------------------------" - echo "Creating GitHub Check..." - - ########################################## - # Call to Github to create the Check API # - ########################################## - CREATE_CHECK_CMD=$( curl -k --fail -X POST \ - --url "$GITHUB_URL/repos/$GITHUB_ORG/$GITHUB_REPO/check-runs" \ - -H 'accept: application/vnd.github.antiope-preview+json' \ - -H "authorization: Bearer $GITHUB_TOKEN" \ - -H 'content-type: application/json' \ - --data "{ \"name\": \"$CHECK_NAME\", \"head_sha\": \"$GITHUB_SHA\", \"status\": \"in_progress\", \"started_at\": \"$START_DATE\" }" \ - ) - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ $ERROR_CODE -ne 0 ]; then - echo "ERROR! Failed to create GitHub Check!" - echo "ERROR:[$CREATE_CHECK_CMD]" + # Failed + echo "ERROR! Failed to find $LINTER_NAME in system!" + echo "ERROR:[$VALIDATE_INSTALL_CMD]" exit 1 - else - echo "Successfully Created GitHub Check" - ############################################# - # Need to get the check ID that was created # - ############################################# - CHECK_ID=$(echo "$CREATE_CHECK_CMD"| jq -r '.id' ) - - ############################ - # Validate we have a value # - ############################ - if [ -z "$CHECK_ID" ]; then - echo "ERROR! Failed to get [CHECK_ID]!" - echo "ERROR:[$CHECK_ID]" - exit 1 - fi - fi -} -################################################################################ -#### Function RunDeploy ######################################################## -RunDeploy() -{ - ########## - # Prints # - ########## - echo "--------------------------------------------" - echo "Running AWS Deploy Process..." - - # Need to complete the following actions to deploy to AWS Serverless: - # https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-deploying.html - # - Package SAM template - # - Deploy packaged SAM template - - # Go into loop if no errors detected - if [ $ERROR_FOUND -eq 0 ]; then - ################# - # Build the App # - ################# - BuidApp - fi - - # Go into loop if no errors detected - if [ $ERROR_FOUND -eq 0 ]; then - ######################## - # Package the template # - ######################## - PackageTemplate - fi - - # Go into loop if no errors detected - if [ $ERROR_FOUND -eq 0 ]; then - ####################### - # Deploy the template # - ####################### - DeployTemplate - fi - - # Go into loop if no errors detected - if [ $ERROR_FOUND -eq 0 ]; then - ####################### - # Deploy the template # - ####################### - GetOutput - fi -} -################################################################################ -#### Function BuidApp ########################################################## -BuidApp() -{ - ########## - # Prints # - ########## - echo "--------------------------------------------" - echo "Building the SAM application..." - - ######################### - # Build the application # - ######################### - # shellcheck disable=SC2164 - BUILD_CMD=$(cd "$GITHUB_WORKSPACE" ; "$SAM_CMD" build) - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ $ERROR_CODE -ne 0 ]; then - # Errors found - echo "ERROR! Failed to build SAM application!" - echo "ERROR:[$BUILD_CMD]" - ######################################### - # Need to update the ACTION_CONCLUSTION # - ######################################### - ERROR_FOUND=1 - ERROR_CAUSE="Failed to build SAM application:[$BUILD_CMD]!" - else - echo "Successfully built local AWS SAM Application" - fi -} -################################################################################ -#### Function PackageTemplate ################################################## -PackageTemplate() -{ - ########## - # Prints # - ########## - echo "--------------------------------------------" - echo "Packaging the template..." - - ############################################## - # Check the source code for the SAM template # - ############################################## - if [ ! -f "$GITHUB_WORKSPACE/$AWS_SAM_TEMPLATE" ]; then - echo "ERROR! Failed to find:[$AWS_SAM_TEMPLATE] in root of repository!" - ################################################### - # Set the ERROR_FOUND flag to 1 to drop out build # - ################################################### - ERROR_FOUND=1 - ERROR_CAUSE="Failed to find:[$AWS_SAM_TEMPLATE] in repository!" - else - echo "Successfully found:[$AWS_SAM_TEMPLATE]" - fi - - ############################ - # Package the SAM template # - ############################ - # shellcheck disable=SC2164 - SAM_PACKAGE_CMD=$(cd "$GITHUB_WORKSPACE"; "$SAM_CMD" package --template-file "$GITHUB_WORKSPACE/$AWS_SAM_TEMPLATE" --s3-bucket "$S3_BUCKET" --output-template-file "$AWS_PACKAGED" --region "$AWS_REGION") - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ $ERROR_CODE -ne 0 ]; then - # Errors found - echo "ERROR! Failed to package SAM template!" - echo "ERROR:[$SAM_PACKAGE_CMD]" - ######################################### - # Need to update the ACTION_CONCLUSTION # - ######################################### - ERROR_FOUND=1 - ERROR_CAUSE='Failed to package SAM template!' - else - echo "Successfully packaged AWS SAM Application" - fi -} -################################################################################ -#### Function DeployTemplate ################################################### -DeployTemplate() -{ - ########## - # Prints # - ########## - echo "--------------------------------------------" - echo "Deploying the template..." - - ############################################ - # Need to validate the package was created # - ############################################ - if [ ! -f "$GITHUB_WORKSPACE/$AWS_PACKAGED" ]; then - echo "ERROR! Failed to find created package:[$AWS_PACKAGED]" - ################################################### - # Set the ERROR_FOUND flag to 1 to drop out build # - ################################################### - ERROR_FOUND=1 - ERROR_CAUSE="Failed to find created package:[$AWS_PACKAGED]" - fi - - ########################### - # Deploy the SAM template # - ########################### - # shellcheck disable=SC2164 - SAM_DEPLOY_CMD=$(cd "$GITHUB_WORKSPACE"; "$SAM_CMD" deploy --template-file "$GITHUB_WORKSPACE/$AWS_PACKAGED" --stack-name "$AWS_STACK_NAME" --capabilities CAPABILITY_IAM --region "$AWS_REGION") - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ $ERROR_CODE -ne 0 ]; then - # Errors found - echo "ERROR! Failed to deploy SAM template!" - echo "ERROR:[$SAM_DEPLOY_CMD]" - ######################################### - # Need to update the ACTION_CONCLUSTION # - ######################################### - ERROR_FOUND=1 - ACTION_CONCLUSTION='failure' - ACTION_OUTPUT="Failed to deploy SAM App" else # Success - echo "Successfully deployed AWS SAM Application" - ######################################### - # Need to update the ACTION_CONCLUSTION # - ######################################### - ACTION_CONCLUSTION='success' - ACTION_OUTPUT="Successfully Deployed SAM App" + echo "Successfully found binary in system" + echo "Location:[$VALIDATE_INSTALL_CMD]" fi -} -################################################################################ -#### Function GetOutput ######################################################## -GetOutput() -{ - # Need to get the generated output from the stack - # to display back to the user for consumption - ########## - # Prints # - ########## - echo "--------------------------------------------" - echo "Gathering Output from deployed SAM application..." + ###################################################### + # Only go into ansible linter if we have base folder # + ###################################################### + if [ -d "$ANSIBLE_DIR" ]; then + ################################# + # Get list of all files to lint # + ################################# + # shellcheck disable=SC2164,SC2010 + LIST_FILES=($(cd "$ANSIBLE_DIR"; ls -I vault.yml -I galaxy.yml | grep ".yml" 2>&1)) - ########################### - # Get the output from AWS # - ########################### - IFS=$'\n' # Set IFS to newline - OUTPUT_CMD=($(aws cloudformation describe-stacks --stack-name "$AWS_STACK_NAME" --query "Stacks[0].Outputs[*]" --region "$AWS_REGION")) - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ $ERROR_CODE -ne 0 ]; then - # Errors found - echo "ERROR! Failed to get output from deployed SAM application!" - echo "ERROR:[${OUTPUT_CMD[*]}]" - ######################################### - # Need to update the ACTION_CONCLUSTION # - ######################################### - ERROR_FOUND=1 - ACTION_CONCLUSTION='failure' - ACTION_OUTPUT="Failed to get output from deployed SAM application" - else - # Success - ################################################ - # Itterate through all lines returned from AWS # - ################################################ - echo "Output from deployed AWS SAM Application:[$AWS_STACK_NAME]:" - for LINE in "${OUTPUT_CMD[@]}" + ################## + # Lint the files # + ################## + for FILE in "${LIST_FILES[@]}" do - # Print the output to the logfile - echo "$LINE" + + ####################################### + # Make sure we dont lint node modules # + ####################################### + # if [[ $FILE == *"node_modules"* ]]; then + # # This is a node modules file + # continue + # fi + + #################### + # Get the filename # + #################### + FILE_NAME=$(basename "$ANSIBLE_DIR/$FILE" 2>&1) + + ############## + # File print # + ############## + echo "---------------------------" + echo "File:[$FILE]" + + ################################ + # Lint the file with the rules # + ################################ + LINT_CMD=$("$LINTER_NAME" -v -c "$ANSIBLE_LINTER_FILE" "$ANSIBLE_DIR/$FILE" 2>&1) + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ $ERROR_CODE -ne 0 ]; then + ######### + # Error # + ######### + echo "ERROR! Found errors in [$LINTER_NAME] linter!" + echo "ERROR:[$LINT_CMD]" + # Increment error count + ((ERRORS_FOUND_ANSIBLE++)) + else + ########### + # Success # + ########### + echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully" + fi done - fi -} -################################################################################ -#### Function ValidateSourceAndRuntime ######################################### -ValidateSourceAndRuntime() -{ - ########## - # Prints # - ########## - echo "--------------------------------------------" - echo "Validating file:[$AWS_SAM_TEMPLATE] and NodeJS runtime..." - - ############################################## - # Validate the user has the template.yml and # - # we have the correct runtime set # - ############################################## - - ############################################ - # Look for the template in the source code # - ############################################ - if [ ! -f "$GITHUB_WORKSPACE/$AWS_SAM_TEMPLATE" ]; then - # Errors found - echo "ERROR! Failed to find template:[$GITHUB_WORKSPACE/$AWS_SAM_TEMPLATE]!" - ######################################### - # Need to update the ACTION_CONCLUSTION # - ######################################### - ERROR_FOUND=1 - ERROR_CAUSE="Failed to find template:[$GITHUB_WORKSPACE/$AWS_SAM_TEMPLATE]!" else - ################################# - # Get the runtime from template # - ################################# - GET_RUNTIME_CMD=$(grep "Runtime" "$GITHUB_WORKSPACE/$AWS_SAM_TEMPLATE" ) - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################################# - # Clean any whitespace that may be returned # - ############################################# - GET_RUNTIME_CMD_NO_WHITESPACE="$(echo "${GET_RUNTIME_CMD}" | tr -d '[:space:]')" - GET_RUNTIME_CMD=$GET_RUNTIME_CMD_NO_WHITESPACE - - ############################## - # Check the shell for errors # - ############################## - if [ $ERROR_CODE -ne 0 ]; then - # Errors found - echo "ERROR! Failed to find [Runtime] in:[$GITHUB_WORKSPACE/$AWS_SAM_TEMPLATE]!" - ######################################### - # Need to update the ACTION_CONCLUSTION # - ######################################### - ERROR_FOUND=1 - ERROR_CAUSE="Failed to find [Runtime] in:[$GITHUB_WORKSPACE/$AWS_SAM_TEMPLATE]!" - else - echo "File found and Runtime variable parsed successfully" - ########################### - # Need to set the runtime # - ########################### - RUNTIME=$(echo "$GET_RUNTIME_CMD" | cut -f2 -d':') - fi - fi - - ################################################## - # Need to set the Runtime for the app deployment # - ################################################## - #SetRuntime "$RUNTIME" -} -################################################################################ -#### Function SetRuntime ####################################################### -SetRuntime() -{ - ################ - # Pull in vars # - ################ - RUNTIME=$1 - - ########## - # Prints # - ########## - echo "--------------------------------------------" - echo "Setting NodeJS runtime..." - - ########################################### - # Remove the 'NodeJS' and get the version # - ########################################### - # shellcheck disable=SC2116 - VERSION=$(echo "${RUNTIME:6}") - - # echo "Version:[$VERSION]" - - ################ - # Set the vars # - ################ - VERSION_MAJOR=$(echo "$VERSION" | cut -f1 -d'.') - VERSION_MINOR=$(echo "$VERSION" | cut -f2 -d'.') - - ################################ - # Check if minor is x or undef # - ################################ - if [ "$VERSION_MINOR" == "x" ] || [ -z "$VERSION_MINOR" ]; then - ######################### - # Need to set to latest # - ######################### - # shellcheck disable=SC1090 - NVM_INSTALL_CMD=$(. "$NVM_SRC"; nvm install "$VERSION_MAJOR" ; nvm use "$VERSION_MAJOR") - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ $ERROR_CODE -ne 0 ]; then - echo "ERROR! Failed to install and set Node:[$VERSION_MAJOR]!" - echo "ERROR:[$NVM_INSTALL_CMD]" - ######################################### - # Need to update the ACTION_CONCLUSTION # - ######################################### - ERROR_FOUND=1 - ERROR_CAUSE="Failed to install and set Node:[$VERSION_MAJOR]!" - fi - else - ######################### - # Running exact version # - ######################### - # shellcheck disable=SC1090 - NVM_INSTALL_CMD=$(. "$NVM_SRC"; nvm install "$VERSION" ; nvm use "$VERSION") - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ $ERROR_CODE -ne 0 ]; then - echo "ERROR! Failed to install and set Node:[$VERSION]!" - echo "ERROR:[$NVM_INSTALL_CMD]" - ######################################### - # Need to update the ACTION_CONCLUSTION # - ######################################### - ERROR_FOUND=1 - ERROR_CAUSE="Failed to install and set Node:[$VERSION]!" - fi + ######################## + # No Ansible dir found # + ######################## + echo "WARN! No Ansible base directory found at:[$ANSIBLE_DIR]" + echo "skipping ansible lint" fi } ################################################################################ -#### Function UpdateCheck ###################################################### -UpdateCheck() +#### Function Footer ########################################################### +Footer() { - ########## - # Prints # - ########## - echo "--------------------------------------------" - echo "Updating GitHub Check..." + echo "" + echo "---------------------------" + echo "The script has completed" + echo "---------------------------" + echo "ERRORS FOUND in YAML:[$ERRORS_FOUND_YML]" + echo "ERRORS FOUND in JSON:[$ERRORS_FOUND_JSON]" + echo "ERRORS FOUND in XML:[$ERRORS_FOUND_XML]" + echo "ERRORS FOUND IN MD:[$ERRORS_FOUND_MD]" + echo "ERRORS FOUND in BASH:[$ERRORS_FOUND_BASH]" + echo "ERRORS FOUND in PERL:[$ERRORS_FOUND_PERL]" + echo "ERRORS FOUND in PYTHON:[$ERRORS_FOUND_PYTHON]" + echo "ERRORS FOUND in RUBY:[$ERRORS_FOUND_RUBY]" + echo "ERRORS FOUND in ANSIBLE:[$ERRORS_FOUND_ANSIBLE]" - ########################### - # Build the finished time # - ########################### - FINISHED_DATE=$(date +"%Y-%m-%dT%H:%M:%SZ") + echo "" - ###################################################### - # Set the conclusion to failure if errors were found # - ###################################################### - if [ $ERROR_FOUND -ne 0 ]; then - # Set conclusion - ACTION_CONCLUSTION='failure' - # Set the output - ACTION_OUTPUT="$ERROR_CAUSE" - fi - - ########################################## - # Call to Github to update the Check API # - ########################################## - UPDATE_CHECK_CMD=$( curl -k --fail -X PATCH \ - --url "$GITHUB_URL/repos/$GITHUB_ORG/$GITHUB_REPO/check-runs/$CHECK_ID" \ - -H 'accept: application/vnd.github.antiope-preview+json' \ - -H "authorization: Bearer $GITHUB_TOKEN" \ - -H 'content-type: application/json' \ - --data "{ \"name\": \"$CHECK_NAME\", \"head_sha\": \"$GITHUB_SHA\", \"status\": \"completed\", \"completed_at\": \"$FINISHED_DATE\" , \"conclusion\": \"$ACTION_CONCLUSTION\" , \"output\": { \"title\": \"AWS SAM Deploy Summary\" , \"text\": \"$ACTION_OUTPUT\"} }") - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ $ERROR_CODE -ne 0 ]; then - echo "ERROR! Failed to update GitHub Check!" - echo "ERROR:[$UPDATE_CHECK_CMD]" + ############################### + # Exit with 1 if errors found # + ############################### + if [ $ERRORS_FOUND_YML -ne 0 ] || \ + [ $ERRORS_FOUND_JSON -ne 0 ] || \ + [ $ERRORS_FOUND_XML -ne 0 ] || \ + [ $ERRORS_FOUND_MD -ne 0 ] || \ + [ $ERRORS_FOUND_BASH -ne 0 ] || \ + [ $ERRORS_FOUND_PERL -ne 0 ] || \ + [ $ERRORS_FOUND_PYTHON -ne 0 ] || \ + [ $ERRORS_FOUND_ANSIBLE -ne 0 ] || \ + [ $ERRORS_FOUND_RUBY -ne 0 ]; then + # Failed exit + echo "Exiting with errors found!" exit 1 else - echo "Success! Updated Github Checks API" + # Successful exit + exit 0 fi } ################################################################################ -################################# MAIN ######################################### +############################### MAIN ########################################### ################################################################################ +########## +# Header # +########## +Header + ####################### -# Debug print all env # +# Get Github Env Vars # ####################### -if [ $DEBUG -ne 0 ]; then - echo "--------------------------------------------" - echo "PRINTENV" - printenv - echo "--------------------------------------------" -fi +# Need to pull in all the Github variables +# needed to connect back and update checks +GetGitHubVars -# Go into loop if no errors detected -if [ $ERROR_FOUND -eq 0 ]; then - ####################### - # Get Github Env Vars # - ####################### - # Need to pull in all the Github variables - # needed to connect back and update checks - GetGitHubVars -fi +######################## +# Get the linter rules # +######################## +GetLinterRules -# Go into loop if no errors detected -if [ $ERROR_FOUND -eq 0 ]; then - ####################################### - # Validate We have configuration file # - ####################################### - # Look for the users configuration file to - # connect to AWS and start the Serverless app - ValidateConfigurationFile -fi +###################### +# Validate workspace # +###################### -# Go into loop if no errors detected -if [ $ERROR_FOUND -eq 0 ]; then - ################################### - # Create local configuration file # - ################################### - # Create the local configuration file used - # to connect to AWS and deploy the Serverless app - CreateLocalConfiguration -fi +###################### +# Lint the Yml Files # +###################### +LintYmlFiles -# Go into loop if no errors detected -if [ $ERROR_FOUND -eq 0 ]; then - #################### - # Validate AWS CLI # - #################### - # Need to validate we have the aws cli installed - # And avilable for usage - ValidateAWSCLI -fi +####################### +# Lint the json files # +####################### +LintJsonFiles -######################################## -# Validate the user source and runtime # -######################################## -ValidateSourceAndRuntime +###################### +# Lint the XML Files # +###################### +LintXmlFiles -################ -# Create Check # -################ -# Create the check in GitHub to let the -# user know we are running the deploy action -# We always want to inform user of the process -# Note: No need to create check as were calling from inside a gitHub Action -#CreateCheck +########################### +# Lint the Markdown Files # +########################### +LintMdFiles -# Go into loop if no errors detected -if [ $ERROR_FOUND -eq 0 ]; then - ############## - # Run Deploy # - ############## - # Run the actual deployment of the NodeJS - # to AWS Serverless - RunDeploy -fi +####################### +# Lint the bash files # +####################### +LintBashFiles -################ -# Update Check # -################ -# Update the check with the status -# of the deployment -# We always want to inform user of the process -# Note: No need to create check as were calling from inside a gitHub Action -#UpdateCheck +######################### +# Lint the python files # +######################### +LintPythonFiles -############################### -# Exit with proper error code # -############################### -if [ $ERROR_FOUND -eq 0 ]; then - # Exit with SUCCESS - exit 0 -else - # Exit with ERROR - exit 1 -fi +####################### +# Lint the perl files # +####################### +LintPerlFiles + +####################### +# Lint the ruby files # +####################### +LintRubyFiles + +######################### +# Lint the coffee files # +######################### +LintCoffeeFiles + +########################## +# Lint the Ansible files # +########################## +LintAnsibleFiles + +########## +# Footer # +########## +Footer