-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[v2] Add pre-commit and CI static checks #1025
Conversation
There are quite a few go-lint errors that I'm happy to fix if we agree to proceed with this change 😃 |
.pre-commit-config.yaml
Outdated
exclude: | | ||
(?x)( | ||
.*zz_generated.*| | ||
^pkg/apis/keda/v1alpha1/triggerauthentication_types\.go$| | ||
^pkg/handler/hashicorpvault_handler\.go$| | ||
^pkg/scalers/azure/azure_aad_podidentity\.go$| | ||
^pkg/scalers/azure/azure_eventhub\.go$| | ||
^pkg/scalers/azure/azure_monitor\.go$| | ||
^pkg/scalers/azure/azure_storage\.go$| | ||
^pkg/scalers/azure_eventhub_scaler\.go$| | ||
^pkg/scalers/azure_queue_scaler\.go$| | ||
^pkg/scalers/azure_servicebus_scaler\.go$| | ||
^pkg/scalers/cron_scaler\.go$| | ||
^pkg/scalers/kafka_scram_client\.go$| | ||
^pkg/scalers/liiklus_scaler\.go$| | ||
^pkg/scalers/postgresql_scaler\.go$| | ||
^pkg/scalers/prometheus\.go$| | ||
^pkg/scalers/rabbitmq_scaler\.go$| | ||
^pkg/scalers/scaler\.go$| | ||
^version/version\.go$ | ||
) |
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.
Those can be fixed in follow up PRs and make good candidates for good-first-issues (Hacktober is coming) 😄
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.
If this gets merged, please don't forget to open issues for these.
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.
This looks OK to me, thanks!
Just make sure to target v2 instead of master so that @zroubalik doesn't have to plow through all of these.
Just a tip, let's discuss this in an issue first in the future because if we didn't like this then you would've wasted a ton of work
.pre-commit-config.yaml
Outdated
exclude: | | ||
(?x)( | ||
.*zz_generated.*| | ||
^pkg/apis/keda/v1alpha1/triggerauthentication_types\.go$| | ||
^pkg/handler/hashicorpvault_handler\.go$| | ||
^pkg/scalers/azure/azure_aad_podidentity\.go$| | ||
^pkg/scalers/azure/azure_eventhub\.go$| | ||
^pkg/scalers/azure/azure_monitor\.go$| | ||
^pkg/scalers/azure/azure_storage\.go$| | ||
^pkg/scalers/azure_eventhub_scaler\.go$| | ||
^pkg/scalers/azure_queue_scaler\.go$| | ||
^pkg/scalers/azure_servicebus_scaler\.go$| | ||
^pkg/scalers/cron_scaler\.go$| | ||
^pkg/scalers/kafka_scram_client\.go$| | ||
^pkg/scalers/liiklus_scaler\.go$| | ||
^pkg/scalers/postgresql_scaler\.go$| | ||
^pkg/scalers/prometheus\.go$| | ||
^pkg/scalers/rabbitmq_scaler\.go$| | ||
^pkg/scalers/scaler\.go$| | ||
^version/version\.go$ | ||
) |
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.
If this gets merged, please don't forget to open issues for these.
@tomkerkhove thanks for the review! Regarding:
I just copy pasted pre-commit config from my other go repo so not a lot of work 😉 |
Oh, DCO doesn't accept PR added from GitHub review? :< |
5990e57
to
8010885
Compare
@zroubalik I've rebased this change onto v2 👍 |
25595ec
to
25f8027
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.
LGTM but I'll leave it up to @zroubalik to give the sign-off
@@ -4,6 +4,19 @@ Thanks for helping make KEDA better 😍. | |||
|
|||
There are many areas we can use contributions - ranging from code, documentation, feature proposals, issue triage, samples, and content creation. | |||
|
|||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> |
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.
That's great, but how does this work? Should add some docs on this :)
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 say that's enough to google doctoc
to find out more information. Also not sure where to put such docs
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.
Yeah. And wit pre-commits you basically do not have to worry about it - just install pre-commit and you forget about it..
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.
That's a bit of an odd argument as that would mean we don't have to doc the pre-commit thingy but it's ok.
Yeah. And wit pre-commits you basically do not have to worry about it - just install pre-commit and you forget about it..
We tend to make it easy for folks to contribute so you cannot assume everybody has pre-commit
installed, that's why we have a CI.
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.
We tend to make it easy for folks to contribute so you cannot assume everybody has pre-commit installed, that's why we have a CI.
As we have totally lightweight pre-commit setup we should probably encourage people to use them. It's good to teach people how to automate stuff and focus on the most important things like the code itself and documentation. However, that's only my personal opinion.
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.
That's definitely the case and I agree, but we can't expect everyone to use it.
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.
We also have it integrated on the CI, so if someone does not use pre-commit locally, they will get a readable diff on the CI that will show what changes should be made.
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.
Yes, that was my point on #1025 (comment) indeed
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.
Yeah. Pre-commits are working like a charm on Apache Airflow for > 1.5 year now and we have plenty of pre-commits running/ You can see it working here for example: https://github.com/apache/airflow/runs/1026196376?check_suite_focus=true#step:7:108 - it integrates very well with CI. you simply run pre-commit run --all-files
in the CI and you get the very same checks executed in CI as locally.
And as @mik-laj mentioned - with --show-diff-on-failure
flag it will even show you what modification would be made if you run pre-commit locally. In case it fails in CI it will even tell you what to do 'pip install pre-commit' and then pre-commit run <id of pre-commit that failed>
. But you still can fix it manually if you prefer (though a lot of pre-commit checks can fix things for you automatically (like end-of-file checking, sorting import in python etc.) and then the only thing you have to do you have to commit modified files. And you have literally hundreds of hooks that you can start using.
So you do not have to even install it as pre-commit (though it is super-easy pre-commit install
will do the job after installit it with pip. The nice thing about it is that you simply forget about it once you install - it will automatically run all the precommits that were added by others since and you will actually fix the problems even before others see them.
I do not see any drawbacks of using pre-commit to be honest if your project's goal is to keep some consistency, it's the perfect tool for the job IMHO.
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.
Don't get me wrong, I'm not saying it's a bad thing or so; I was just saying that it's fine and the CI will cover it but we shouldn't force people to use it.
I'm not saying you are, it was just a general remark :) This escalated quickly.
Signed-off-by: Tomek Urbaszek <[email protected]>
Signed-off-by: Tomek Urbaszek <[email protected]>
Signed-off-by: Tomek Urbaszek <[email protected]>
Signed-off-by: Tomek Urbaszek <[email protected]>
Signed-off-by: Tomek Urbaszek <[email protected]>
cef337d
to
dfbd618
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.
change looks good to me. I'm assuming the CI pre-commit will fail if something needs to be fixed, right? I haven't used pre-commit before but looks neat.
Signed-off-by: Tomek Urbaszek <[email protected]>
That's right! For example:
Most of pre-commit hooks we use apply the changes automatically during |
@tomkerkhove @zroubalik are we good to go? |
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.
LGTM, just one more change.
@@ -4,6 +4,19 @@ Thanks for helping make KEDA better 😍. | |||
|
|||
There are many areas we can use contributions - ranging from code, documentation, feature proposals, issue triage, samples, and content creation. | |||
|
|||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> |
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.
Don't get me wrong, I'm not saying it's a bad thing or so; I was just saying that it's fine and the CI will cover it but we shouldn't force people to use it.
I'm not saying you are, it was just a general remark :) This escalated quickly.
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.
LGTM, just minor remark on "enforcing" pre-commit. Thanks for the contribution
Signed-off-by: Tomek Urbaszek <[email protected]>
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.
LGTM
Tomek, great work! Thanks a lot! 🎉 |
Thanks all! 🚀 |
❤️ |
<3 |
Signed-off-by: Neelanjan Manna <[email protected]> Signed-off-by: Neelanjan Manna <[email protected]>
Code quality is important, especially in an open source project where the code will be maintained for a long time and by multiple people. So I would like to suggest using https://pre-commit.com framework to automate a lot of stuff and assure that our code is nice.
It plays nicely with Github action and allows a plethora of checks (building TOC, license insert, liniting etc) and gives possibility to build custom ones. For example here's configuration from Apache Airflow:
https://github.com/apache/airflow/blob/master/.pre-commit-config.yaml
Checklist