Add bash linting & Fix the TF one (#1626)

* add/fix superlinter

* revert the slim image usage

* add slim back

* fix yaml linting issue

* add superlinter to makefile

* ignore role in validation yml
This commit is contained in:
Tamir Kamara 2022-03-30 14:53:17 +03:00 коммит произвёл GitHub
Родитель 30154f4162
Коммит e5d4a76659
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 41 добавлений и 9 удалений

Просмотреть файл

@ -23,6 +23,10 @@
"type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock"
],
"remoteUser": "vscode",
"remoteEnv": {
// this is used for SuperLinter
"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}",
},
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.defaultProfile.linux": "bash",
@ -181,7 +185,8 @@
"editorconfig.editorconfig",
"github.vscode-pull-request-github",
"mikestead.dotenv",
"humao.rest-client"
"humao.rest-client",
"timonwong.shellcheck",
],
"forwardPorts": [
8000

Просмотреть файл

@ -21,6 +21,7 @@ trim_trailing_whitespace = false
[{*.yaml,*.yml}]
indent_size = 2
max_line_length = 120 # Keep this updated with the yaml-lint file
[Makefile]
indent_style = tab
@ -34,4 +35,4 @@ max_line_length = 120
max_line_length = 120
# disable wildcard imports
ij_java_class_count_to_use_import_on_demand = 99
ij_java_names_count_to_use_import_on_demand = 99
ij_java_names_count_to_use_import_on_demand = 99

7
.github/linters/.yaml-lint.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,7 @@
---
extends: default
rules:
line-length:
max: 120 # Keep this updated with the editorconfig file
level: warning

Просмотреть файл

@ -1,7 +1,7 @@
---
name: Build Validation
on:
on: # yamllint disable-line rule:truthy
pull_request:
branches: [main]
@ -25,7 +25,8 @@ jobs:
persist-credentials: false
- name: Lint code base
uses: github/super-linter@v4
# the slim image is 2GB smaller and we don't use the extra stuff
uses: github/super-linter/slim@v4
env:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: main
@ -33,10 +34,12 @@ jobs:
VALIDATE_MARKDOWN: true
VALIDATE_PYTHON_FLAKE8: true
VALIDATE_YAML: true
VALIDATE_TERRAFORM: true
RUN_LOCAL: true
VALIDATE_TERRAFORM_TFLINT: true
VALIDATE_JAVA: true
JAVA_FILE_NAME: checkstyle.xml
VALIDATE_BASH: true
VALIDATE_BASH_EXEC: true
VALIDATE_GITHUB_ACTIONS: true
- uses: dorny/paths-filter@v2
id: filter

Просмотреть файл

@ -221,10 +221,26 @@ terraform-destroy:
&& . ./devops/scripts/load_terraform_env.sh ${DIR}/.env \
&& cd ${DIR}/terraform/ && ./destroy.sh
# This will validate all files, not only the changed ones as the CI version does.
lint:
$(call target_title, "Linting Python and Terraform") && \
flake8 && \
cd ./templates && terraform fmt -check -recursive -diff
$(call target_title, "Linting")
@terraform fmt -check -recursive -diff
@echo "You might not see much on the screen for a few minutes..."
@# LOG_LEVEL=NOTICE reduces noise but it might also seem like the process is stuck - it's not...
@docker run --name superlinter --pull=always --rm \
-e RUN_LOCAL=true \
-e LOG_LEVEL=NOTICE \
-e VALIDATE_MARKDOWN=true \
-e VALIDATE_PYTHON_FLAKE8=true \
-e VALIDATE_YAML=true \
-e VALIDATE_TERRAFORM_TFLINT=true \
-e VALIDATE_JAVA=true \
-e JAVA_FILE_NAME=checkstyle.xml \
-e VALIDATE_BASH=true \
-e VALIDATE_BASH_EXEC=true \
-e VALIDATE_GITHUB_ACTIONS=true \
-v $${LOCAL_WORKSPACE_FOLDER}:/tmp/lint \
github/super-linter:slim-v4
bundle-build:
$(call target_title, "Building ${DIR} bundle with Porter") \