-
-
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
feat: run rustfmt after generating schema.rs file #4407
feat: run rustfmt after generating schema.rs file #4407
Conversation
Thanks for opening this PR. It seems to work, but now we need to update the expected output for some tests. You can run the tests locally by using |
Thanks for the update, but the CI still indicates that there is something wrong with the snapshots. It would be great if you could have a look at that, otherwise I will try to address that after the holidays. |
I've now realized my implementation has a problem.
So what I'm thinking is adding a new function We can also move this to output_schema but I like the option of keeping the current output_schema function for now. Let me know what you think |
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 think, it would be better to run formatter only when explicitly requested by flag. Or at least provide a flag which disables autoformatting.
Sounds like a good idea. Can I assume autoformating is something that we want enabled by default? |
I wouldn't want to introduce an option for formatting. As for the print-schema "issue": The correct solution is to run formatting only there by using |
Here we go. Finally got it working |
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.
Thanks, looks good now 🎉
So the CI tests failed before with these errors:
So it made me realize that the Pushed a fix (9c2b8f1 and 5edd2a5) where I check for the rustfmt exit code and return an error in case it's not succesful. Should've done this earlier but didn't realize it was a possibility |
Perfect. So it seems to be working (as in, it does what I want it to do) but the tests will fail because it tries to check snapshots created with rustfmt vs results created in an environment where rustfmt doesn't exist I see two options:
I would be happy to work on this until we can make it work. Let me know what you think |
Thanks for this update. It's reasonable to just install rustfmt in the CI. The right point to do this is there: https://github.com/diesel-rs/diesel/blob/master/.github/workflows/ci.yml#L175 That should be as simple as adding the rustfmt component as documented here: https://github.com/dtolnay/rust-toolchain |
Thank you for your help, let's watch those tests turn green :) |
Closes #4405 by launching a rustfmt process to format the generated
schema.rs
fileIf rustfmt doesn't exist or it throws an error it will simply print a message to the user