Skip to content
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 ci for coding style #2

Merged
merged 16 commits into from
Jun 13, 2021
Merged

Add ci for coding style #2

merged 16 commits into from
Jun 13, 2021

Conversation

cbl
Copy link
Owner

@cbl cbl commented Jun 12, 2021

This pr adds a github action for automating coding style fixes using google-java-format. The goal is to keep future pull requests clean and make them easier to review.

@cbl cbl requested a review from herrmanno June 12, 2021 17:30
@cbl cbl marked this pull request as draft June 12, 2021 17:41
In order to work one must crete a file `./.env` that defines
`GOOGLE_JAVA_FORMATTER_JAR` as environment variable pointing to the
location of the google-java-formatter jar file.

Example `./.env`
```
GOOGLE_JAVA_FORMATTER_JAR="/usr/local/Cellar/google-java-format/1.10.0/libexec/google-java-format.jar"
```
Copy link
Collaborator

@herrmanno herrmanno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine.

I've merge 'main' into this PR to enable it to be fast-forward mergeable to main, when dissolved.

Also, I've added a format.sh script which calls google-java-formatter locally for when one would like for format upfront.

@herrmanno
Copy link
Collaborator

Just checked the result of the formatter GitHub action:
It seems the action does not yet work w/ Java 16 (see google/google-java-format#538).

@cbl
Copy link
Owner Author

cbl commented Jun 13, 2021

@herrmanno looks good, I fixed the ci for Java 16.

@cbl cbl marked this pull request as ready for review June 13, 2021 16:15
@cbl cbl merged commit d2de907 into main Jun 13, 2021
bin/format.sh Outdated
@@ -14,6 +14,4 @@ java --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
retVal=$?
if [ $retVal -ne 0 ]; then
echo "[ERROR]: Some files needed formatting"
exit $retVal
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary for the Github Action? Otherwise, a non-zero return value may be useful when the format script is used as (pre-commit) git hook to prevent committing code that does not satisfy the format rules.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re added in #4

@cbl cbl deleted the feat/style-ci branch June 13, 2021 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants