Skip to content

Commit 124f157

Browse files
committed
ci: check android code formatting
Signed-off-by: Michael Nahkies <michael@nahkies.co.nz>
1 parent b42ab6b commit 124f157

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

.github/workflows/android.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,23 @@ jobs:
3535

3636
- name: Run tests
3737
run: make test
38+
39+
lint:
40+
runs-on: ubuntu-latest
41+
42+
if: "!contains(github.event.head_commit.message, '[ci skip]')"
43+
44+
steps:
45+
- name: Check out code
46+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
47+
- uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
48+
with:
49+
go-version-file: "go.mod"
50+
- name: Switch to Java 17 # Note: 17 is pre-installed on ubuntu-latest
51+
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
52+
with:
53+
distribution: "temurin"
54+
java-version: "17"
55+
56+
- name: Run fmt-check
57+
run: make fmt-check

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,8 @@ fmt: gradle-dependencies ## Format the Android code
321321

322322
.PHONY: fmt-check
323323
fmt-check: gradle-dependencies ## Check the Android code is formatted
324-
(cd android && ./gradlew ktfmtCheck)
324+
(cd android && ./gradlew ktfmtCheck) \
325+
|| (echo -e "\033[1;31mfmt-check failed. Run 'make fmt' to fix.\033[0m" && exit 1)
325326

326327
.PHONY: emulator
327328
emulator: ## Start an android emulator instance

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ shell.
5858
The ktmft plugin on the default setting should be used to autoformat all Java, Kotlin
5959
and XML files in Android Studio. Enable "Format on Save".
6060

61+
This is checked in CI using `make fmt-check`, and you can also run reformat the files locally
62+
using: `make fmt`
63+
6164
### Docker
6265

6366
If you wish to avoid installing software on your host system, a Docker based development strategy is available, you can build and start a shell with:

0 commit comments

Comments
 (0)