From dd49957d846a06d43aea850fceb73acb7d1bb020 Mon Sep 17 00:00:00 2001 From: Connor Koehler Date: Thu, 5 Oct 2023 06:10:21 -0400 Subject: [PATCH] Draft: Playing with local linting --- .github/workflows/linter.yaml | 11 ----------- .mega-linter.yml | 34 ++++++++++++++++++++++++++++++++++ DEVELOPING.md | 10 ++++++++++ 3 files changed, 44 insertions(+), 11 deletions(-) create mode 100644 .mega-linter.yml diff --git a/.github/workflows/linter.yaml b/.github/workflows/linter.yaml index 4223110441..ad5c26de16 100644 --- a/.github/workflows/linter.yaml +++ b/.github/workflows/linter.yaml @@ -28,14 +28,3 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # setting this to false means that only changed files will be scanned in each commit VALIDATE_ALL_CODEBASE: ${{ github.event_name != 'pull_request' }} - # Enable Linters to run - VALIDATE_GITHUB_ACTIONS: true - # VALIDATE_GOOGLE_JAVA_FORMAT: true - JAVA_FILE_NAME: ../../contrib/checkstyle.xml - VALIDATE_DOCKERFILE_HADOLINT: true - DOCKERFILE_HADOLINT_FILE_NAME: ../../contrib/docker/.hadolint.yaml - # VALIDATE_MARKDOWN: true - VALIDATE_XML: true - VALIDATE_YAML: true - FILTER_REGEX_EXCLUDE: .*contrib/helm.* - GITHUB_COMMENT_REPORTER: false diff --git a/.mega-linter.yml b/.mega-linter.yml new file mode 100644 index 0000000000..003ed495e3 --- /dev/null +++ b/.mega-linter.yml @@ -0,0 +1,34 @@ +# Configuration file for MegaLinter +# See all available variables at https://megalinter.io/configuration/ and in linters documentation + +APPLY_FIXES: all +# ENABLE: # If you use ENABLE variable, all other languages/formats/tooling formats will be disabled by default +# ENABLE_LINTERS: # If you use ENABLE_LINTERS variable, all other linters will be disabled by default +ENABLE: + - COPYPASTE + - SPELL + - ACTION + - DOCKERFILE + - XML + - YAML +ENABLE_LINTERS: + - JSON_PRETTIER + - REPOSITORY_GITLEAKS + - DOCKERFILE_HADOLINT + - XML_XMLLINT + - YAML_PRETTIER + - YAML_YAMLLINT + - SPELL_CSPELL + - ACTION_ACTIONLINT + - KUBERNETES_HELM +PRINT_ALL_FILES: false +DOCKERFILE_HADOLINT_FILE_NAME: ../../contrib/docker/.hadolint.yaml +FILTER_REGEX_EXCLUDE: .*contrib/helm.* +MARKDOWN_MARKDOWN_LINK_CHECK_DISABLE_ERRORS: true +SHOW_ELAPSED_TIME: true +FLAVOR_SUGGESTIONS: false +EMAIL_REPORTER: false +FILEIO_REPORTER: false +JSON_REPORTER: true +GITHUB_STATUS_REPORTER: false +GITHUB_COMMENT_REPORTER: false diff --git a/DEVELOPING.md b/DEVELOPING.md index 01c0cd7b6e..3d1d139c33 100644 --- a/DEVELOPING.md +++ b/DEVELOPING.md @@ -293,6 +293,16 @@ additional things to consider when developing: * If you fix a bug, add a test. * If you answer a question, add some documentation. +### Local Mega Linter validation and auto fix +The project leverages [MegaLinter](https://github.com/marketplace/actions/megalinter) as a GitHub action to run across +changed files in PR's and the entire codebase on merge. To run the same linting rule set local following the following steps. +Instructions are derived from [MegaLinter Runner Documentation](https://megalinter.io/latest/mega-linter-runner/) + +1) Install [Node Package Manager (NPM)](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) +2) Install mega-linter-runner for current users `npm install mega-linter-runner --save-dev` +3) Run MegaLinter from project root using project configuration `mega-linter-runner .mega-linter.yml .` +* To have MegaLinter attempt to fix errors add the `--fix` option to the command: `mega-linter-runner .mega-linter.yml --fix .` + ## Helpful Commands ### Cleaning