-
Notifications
You must be signed in to change notification settings - Fork 215
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
Add pre commit hooks support #585
Conversation
Signed-off-by: l.h. riley <[email protected]>
Signed-off-by: l.h. riley <[email protected]>
Signed-off-by: l.h. riley <[email protected]>
c757e16
to
151dbbd
Compare
In testing over the last week I've come across a weird issue when using the In my case, I had a copy in ❯ pre-commit run -av ct-lint-golang
chart testing lint (please wait)....................................................Failed
- hook id: ct-lint-golang
- duration: 0.01s
- exit code: 1
Linting charts...
Error: failed loading configuration: 'chart_schema.yaml' neither specified nor found in default locations
failed loading configuration: 'chart_schema.yaml' neither specified nor found in default locations These files should be available in the hook, as they are provided in the git repo under Update: This did not work as expected. Adding the expected files into our git repo under Is there any option in the config files to specify where to look for the schema / linting files? |
92b72ad
to
151dbbd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can move this to a directory, myabe called tools
or something else?
@cpanato I'm not sure that I understand your ask, Do you mean move the bash script to a different directory? i.e. not Instead:
|
yes, something like that, move all those scripts to a specific directory, this is more a support tool for users using the chart-testing for the charts and not much for this repository and flow here. |
You are correct. These scripts are used by |
pushed a commit moving the script as requested |
65ad8d4
to
47825e3
Compare
Signed-off-by: l.h. riley <[email protected]>
47825e3
to
d24f65b
Compare
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dot file should be in the same directory as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add all files the dot file and the .sh under 'tools/pre-commit'
@cpanato |
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
This PR was closed because it has been stalled for 10 days with no activity. |
Is there any way that we can bring this back to life? 🙏 |
yes, sure, but this hook have nothing to do in this repository, so that why i asked to add in a specific directory, and the users can download that and install the hook in the repo they want |
I don't think there's any way to implement this without There used to be a practice of people creating mirrors / forks of popular projects and putting pre-commit configuration in them, but it's fallen out of favor for obvious reasons. If you don't want to add a dotfile to the root project, it is what it is 🤷 |
My main issue with accepting this PR is that this pre-commit hook is to be used when dealing with helm charts, not here in this repo, which is the tool that is used in ci. People do not need to clone this repo to build their helm charts, so that should be an example of how to implement the hook as a document. Do you have any thoughts @davidkarlsen? |
@cpanato people don't need to clone this repo to use the pre-commit hook, at least not directly, |
I am dumb. Can you explain how this will work when people are working in another repository for the helm charts? Let's say I am updating my chart in this repo: https://github.com/falcosecurity/charts/tree/master/charts/falco-exporter. How will this pre-commit hook work? and i don't have https://github.com/helm/chart-testing cloned in my machine |
To add context, in addition to orchestrating command execution, The main benefit of using |
this is a pre-commit config on one of my projects. If you check the build step in this pre-commit.ci job, you can see that An aside to call out a possible alternative route: ruff-pre-commit is a repo that exists solely for pre-commit to point to when installing |
Just piping in to say I would love this feature. Would help make our pipelines fail faster, as right now people don't become aware of linting errors until the github action runs after a commit, which is frustrating (especially when it's simple things like bumping the version of the chart, for example). |
And here we get to the core. My view aligns with @cpanato that the pre-commit hooks should reside in the repos that host the charts not this repo which hosts tooling. It would not benefit consumers of the What we could do however, is to offer a gist in this repo to show how one can integrate other 3rd party tooling around your chart development - that could make sense. |
hang on... researching a bit... I'll get back |
yes, sorry, I was jumping to conclusions a bit fast. It seems patterns are like: perhaps we should rather create a separate repo for offering these hooks. That seems like a more widespread pattern - and also more clearly separates the tool itself from usage of the tool through a hook. But I agree that it provides value to offer a central definition of the hooks for folks to be able to consume/hook into (pun intended) |
agree in having a new repo and put that there, what will be the name or |
Those two repos are not very representative of the ecosystem. It's far more common to have the hook config in the same repo as the tool. |
First and foremost @lhriley thanks for not only starting the conversation, but for the integration that will enable Regarding the key question within this issue (where hooks for However, for at least |
Hi all, first let me say thanks to everyone who has participated in this discussion. I'm not able to contribute any code changes at the moment, so I would appreciate it if someone could handle any changes requested or moving the code to a different repository if that's the decision. I'd like to add some comments, however, since there is an incomplete picture of how
While the statement above could be true, one of the features of The nice part about this is that the version of the tool can be pinned to a unique git commit, and then when One benefit is that this can speed up CI dramatically when cache is configured properly as multiple versions of So, even though there is a pattern where some tools use a separate repo for hooks, that's not the intended / ideal use case for a tool such as I honestly don't have a strong opinion for which pattern to adopt. There are a few hacks to make the hooks work as is, and if the maintainers would prefer a separate repo there are a few limitations that would arise that would need to be considered:
Ideally, the hooks should remain in this repo for full functionality, but if that isn't "allowed", then I would ask that someone pick up the work from this PR and run with it. 🖖🏼 |
hi @lhriley, echoing Andy's thanks for the PR and convo. Also thanks for your last thoughtful reply. A few clarifications:
So in summary, apart for something you might be able to clarify in point 3, I think the downsides don't apply to this specific tool. But please correct me if there are some major unsavory hacks or duplicated code needed for some reason? A few more thoughts:
|
Regarding:
There are weird edge cases that I would expect anyone working across repos might encounter. I'm not clear on what would be required, and it would need to come out of testing. I simply mentioned the possibility as I've had to write several scripts to work around design limitations with I would refer you to the scripts that I wrote to make the containerized releases compatible with Furthermore, there are some odd issues with Additionally, the biggest annoyance I've experienced is that Again, I'm not able to contribute any code at the moment for personal reasons, despite the fact that I would love to get first commit credit in one of this organization's repos. It could be possible at some point in the future, but I'm not clear when that might be. I'm happy to give guidance when possible, in whatever limited capacity that takes. |
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
This PR was closed because it has been stalled for 10 days with no activity. |
What this PR does / why we need it:
This PR adds support for pre-commit hooks in a variety of options.
ct
binarygolang
hooks build thect
package in a virtual environment managed bypre-commit
container
hooks depend on Docker and use thelatest
official container imageWhich issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close that issue when PR gets merged): fixes # n/aSpecial notes for your reviewer:
This can be tested with a configuration similar to the following:
Additionally, it should be noted that the
container
variations require a bash script (included) to work properly. Using the nativedocker_image
pre-commit "language" is not enough due to the requirements ofct
. The basic configuration is based on the information in theREADME.md
and includes some tweaks to work with pre-commit.Of special note, I have included a hack in the script to mount the
gcloud SDK
into the container as well, since we use this for IAM access to our OCI repository in Google Artifact Registry. I assume similar functionality could be added to support other providers. The alternative is to build containersFROM
the officialchart-testing
image or include dead weight in the official container. I opted for the hack to avoid the alternative.Related:
pre-commit/pre-commit#2968