Sign inSign up

assignuser/super-linter

By assignuser

•Updated about 6 years ago

Image
0

476

assignuser/super-linter repository overview

⁠Super-Linter

This repository is for the GitHub Action to run a Super-Linter. It is a simple combination of various linters, written in bash, to help validate your source code.

The end goal of this tool:

  • Prevent broken code from being uploaded to the default branch (Usually master)
  • Help establish coding best practices across multiple languages
  • Build guidelines for code layout and format
  • Automate the process to help streamline code reviews

⁠Table of Contents

⁠How it Works

The super-linter finds issues and reports them to the console output. Fixes are suggested in the console output but not automatically fixed, and a status check will show up as failed on the pull request.

The design of the Super-Linter is currently to allow linting to occur in GitHub Actions as a part of continuous integration occurring on pull requests as the commits get pushed. It works best when commits are being pushed early and often to a branch with an open or draft pull request. There is some desire to move this closer to local development for faster feedback on linting errors but this is not yet supported.

⁠Supported Linters

Developers on GitHub can call the GitHub Action to lint their code base with the following list of linters:

⁠How to use

More in-depth tutorial⁠ available

To use this GitHub Action you will need to complete the following:

  1. Create a new file in your repository called .github/workflows/linter.yml
  2. Copy the example workflow from below into that new file, no extra configuration required
  3. Commit that file to a new branch
  4. Open up a pull request and observe the action working
  5. Enjoy your more stable, and cleaner code base
  6. Check out the Wiki⁠ for customization options

NOTE: If you pass the Environment variable GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} in your workflow, then the GitHub Super-Linter will mark the status of each individual linter run in the Checks section of a pull request. Without this you will only see the overall status of the full run. There is no need to set the GitHub Secret as it is automatically set by GitHub, it only needs to be passed to the action.

⁠Example connecting GitHub Action Workflow

In your repository you should have a .github/workflows folder with GitHub Action similar to below:

  • .github/workflows/linter.yml

This file should have the following code:

---
###########################
###########################
## Linter GitHub Actions ##
###########################
###########################
name: Lint Code Base

#
# Documentation:
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
#

#############################
# Start the job on all push #
#############################
on:
  push:
    branches-ignore: [master]
    # Remove the line above to run when pushing to master
  pull_request:
    branches: [master]

###############
# Set the Job #
###############
jobs:
  build:
    # Name the Job
    name: Lint Code Base
    # Set the agent to run on
    runs-on: ubuntu-latest

    ##################
    # Load all steps #
    ##################
    steps:
      ##########################
      # Checkout the code base #
      ##########################
      - name: Checkout Code
        uses: actions/checkout@v2

      ################################
      # Run Linter against code base #
      ################################
      - name: Lint Code Base
        uses: docker://github/super-linter:v3
        env:
          VALIDATE_ALL_CODEBASE: false
          DEFAULT_BRANCH: master
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

NOTE: Using the line:uses: docker://github/super-linter:v3 will pull the image down from DockerHub and run the GitHub Super-Linter. Using the line: uses: github/super-linter@v3 will build and compile the GitHub Super-Linter at build time. This can be far more costly in time...

⁠Environment variables

The super-linter allows you to pass the following ENV variables to be able to trigger different functionality.

Note: All the VALIDATE_[LANGUAGE] variables behave in a very specific way:

  • If none of them are passed, then they all default to true.
  • If any one of the variables are set to true, we default to leaving any unset variable to false (only validate those languages).
  • If any one of the variables are set to false, we default to leaving any unset variable to true (only exclude those languages).
  • If there are VALIDATE_[LANGUAGE] variables set to both true and false. It will fail.

This means that if you run the linter "out of the box", all languages will be checked. But if you wish to select or exclude specific linters, we give you full control to choose which linters are run, and won't run anything unexpected.

ENV VARDefault ValueNotes
ACTIONS_RUNNER_DEBUGfalseFlag to enable additional information about the linter, versions, and additional output.
ANSIBLE_DIRECTORY/ansibleFlag to set the root directory for Ansible file location(s).
DEFAULT_BRANCHmasterThe name of the repository default branch.
DEFAULT_WORKSPACE/tmp/lintThe location containing files to lint if you are running locally.
DISABLE_ERRORSfalseFlag to have the linter complete with exit code 0 even if errors were detected.
JAVASCRIPT_ES_CONFIG_FILE.eslintrc.ymlFilename for eslint configuration⁠ (ex: .eslintrc.yml, .eslintrc.json)
LINTER_RULES_PATH.github/lintersDirectory for all linter configuration rules.
LOG_FILEsuper-linter.logThe file name for outputting logs. All output is sent to the log file regardless of LOG_LEVEL.
LOG_LEVELVERBOSEHow much output the script will generate to the console. One of VERBOSE, DEBUG or TRACE.
MULTI_STATUStrueA status API is made for each language that is linted to make visual parsing easier.
MARKDOWN_CONFIG_FILE.markdown-lint.ymlFilename for Markdownlint configuration⁠ (ex: .markdown-lint.yml, .markdownlint.json, .markdownlint.yaml)
OUTPUT_FORMATnoneThe report format to be generated, besides the stdout one. Output format of tap is currently using v13 of the specification. Supported formats: tap
OUTPUT_FOLDERsuper-linter.reportThe location where the output reporting will be generated to. Output folder must not previously exist.
OUTPUT_DETAILSsimplerWhat level of details to be reported. Supported formats: simpler or detailed.
PYTHON_PYLINT_CONFIG_FILE.python-lintFilename for pylint configuration⁠ (ex: .python-lint, .pylintrc)
PYTHON_FLAKE8_CONFIG_FILE.flake8Filename for flake8 configuration⁠ (ex: .flake8, tox.ini)
RUBY_CONFIG_FILE.ruby-lint.ymlFilename for rubocop configuration⁠ (ex: .ruby-lint.yml, .rubocop.yml)
TYPESCRIPT_ES_CONFIG_FILE.eslintrc.ymlFilename for eslint configuration⁠ (ex: .eslintrc.yml, .eslintrc.json)
VALIDATE_ALL_CODEBASEtrueWill parse the entire repository and find all files to validate across all types. NOTE: When set to false, only new or edited files will be parsed for validation.
VALIDATE_ANSIBLEtrueFlag to enable or disable the linting process of the Ansible language.
VALIDATE_ARMtrueFlag to enable or disable the linting process of the ARM language.
VALIDATE_BASHtrueFlag to enable or disable the linting process of the Bash language.
VALIDATE_CLOJUREtrueFlag to enable or disable the linting process of the Clojure language.
VALIDATE_CLOUDFORMATIONtrueFlag to enable or disable the linting process of the AWS Cloud Formation language.
VALIDATE_COFFEEtrueFlag to enable or disable the linting process of the Coffeescript language .
VALIDATE_CSStrueFlag to enable or disable the linting process of the CSS language.
VALIDATE_DARTtrueFlag to enable or disable the linting process of the Dart language.
VALIDATE_DOCKERtrueFlag to enable or disable the linting process of the Docker language.
VALIDATE_DOCKER_HADOLINTtrueFlag to enable or disable the linting process of the Docker language.
VALIDATE_EDITORCONFIGtrueFlag to enable or disable the linting process with the editorconfig.
VALIDATE_ENVtrueFlag to enable or disable the linting process of the ENV language.
VALIDATE_GOtrueFlag to enable or disable the linting process of the Golang language.
VALIDATE_GROOVYtrueFlag to enable or disable the linting process of the language.
VALIDATE_HTMLtrueFlag to enable or disable the linting process of the HTML language.
VALIDATE_JAVAtrueFlag to enable or disable the linting process of the language.
VALIDATE_JAVASCRIPT_EStrueFlag to enable or disable the linting process of the Javascript language. (Utilizing: eslint)
VALIDATE_JAVASCRIPT_STANDARDtrueFlag to enable or disable the linting process of the Javascript language. (Utilizing: standard)
VALIDATE_JSONtrueFlag to enable or disable the linting process of the JSON language.
VALIDATE_JSXtrueFlag to enable or disable the linting process for jsx files (Utilizing: eslint)
VALIDATE_KOTLINtrueFlag to enable or disable the linting process of the Kotlin language.
VALIDATE_LUAtrueFlag to enable or disable the linting process of the language.
VALIDATE_MDtrueFlag to enable or disable the linting process of the Markdown language.
VALIDATE_OPENAPItrueFlag to enable or disable the linting process of the OpenAPI language.
VALIDATE_PERLtrueFlag to enable or disable the linting process of the Perl language.
VALIDATE_PHPtrueFlag to enable or disable the linting process of the PHP language. (Utilizing: PHP built-in linter) (keep for backward compatibility)
VALIDATE_PHP_BUILTINtrueFlag to enable or disable the linting process of the PHP language. (Utilizing: PHP built-in linter)
VALIDATE_PHP_PHPCStrueFlag to enable or disable the linting process of the PHP language. (Utilizing: PHP CodeSniffer)

Tag summary

Content type

Image

Digest

Size

1 GB

Last updated

about 6 years ago

docker pull assignuser/super-linter