-
-
Notifications
You must be signed in to change notification settings - Fork 581
Support for terraform test #549
Copy link
Copy link
Open
Labels
estimate/1dayNeed 1 work day to be doneNeed 1 work day to be donefeatureNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Metadata
Metadata
Assignees
Labels
estimate/1dayNeed 1 work day to be doneNeed 1 work day to be donefeatureNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
What problem are you facing?
I want to run
terraform testin a pre-commit hook if either the module or one of the module's tests changed.terraform testhas been around since at least 2021 and became quite usable with thepreconditionandpostconditionblocks introduced in terraform 1.2.0, but is nevertheless still a "experimental" feature of the terraform CLI.How could pre-commit-terraform help solve your problem?
In principle
terraform testis "just the same" as theterraform validatehook, except that it should be only triggered if eitherdir_pathhas a parent directory that is calledtests(i.e. there is a changed test in the commit) ordir_pathhas a child directory that is calledtests(i.e. there is a change in the module). Either way,terraform testwould be run from the terraform module root directory and it should fail the commit if the tests do not pass.