-
-
Notifications
You must be signed in to change notification settings - Fork 540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows Support / Rewrite hooks to Python #648
Comments
Yep, we're open for contributions. We welcome and encourage them. Especially those of such a brave kind 👍🏻 You may take the https://github.com/antonbabenko/pre-commit-terraform/blob/master/.github/CONTRIBUTING.md as a base point. While it is not quite Windows-aware I guess, it may probably help you with the direction. |
I'll recommend building PoC on something simple, like hooks/terraform_fmt.sh, test it execution speed on big repo via If you have no big repo - try to test on a tiny one but you'll need aware of fractions of a second and test it many times in a row. And when you're ready - send PoC PR - I have a huge repo where I'll test it :) |
Sounds good. Just wanted to make sure you'd be okay with taking on Python as a dependency before attempting a prototype. To me at least, Python makes more sense of a dependency than Bash does since any environment running pre-commit already has Python but not necessarily Bash. I'll give it a try. |
I'm noticing that the These times include the overhead of
I would like to continue, but need to know that you would accept a solution that is performant if you concede the installation time. Unfortunately this is inherent to how no-op testsI changed both 5 runs 'dummy script'
5 runs 'dummy python'
|
As you already mentioned, Python is a hard dependency for
If you feel you can replace all the shell related bits with Python, as @MaxymVlasov already mentioned above we'll be keen to see whether this can be viable and feasible solution. |
@yermulnik I'm happy to discuss this here as suggested. I am confused by asking me to look at Use the following args... - id: terraform_fmt
args:
- --env-vars=DEBUG_START="start
- --env-vars=DEBUG_END=end"
- --env-vars=DEBUG_MID=mi"d
- --env-vars=DEBUG_BOTH="both"
- --env-vars=DEBUG_BARE=bare
- --env-vars=DEBUG_MSG1="This is not how "bash" works"
- --env-vars=DEBUG_MSG2="this is how \"bash\" works" ... and you'll see the behavior differences between what _common.sh supports and what Bash supports.
My point is, For the purposes of this feature, I just need to know what to support. I can implement it to work exactly the same. I'd actually prefer if these hooks didn't fully support Bash interpretation because that would make this feature impossible. 2 lines of simple bash should be about 2 lines in any language. So... finally, I'll just ask my question: should my Python implementation exactly mimic the behavior in the _common.sh column in the above table? |
For that case, better choose |
They are: https://github.com/antonbabenko/pre-commit-terraform/blob/master/hooks/_common.sh#L536 (not specifically interpreted, which makes that function do half of the task apparently, though still those vars are handled by Bash to get them exported into env).
All of the existing hooks rely upon Bash specifically (apart from
If I got it right, the gist of this feature is to re-implement hooks in Python. For this goal I'd say you wanted to support the result (altogether with existing user-facing options and features) — if you can replicate what benefits these hooks bring to our users, then the goal is accomplished IMHO.
I think the idea must be to re-implement rather than to replicate. Hence you're through the greenfield and have all the options to re-implement the way it is better for users.
I'm more than certain — again — you should be targeting to implement the result, rather than behavior. |
PS: Export vars the way they should be exported from within any language. As @MaxymVlasov already mentioned, the |
What problem are you facing?
I cannot use pre-commit from Windows cmd.exe or PowerShell as it depends on bash. Only way is to use "Git Bash"
How could pre-commit-terraform help solve your problem?
I think the bash dependency should go away. Git is used on Windows outside of Git Bash all the time... either directly by developers using PowerShell or cmd.exe... or indirectly by other tools/IDEs, etc.
pre-commit itself is a Python script, so any environment where pre-commit is running necessarily already has Python available. I'd like to see those shell scripts converted to Python. It could use the subprocess module to invoke the Terraform binary.
I'm willing to do this work if you're open to it.
The text was updated successfully, but these errors were encountered: