-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
102 lines (89 loc) · 3.15 KB
/
.pre-commit-config.yaml
File metadata and controls
102 lines (89 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
repos:
# Terraform formatting and validation (commit stage)
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.96.2
hooks:
- id: terraform_fmt
- id: terraform_validate
args: [--init-args=-backend=false]
# Local hooks
- repo: local
hooks:
- id: terraform-docs
name: generate terraform docs
description: Generate terraform documentation for all modules
entry: bash scripts/gen-docs.sh
language: system
files: \.tf$
exclude: ^\.terraform/.*$
pass_filenames: false
- id: tflint
name: tflint
description: Run tflint to check terraform code quality
entry: tflint
language: system
files: \.tf$
exclude: ^\.terraform/.*$
- id: schema-drift
name: schema drift check
entry: uv run --with PyYAML scripts/check_schema_drift.py --mapping scripts/resource_mapping.yml --schema schemas/v1.json --terraform-dir .
language: system
files: ^(schemas/|scripts/resource_mapping\.yml$|\.terraform\.lock\.hcl$)
pass_filenames: false
require_serial: true
- id: terraform-test-root
name: terraform test (root, mock)
entry: terraform test
language: system
pass_filenames: false
stages: [pre-push]
files: ^(.*\.tf$|tests/|\.terraform\.lock\.hcl$)
- id: terraform-test-modules
name: terraform test (modules, mock)
entry: bash -c 'for m in project environments jobs credentials repository; do (cd modules/$m && terraform init -backend=false && terraform test -verbose) || exit 1; done'
language: system
pass_filenames: false
stages: [pre-push]
files: ^modules/
- id: yaml-schema-valid
name: yaml schema accepts valid.yml
entry: bash -c 'uvx check-jsonschema==0.37.1 --schemafile schemas/v1.json validate/tests/valid.yml'
language: system
pass_filenames: false
stages: [pre-push]
always_run: true
- id: yaml-schema-invalid
name: yaml schema rejects invalid.yml
entry: bash -c '! uvx check-jsonschema==0.37.1 --schemafile schemas/v1.json validate/tests/invalid.yml'
language: system
pass_filenames: false
stages: [pre-push]
always_run: true
# General linting and formatting
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
name: Trim trailing whitespace
exclude: ^\.terraform/.*$
- id: end-of-file-fixer
name: Fix end of file
exclude: ^\.terraform/.*$
- id: check-yaml
name: Check YAML syntax
exclude: ^\.terraform/.*$
- id: check-json
name: Check JSON syntax
exclude: ^\.terraform/.*$
- id: check-added-large-files
name: Check for large files
args: [--maxkb=1000]
exclude: ^\.terraform/.*$
# Detect secrets
- repo: https://github.com/Yelp/detect-secrets
rev: v1.4.0
hooks:
- id: detect-secrets
name: Detect secrets
args: [--baseline, .secrets.baseline]
exclude: ^\.terraform/.*$