ci: Fixing pre-commit validate hook#6
Merged
actuarysailor merged 14 commits intomainfrom Aug 16, 2025
Merged
Conversation
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Pull Request Overview
This PR fixes the terraform_validate_docker hook to provide feature parity with the script-based terraform_validate hook by implementing automatic retry logic for handling missing providers and modules.
- Replaces direct
terraform validatecall with the existing validation script that includes retry logic - Enables automatic
terraform initand retry behavior when validation fails due to missing dependencies - Updates hook description to clarify the new automatic initialization behavior
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Put an
xinto the box if that apply:Description of your changes
This PR fixes the
terraform_validate_dockerhook to properly handle missing providers and modules by implementing automatic retry logic withterraform init.Problem: The
terraform_validate_dockerhook was previously configured to runterraform validatedirectly, without the retry logic present in the script-basedterraform_validatehook. As a result, if validation failed due to missing providers or uninitialized modules, the Docker hook would fail immediately instead of attempting to runterraform initand retry.Solution: The hook is now configured to:
/usr/bin/hooks/terraform_validate.shscript (already present in the Docker image) instead of callingterraform validatedirectly.--retry-once-with-cleanup=trueby default to automatically handle missing provider/module scenarios.terraform validateterraform initand retry.terraform/modulesand.terraform/providersdirectories and retry once moreThis ensures feature parity between the script-based and Docker-based validation hooks, providing a consistent user experience regardless of which version is used.
How can we test changes
Test with missing providers:
.terraformdirectory.terraform_validate_dockerhook and verify it automatically runsterraform initand succeeds.Test retry logic with corrupted state:
.terraform/providersor.terraform/modules.Compare with script-based hook:
terraform_validateandterraform_validate_dockerhooks.Test in CI/CD environments: