11repos :
2- # Terraform formatting and documentation
2+ # Terraform formatting and validation (commit stage)
3+ - repo : https://github.com/antonbabenko/pre-commit-terraform
4+ rev : v1.96.2
5+ hooks :
6+ - id : terraform_fmt
7+ - id : terraform_validate
8+ args : [--init-args=-backend=false]
9+
10+ # Local hooks
311 - repo : local
412 hooks :
5- - id : terraform-docs-go
6- name : terraform- docs
7- description : Generate terraform documentation
8- entry : terraform-docs -c .terraform- docs.yml
13+ - id : terraform-docs
14+ name : generate terraform docs
15+ description : Generate terraform documentation for all modules
16+ entry : bash scripts/gen- docs.sh
917 language : system
10- files : ^[^/]* \.tf$
18+ files : \.tf$
1119 exclude : ^\.terraform/.*$
20+ pass_filenames : false
1221
13- # Terraform linting
14- - repo : local
15- hooks :
1622 - id : tflint
1723 name : tflint
1824 description : Run tflint to check terraform code quality
@@ -21,6 +27,46 @@ repos:
2127 files : \.tf$
2228 exclude : ^\.terraform/.*$
2329
30+ - id : schema-drift
31+ name : schema drift check
32+ entry : uv run --with PyYAML scripts/check_schema_drift.py --mapping scripts/resource_mapping.yml --schema schemas/v1.json --terraform-dir .
33+ language : system
34+ files : ^(schemas/|scripts/resource_mapping\.yml$|\.terraform\.lock\.hcl$)
35+ pass_filenames : false
36+ require_serial : true
37+
38+ - id : terraform-test-root
39+ name : terraform test (root, mock)
40+ entry : terraform test
41+ language : system
42+ pass_filenames : false
43+ stages : [pre-push]
44+ always_run : true
45+
46+ - id : terraform-test-modules
47+ name : terraform test (modules, mock)
48+ 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'
49+ language : system
50+ pass_filenames : false
51+ stages : [pre-push]
52+ always_run : true
53+
54+ - id : yaml-schema-valid
55+ name : yaml schema accepts valid.yml
56+ entry : bash -c 'uvx check-jsonschema==0.37.1 --schemafile schemas/v1.json validate/tests/valid.yml'
57+ language : system
58+ pass_filenames : false
59+ stages : [pre-push]
60+ always_run : true
61+
62+ - id : yaml-schema-invalid
63+ name : yaml schema rejects invalid.yml
64+ entry : bash -c '! uvx check-jsonschema==0.37.1 --schemafile schemas/v1.json validate/tests/invalid.yml'
65+ language : system
66+ pass_filenames : false
67+ stages : [pre-push]
68+ always_run : true
69+
2470 # General linting and formatting
2571 - repo : https://github.com/pre-commit/pre-commit-hooks
2672 rev : v4.4.0
0 commit comments