Add pre-commit hook configuration (#2326)
* Pre-commit config Run following linters on commit: Terraform: - terraform fmt - terraform tflint Python specific: - yapf Shell scripts - shellcheck - shfmt YAML files: - yamllint (disabled as of now) - check-yaml Other: - end-of-file-fixer - trailing-whitespace fixer Fabric specific - tools/tfdoc.py - tools/check_boilerplate.py * linting fixes * Fix boilerplate check
This commit is contained in:
committed by
GitHub
parent
23b256ac25
commit
f8f18734f1
82
.pre-commit-config.yaml
Normal file
82
.pre-commit-config.yaml
Normal file
@@ -0,0 +1,82 @@
|
||||
# Copyright 2024 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
---
|
||||
repos:
|
||||
- repo: https://github.com/antonbabenko/pre-commit-terraform
|
||||
rev: v1.86.0
|
||||
hooks:
|
||||
- id: terraform_fmt
|
||||
- id: terraform_tflint
|
||||
args:
|
||||
- --args=--config=__GIT_WORKING_DIR__/.tflint.hcl
|
||||
files: ^modules/
|
||||
exclude: (tests/fixtures/|tools/lockfile/)
|
||||
# - id: terraform_validate
|
||||
# args:
|
||||
# - --hook-config=--retry-once-with-cleanup=true
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: cff-readme
|
||||
name: Regenerate README.md with tfdoc.py
|
||||
entry: tools/pre-commit-tfdoc.sh
|
||||
language: script
|
||||
#types: [terraform]
|
||||
files: ^(modules|fast).*(tf|README.md)$
|
||||
pass_filenames: true
|
||||
require_serial: true
|
||||
- id: licenese
|
||||
name: Check license presence and other boilerplate checks
|
||||
language: system
|
||||
entry: tools/check_boilerplate.py
|
||||
pass_filenames: true
|
||||
args:
|
||||
- --scan-files
|
||||
- id: tflint-fast
|
||||
name: Checking FAST code with tflint
|
||||
entry: tools/tflint-fast.py
|
||||
language: system
|
||||
pass_filenames: false
|
||||
require_serial: true
|
||||
files: ^fast/.*tf
|
||||
|
||||
# - repo: https://github.com/adrienverge/yamllint
|
||||
# rev: v1.34.0
|
||||
# hooks:
|
||||
# - id: yamllint
|
||||
# args: [-c=.yamllint, --no-warnings]
|
||||
# exclude: (/templates/|modules/cloud-config-container/)
|
||||
|
||||
- repo: https://github.com/jumanjihouse/pre-commit-hooks
|
||||
rev: "3.0.0"
|
||||
hooks:
|
||||
- id: script-must-have-extension
|
||||
- id: shellcheck
|
||||
- id: shfmt
|
||||
exclude: ".*tpl"
|
||||
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.5.0
|
||||
hooks:
|
||||
- id: end-of-file-fixer
|
||||
- id: trailing-whitespace
|
||||
- id: check-yaml
|
||||
args:
|
||||
- --allow-multiple-documents
|
||||
exclude: (/templates/|modules/cloud-config-container/)
|
||||
|
||||
- repo: https://github.com/google/yapf/
|
||||
rev: v0.40.2
|
||||
hooks:
|
||||
- id: yapf
|
||||
Reference in New Issue
Block a user