Skip to content

Comments

fix(ci): include .tftest.hcl files in terraform fmt pre-commit hook#872

Open
hwkiem wants to merge 1 commit intomainfrom
fix/pre-commit-terraform-fmt-tftest
Open

fix(ci): include .tftest.hcl files in terraform fmt pre-commit hook#872
hwkiem wants to merge 1 commit intomainfrom
fix/pre-commit-terraform-fmt-tftest

Conversation

@hwkiem
Copy link
Contributor

@hwkiem hwkiem commented Feb 14, 2026

Summary

  • Override the files pattern on the terraform_fmt pre-commit hook to also match .tftest.hcl files

Context

The upstream terraform_fmt hook from antonbabenko/pre-commit-terraform only matches .tf, .tofu, and .tfvars files. This means .tftest.hcl files are not formatted by the pre-commit hook, but CI runs terraform fmt -check -recursive which catches all Terraform file types.

This mismatch caused format check failures on #870 and #871 — the pre-commit hook passed locally but CI failed on unformatted test files.

Test plan

  • Modify a .tftest.hcl file with bad formatting and verify the pre-commit hook catches it

The upstream terraform_fmt hook only matches .tf, .tofu, and .tfvars
files. Override the files pattern to also match .tftest.hcl so that
Terraform test files are formatted on commit, matching the CI check
which runs `terraform fmt -check -recursive` on all file types.
@hwkiem hwkiem force-pushed the fix/pre-commit-terraform-fmt-tftest branch from a8627ab to 0fcf44c Compare February 17, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants