diff --git a/.cspell.json b/.cspell.json new file mode 100644 index 0000000000..fcd0f38100 --- /dev/null +++ b/.cspell.json @@ -0,0 +1,15 @@ +{ + "ignorePaths": [ + "**/node_modules/**", + "**/vscode-extension/**", + "**/.git/**", + ".vscode", + "megalinter", + "package-lock.json", + "report" + ], + "language": "en", + "noConfigSearch": true, + "words": ["secureCodeBox", "kubernetes"], + "version": "0.2" +} diff --git a/.eslintrc b/.eslintrc.json similarity index 100% rename from .eslintrc rename to .eslintrc.json diff --git a/.github/workflows/mega-linter.yml b/.github/workflows/mega-linter.yml new file mode 100644 index 0000000000..f37d0bf96e --- /dev/null +++ b/.github/workflows/mega-linter.yml @@ -0,0 +1,55 @@ +--- +# MegaLinter GitHub Action configuration file +# More info at https://megalinter.github.io +name: MegaLinter + +on: + # Trigger mega-linter at every push. Action will also be visible from Pull Requests to master + push: # Comment this line to trigger action only on pull-requests (not recommended if you don't pay for GH Actions) + pull_request: + branches: [master, main] + +env: # Comment env block if you do not want to apply fixes + # Apply linter fixes configuration + APPLY_FIXES: none # When active, APPLY_FIXES must also be defined as environment variable (in github/workflows/mega-linter.yml or other CI tool) + APPLY_FIXES_EVENT: pull_request # Decide which event triggers application of fixes in a commit or a PR (pull_request, push, all) + APPLY_FIXES_MODE: commit # If APPLY_FIXES is used, defines if the fixes are directly committed (commit) or posted in a PR (pull_request) + +concurrency: + group: ${{ github.ref }}-${{ github.workflow }} + cancel-in-progress: true + +jobs: + build: + name: MegaLinter + runs-on: ubuntu-latest + steps: + # Git Checkout + - name: Checkout Code + uses: actions/checkout@v2 + with: + token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} + fetch-depth: 0 + + # MegaLinter + - name: MegaLinter + id: ml + # You can override MegaLinter flavor used to have faster performances + # More info at https://megalinter.github.io/flavors/ + uses: megalinter/megalinter@v5 + env: + # All available variables are described in documentation + # https://megalinter.github.io/configuration/ + VALIDATE_ALL_CODEBASE: false # only lint changed files + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # ADD YOUR CUSTOM ENV VARIABLES HERE TO OVERRIDE VALUES OF .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY + + # Upload MegaLinter artifacts + - name: Archive production artifacts + if: ${{ success() }} || ${{ failure() }} + uses: actions/upload-artifact@v2 + with: + name: MegaLinter reports + path: | + report + mega-linter.log diff --git a/.gitignore b/.gitignore index 13524d4da8..752435a286 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,7 @@ tags [._]*.un~ # End of https://www.toptal.com/developers/gitignore/api/vim + + +# Megalint report dir +report diff --git a/.mega-linter.yml b/.mega-linter.yml new file mode 100644 index 0000000000..d22ae6a30c --- /dev/null +++ b/.mega-linter.yml @@ -0,0 +1,27 @@ +# Configuration file for MegaLinter +# See all available variables at https://megalinter.github.io/configuration/ and in linters documentation + +APPLY_FIXES: none # all, none, or list of linter keys +# 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 +DISABLE: + - COPYPASTE # Comment to enable checks of excessive copy-pastes + - MARKDOWN # Disable markdown as the readmes are generated automatically + - CREDENTIALS # Disable checks for credentials, as there are some false positives in the repo for documentation purposes (e.g demo-targets) +DISABLE_LINTERS: + - JAVASCRIPT_STANDARD # standard is a javascript linter that by design can not be configured in any way. This project uses eslint anyways. + - TYPESCRIPT_STANDARD # standard is a typescript linter that by design can not be configured in any way. This project uses eslint anyways. + - SPELL_CSPELL # disable cspell because if finds way to many false positives and it would be way to much work to exclude all false positives + - EDITORCONFIG_EDITORCONFIG_CHECKER # this linter complains about non important stuff like tabs instead of spaces etc. Disabled because its annoying + - PYTHON_MYPY # fails because missing cache file "error: --install-types failed (no mypy cache directory)". See https://github.com/python/mypy/issues/10600#issuecomment-857351152 + +SHOW_ELAPSED_TIME: true +DISABLE_ERRORS: true # Uncomment if you want MegaLinter to detect errors but not block CI to pass + +# ignore files generated by controller-gen +FILTER_REGEX_EXCLUDE: (.*rbac/role\.yaml|.*bases/.*\.yaml) +VALIDATE_ALL_CODEBASE: false +IGNORE_GENERATED_FILES: true + +# disable useless alpaca ascii art that gets printed at the start of the linting +PRINT_ALPACA: false \ No newline at end of file diff --git a/Makefile b/Makefile index 9493168472..414e1ca729 100644 --- a/Makefile +++ b/Makefile @@ -92,4 +92,20 @@ help: ## Display this help screen. test-scanner: make test -C $(SCANNERS_DIR)/$(target) test-hook: - make test -C $(HOOKS_DIR)/$(target) \ No newline at end of file + make test -C $(HOOKS_DIR)/$(target) + + +.PHONY: +lint: ## Lint only changed files with respect to main branch + npx mega-linter-runner + @printf "\033[36m\n\n\nThe generated reports can be found under ./report/linters_logs/ \n\n\033[0m" + +.PHONY: +lintfix: ## Lint only changed files with respect to main branch and apply automatic fixes if possible + npx mega-linter-runner --fix + @printf "\033[36m\n\n\nThe generated reports can be found under ./report/linters_logs/ \n\n\033[0m" + +.PHONY: +lintall: ## Lint complete repo + npx mega-linter-runner --env VALIDATE_ALL_CODEBASE=true + @printf "\033[36m\n\n\nThe generated reports can be found under ./report/linters_logs/ \n\n\033[0m"