-
-
Notifications
You must be signed in to change notification settings - Fork 542
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
Easier execution via docker image #418
Comments
That is expected, because there is no stages:
- push https://pre-commit.com/#hooks-stages You need manually detect differ files (GHA example) if you'd like to run pre-commit only on that files, otherwise, use
That already can be done via
or if you need specific versions use Also, it should not be a problem to create a shell or git alias to run the needed Running all that stuff as many separate containers will slow down hook executions compared to a usage of OS-native env, different teams prefer to use different versions of each tool (and sometimes, their dependencies) so to do what you ask good (and w/o big maintenance effort) will need some time. Anyway, glad to review your PR that will implement that. P.S. That may resolve #397 as not needed, if anyone with Mac will switch to docker |
I would also love to have the above functionality and not have to install any dependencies on my CI/CD pipeline. Below, there is a list of repos that already offer pre-commit hooks using Docker: |
Note: Also, in case of Exampleon host machine ➜ pwd
/home/vm/code/Oslo/modules/aws-environment/.terraform/providers/registry.terraform.io/hashicorp/random/3.4.3
➜ ls -lah
lrwxrwxrwx 1 vm vm 91 Oct 3 17:59 linux_amd64 -> /home/vm/.terraform.d/plugin-cache/registry.terraform.io/hashicorp/random/3.4.3/linux_amd64
in container:
```bash
bash-5.1# pwd
/lint/modules/aws-environment/.terraform/providers/registry.terraform.io/hashicorp/random/3.4.3
bash-5.1# ls -lah
lrwxrwxrwx 1 root root 68 Oct 3 14:55 linux_amd64 -> /tf_plugins/registry.terraform.io/hashicorp/random/3.4.3/linux_amd64 So, work command is TAG=latest
docker run \
-e "USERID=$(id -u):$(id -g)" \
-v "$TF_PLUGIN_CACHE_DIR:$TF_PLUGIN_CACHE_DIR" -e TF_PLUGIN_CACHE_DIR="$TF_PLUGIN_CACHE_DIR" \
-v $(pwd):/lint -w /lint \
ghcr.io/antonbabenko/pre-commit-terraform:$TAG run -a |
Looks like #622 (comment) could be related to this issue WORKDIR $PRE_COMMIT_CACHE
COPY .pre-commit-config.yaml .
RUN \
git init . && \
pre-commit install --install-hooks \
&& chmod -R a+rwX "$PRE_COMMIT_HOME" |
Also, it can be done in slightly different way: |
Hello,
I am trying to implement pre-commit-terraform tflint fmt and checkov but I am facing issues when trying to execute it when running everything on docker image.
To be a bit more specific I just build image with dependencies and created .git/hooks/pre-push script manually:
This is how my .pre-commit-config.yamls looks like:
This surprisingly works very well when trying same solution for commit stage, but it sees no diff when its set push and its getting always "skipped". I saw there is a dedicated docker image but if I am correct there is no easy way for implementation in pre-commit-config.yaml to do the same but via docker image to get rid off dependencies.
How could pre-commit-terraform help solve your problem?
It would be great to have possibility to have hooks preconfigured with docker image and just run following without worrying about dependencies:
The text was updated successfully, but these errors were encountered: