-
Notifications
You must be signed in to change notification settings - Fork 533
ci: check android code formatting #696
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
Conversation
IMO this is a trivial change, but happy to open an issue if needed. I noticed this because I couldn't run the formatting on files I was changing in #695 without muddying the diff with unrelated changes, which is my motivation for proposing to enforce it in CI. |
.github/workflows/android.yml
Outdated
- name: Run lint | ||
run: make lint-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 should probably make this its own workflow (separate yml file) that can run in parallel with building the APKs & running tests. Then it'll fail much faster for developers rather than at the end.
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've reworked it to be a separate job in the same workflow, which should:
- run in parallel
- give a separate commit status
Android CI / lint
- whilst keeping the duplicated setup close together
Unsure if there's a better/worthwhile way to DRY the setup steps
Makefile
Outdated
.PHONY: lint-ci | ||
lint-ci: gradle-dependencies ## Check the Android code is formatted | ||
(cd android && ./gradlew ktfmtCheck) |
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.
When this fails (especially in CI), it's nice if it can say in the error output what the developer can do to fix it ("run 'make lint' to reformat the source code")
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.
Added a message in e03a973
Included color code escapes, as I thought the text was a bit subtle / easy to miss otherwise. In two minds about that though as I suspect in CI the color codes will be stripped from the output anyway.

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.
Signed-off-by: Michael Nahkies <[email protected]>
e03a973
to
109fb34
Compare
FYI @bradfitz looks like your squash commit might've dropped the gh actions workflow + hint error message in makefile from the change set |
@mnahkies, you have multiple overlapping PRs open. I repurposed this one to be just the base part without the GH actions bits. Then the second one can wire it up to PR. I also renamed the Makefile rules. (and run the fmt commands might myself from the original source to verify it matched) |
the
com.ncorti.ktfmt.gradle
plugin from https://github.com/cortinico/ktfmt-gradle?tab=readme-ov-file#task is already setup, but its not being invoked.this change adds targets for it to the
Makefile
and adds a CI step that checks the formatting is correct.See #697 for the current pending formatting changes.