-
Notifications
You must be signed in to change notification settings - Fork 184
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
chore(format): added pre-commit hooks and formatted files #294
Conversation
@aeswibon is attempting to deploy a commit to the Hatchet Team on Vercel. A member of the Team first needs to authorize it. |
@abelanger5 Can you check the PR? |
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'm going to request some other reviews on this as it's quite a large PR, but generally I think we want to ignore auto-generated files (like migration.sql
and auto-generated REST clients). Will do a deeper dive later today.
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 good but indeed as @abelanger5 said the prisma .sql migration files under prisma/migrations
can't be changed now as it will break the migrations. We can only change this with a major release where migrations would need to be reset. Ignoring auto-generated clients makes sense as well. If you need any guidance on what else needs to be ignored I'm happy to help and/or make a list.
So like, I should just ignore all the files in prisma/migrations folder. Anything else? |
Yes, pretty much. Also, the linter needs to run as the last item of the each task where something is generated. I think running the linter on generated files is fine from my perspective as that ensures consistent formatting throughout the project. Once you have that the generate CI job should succeed (and the lint seems to be a leftover, so not related to this PR). |
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! Please merge with incoming changes and then just run the linter again and it should be fine. Also check that the checks all pass (except for golangci-lint that is expected to fail in this case). I'll check with @abelanger5 if there is anything else before we merge.
Sure, I will resolve all the conflicts. |
@aeswibon can you please look into the CI failures? looks like the generate task fails |
Sure, I will check that. And will also resolve the merge conflicts |
@steebchen I have cleared the merge conflict and fixed the pipeline |
@steebchen I'd like to give this another look before merging since it's a fairly large commit. Feel free to review and I'll look in the am. |
@aeswibon Can you please run the generate script again and push. You can see in the |
Sure |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@aeswibon generate step is still failing unfortunately, also please merge from main again |
@steebchen Generate step would fail as in the pipeline, python files are also generated, due to which pre-commit would fail. |
@aeswibon I don't follow, if you run generate and run the lint, and then push the changes, the CI step should result in the same files and then succeed? Can you elaborate? And the merge is also required otherwise I can't merge due to the conflicts |
Signed-off-by: Abhiuday <[email protected]>
Signed-off-by: Abhiuday <[email protected]>
@steebchen I have resolved the conflict. Also, when I saw the logs, the files were re-generated using openapi-generator
I have previously tried to run the generator for python files and then tried lining but the pipeline failed. |
Signed-off-by: Abhiuday <[email protected]>
Ah I understand the problem now. I'm new to that pre-commit CLI so I'm not sure the best way to fix it. What command are you running locally to run the format? I think we can just run that instead of what we run right now in CI, so that it just formats the files instead of failing. We have a CI check for the diff anyway, so this ensures that everything is consistent. |
For the command, I have added it in the |
Yeah but it fails in the CI. It doesn't seem to fail on your machine. What am I missing? |
It fails in the CI because the code is rewritten. Pre-commit will fail initially because the generation step would generate unformatted code. pre-commit will check the files and if the step fails then it formats the code. |
I understand why it fails, but does the command fail locally as well? I just want to figure out how to make it not fail for CI, as it is expected that it needs to re-format the code, because all generated code is newly generated in CI. |
Locally, pre-commit would fail initially, then it would format the file after which it would pass. |
I see, got it. We would need to think of a way to make it work in CI... running it twice while ignoring the first result is an option although it's not optimal |
@aeswibon I removed ggshield as it seems to require an API key, and I changed the command to run twice basically so it doesn't fail. If there is still a diff from the source code after this, the So unless anyone has any other concerns I'll merge this as is |
THanks @aeswibon for the contribution! I will most likely split the python client into its own repository, but this helped a lot as we wanted to set up a linter for python anyway but didn't get to it. |
Description
pre-commit
hooks to format filesType of change
What's Changed