-
Notifications
You must be signed in to change notification settings - Fork 4k
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
THRIFT-5568: use spotless plugin and google-java-format to enforce a consistent code format #2581
Conversation
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.
Are the formatting changes already checked in, or is that expected to be a follow-on?
162bc57
to
f840a08
Compare
4f729c7
to
9531b29
Compare
had to rebase to pickup fix from #2585 |
37a5f65
to
e8e1eef
Compare
After the rebase (and reformat) this seems fixed now. @ctubbsii you can verify by |
well actually that was a lie - for only one of the file i indeed need to remove the wildcard import as to remove ambiguity of |
If the check is fast enough, could add a task to format during CI, and fail the CI check if it results in any changes to tracked files. |
Yes the format is fast enough and it is included by default into gradle build so I think it's already enabled now |
The specific command is |
What I'm suggesting is that the check should verify that the code that is checked into the repo is formatted, not the code that is the result of the build is formatted. That implies that spotlessCheck should run as an independent check, without running spotlessApply. |
Yes sorry I wasn't clear in the beginning. The spotless check is a standalone step already included into gradle build - but you can also run it on its own. It does the check on Java lib code that's checked into git. |
I understand that spotlessCheck is included into the gradle build. However, I'm suggesting that for it to be useful as a CI check, it needs to be run on its own, outside the normal gradle build. In development, we want: In the pull request CI checks, we want something different. It is not sufficient to simply run So, we need to run Imagine that there is unformatted code in a PR. We want a CI check to ensure code in PRs are formatted already, so we don't merge unformatted code. As I understand it, |
As an example, Accumulo does this to verify the format during CI. Note the |
@ctubbsii thanks for the suggestion, i added one step for checking within the GitHub workflow action |
the step in effective is https://github.com/apache/thrift/runs/6299416812?check_suite_focus=true |
thanks for the detailed explanation - i believe we arrived at an mutual understanding of what we want to achieve here. The fact is, |
I resolved the merge conflicts. Just waiting on CI before merging this. |
Fix `gradle build` by ensuring the spotless plugin doesn't run against the generated Java files in the `build/` directory
@jimexist I've verified everything is working for me locally now... but I'd like to see it pass in CI. I had to modify the spotless plugin configuration to only target the src/ directory, because |
Passing in GH Actions is sufficient for me, since I've verified |
because i shall later add |
use spotless plugin and google-java-format to enforce a consistent code format
This needs to be rebased onto:
before actually applying the formatting, in order to avoid large diff and merge conflicts
The choice of google-java-format:
[skip ci]
anywhere in the commit message to free up build resources.