From 23d39c0e934cf5d1b38e60169dea2a531e7c1db6 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sun, 6 Jul 2025 01:45:07 +0700 Subject: [PATCH 1/8] build: Spotless check --- .github/workflows/spotless.yml | 22 ++++++++++++++++++++++ build.gradle.kts | 8 ++++++++ gradle/libs.versions.toml | 2 ++ 3 files changed, 32 insertions(+) create mode 100644 .github/workflows/spotless.yml diff --git a/.github/workflows/spotless.yml b/.github/workflows/spotless.yml new file mode 100644 index 0000000000..bd55bd23ce --- /dev/null +++ b/.github/workflows/spotless.yml @@ -0,0 +1,22 @@ +name: Spotless Check + +on: + pull_request: + branches: + - dev + +jobs: + release: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Cache Gradle + uses: burrunan/gradle-cache-action@v3 + + - name: Check + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: ./gradlew spotlessCheck --no-daemon diff --git a/build.gradle.kts b/build.gradle.kts index c543b2fa89..e9e415aa6b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,4 +7,12 @@ plugins { alias(libs.plugins.kotlin.parcelize) apply false alias(libs.plugins.about.libraries) apply false alias(libs.plugins.compose.compiler) apply false + alias(libs.plugins.spotless) +} + +spotless { + kotlin { + target("app/src/*/java/**/*.kt", "api/src/*/kotlin/**/*.kt") + ktfmt().googleStyle() + } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 245dda8978..02442e7ff3 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -37,6 +37,7 @@ compose-icons = "1.2.4" kotlin-process = "1.5.1" hidden-api-stub = "4.3.3" binary-compatibility-validator = "0.17.0" +spotless-gradle-plugin = "7.0.4" [libraries] # AndroidX Core @@ -144,3 +145,4 @@ compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = " devtools = { id = "com.google.devtools.ksp", version.ref = "dev-tools-gradle-plugin" } about-libraries = { id = "com.mikepenz.aboutlibraries.plugin", version.ref = "about-libraries-gradle-plugin" } binary-compatibility-validator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binary-compatibility-validator" } +spotless = { id = "com.diffplug.spotless", version.ref = "spotless-gradle-plugin" } From a150fdb147e11443c00c803c9b2c90872f3918cf Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sun, 6 Jul 2025 01:46:08 +0700 Subject: [PATCH 2/8] ci: Merge Spotless CI with Build PR --- .github/workflows/build_pull_request.yml | 5 +++++ .github/workflows/spotless.yml | 22 ---------------------- 2 files changed, 5 insertions(+), 22 deletions(-) delete mode 100644 .github/workflows/spotless.yml diff --git a/.github/workflows/build_pull_request.yml b/.github/workflows/build_pull_request.yml index c28a17f1bc..4e2ec3f8b9 100644 --- a/.github/workflows/build_pull_request.yml +++ b/.github/workflows/build_pull_request.yml @@ -19,6 +19,11 @@ jobs: - name: Cache Gradle uses: burrunan/gradle-cache-action@v1 + - name: Spotless Check + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: ./gradlew spotlessCheck --no-daemon + - name: Build env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/spotless.yml b/.github/workflows/spotless.yml deleted file mode 100644 index bd55bd23ce..0000000000 --- a/.github/workflows/spotless.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Spotless Check - -on: - pull_request: - branches: - - dev - -jobs: - release: - name: Build - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Cache Gradle - uses: burrunan/gradle-cache-action@v3 - - - name: Check - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: ./gradlew spotlessCheck --no-daemon From bfe207e682db206853cf5dead05732eb72b0d45e Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sun, 6 Jul 2025 01:52:37 +0700 Subject: [PATCH 3/8] build: Try to format when needed, not all the time (for now) --- build.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle.kts b/build.gradle.kts index e9e415aa6b..20c02be696 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,6 +11,7 @@ plugins { } spotless { + ratchetFrom("compose-dev") kotlin { target("app/src/*/java/**/*.kt", "api/src/*/kotlin/**/*.kt") ktfmt().googleStyle() From e85efceb3980a1fd3fd443208742e329e5f875a4 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sun, 6 Jul 2025 02:13:33 +0700 Subject: [PATCH 4/8] build: Use ktlint (Android Studio configuration) --- .editorconfig | 23 +++++++++++++++++++++++ build.gradle.kts | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..32786813ca --- /dev/null +++ b/.editorconfig @@ -0,0 +1,23 @@ +[*.{kt,kts}] +end_of_line = lf +ij_kotlin_allow_trailing_comma = false +ij_kotlin_allow_trailing_comma_on_call_site = false +ij_kotlin_imports_layout = * +ij_kotlin_indent_before_arrow_on_new_line = false +ij_kotlin_line_break_after_multiline_when_entry = true +ij_kotlin_packages_to_use_import_on_demand = java.util.*,kotlinx.android.synthetic.** +indent_size = 4 +indent_style = space +insert_final_newline = true +ktlint_annotation_handle_annotations_with_parameters_same_as_annotations_without_parameters = [unset] + ktlint_argument_list_wrapping_ignore_when_parameter_count_greater_or_equal_than = 8 + ktlint_chain_method_rule_force_multiline_when_chain_operator_count_greater_or_equal_than = 4 + ktlint_class_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = unset + ktlint_code_style = android_studio + ktlint_enum_entry_name_casing = upper_or_camel_cases + ktlint_function_naming_ignore_when_annotated_with = [unset] + ktlint_function_signature_body_expression_wrapping = default + ktlint_function_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = unset + ktlint_ignore_back_ticked_identifier = false + ktlint_property_naming_constant_naming = screaming_snake_case + max_line_length = 100 \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 20c02be696..ca4fff62e1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,6 +14,6 @@ spotless { ratchetFrom("compose-dev") kotlin { target("app/src/*/java/**/*.kt", "api/src/*/kotlin/**/*.kt") - ktfmt().googleStyle() + ktlint().setEditorConfigPath("$projectDir/.editorconfig") } } From b1e5f2534145edaeefac847ca84572b8e72a0bdf Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sun, 6 Jul 2025 02:19:42 +0700 Subject: [PATCH 5/8] build: Remove ratchet!! (sigh) --- build.gradle.kts | 1 - 1 file changed, 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index ca4fff62e1..14a8a6ee2a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,7 +11,6 @@ plugins { } spotless { - ratchetFrom("compose-dev") kotlin { target("app/src/*/java/**/*.kt", "api/src/*/kotlin/**/*.kt") ktlint().setEditorConfigPath("$projectDir/.editorconfig") From 0aad5869336f23ca38d7c8c7819d1acb08d7b5d3 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Tue, 15 Jul 2025 23:08:12 +0700 Subject: [PATCH 6/8] fix: cursed space --- .editorconfig | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.editorconfig b/.editorconfig index 32786813ca..205359ab40 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,14 +10,14 @@ indent_size = 4 indent_style = space insert_final_newline = true ktlint_annotation_handle_annotations_with_parameters_same_as_annotations_without_parameters = [unset] - ktlint_argument_list_wrapping_ignore_when_parameter_count_greater_or_equal_than = 8 - ktlint_chain_method_rule_force_multiline_when_chain_operator_count_greater_or_equal_than = 4 - ktlint_class_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = unset - ktlint_code_style = android_studio - ktlint_enum_entry_name_casing = upper_or_camel_cases - ktlint_function_naming_ignore_when_annotated_with = [unset] - ktlint_function_signature_body_expression_wrapping = default - ktlint_function_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = unset - ktlint_ignore_back_ticked_identifier = false - ktlint_property_naming_constant_naming = screaming_snake_case - max_line_length = 100 \ No newline at end of file +ktlint_argument_list_wrapping_ignore_when_parameter_count_greater_or_equal_than = 8 +ktlint_chain_method_rule_force_multiline_when_chain_operator_count_greater_or_equal_than = 4 +ktlint_class_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = unset +ktlint_code_style = android_studio +ktlint_enum_entry_name_casing = upper_or_camel_cases +ktlint_function_naming_ignore_when_annotated_with = [unset] +ktlint_function_signature_body_expression_wrapping = default +ktlint_function_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = unset +ktlint_ignore_back_ticked_identifier = false +ktlint_property_naming_constant_naming = screaming_snake_case +max_line_length = 100 \ No newline at end of file From c26adf5dca309ab3510cb600fd47c42f295424f9 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Tue, 15 Jul 2025 23:10:24 +0700 Subject: [PATCH 7/8] chore: Ratcheteer! This reverts commit b1e5f2534145edaeefac847ca84572b8e72a0bdf. --- build.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle.kts b/build.gradle.kts index 14a8a6ee2a..ca4fff62e1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,6 +11,7 @@ plugins { } spotless { + ratchetFrom("compose-dev") kotlin { target("app/src/*/java/**/*.kt", "api/src/*/kotlin/**/*.kt") ktlint().setEditorConfigPath("$projectDir/.editorconfig") From e4d896f7f05d7542b07d777120f9e96589600754 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Wed, 3 Sep 2025 17:16:25 +0700 Subject: [PATCH 8/8] build: Remove style ratchet from build script again again --- build.gradle.kts | 1 - 1 file changed, 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index ca4fff62e1..14a8a6ee2a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,7 +11,6 @@ plugins { } spotless { - ratchetFrom("compose-dev") kotlin { target("app/src/*/java/**/*.kt", "api/src/*/kotlin/**/*.kt") ktlint().setEditorConfigPath("$projectDir/.editorconfig")