Skip to content

[#570] Add preRelease build type to distribute release build with Chucker#627

Merged
hoangnguyen92dn merged 6 commits intodevelopfrom
feature/570-add-pre-release-build-type-to-distribute-release-build-with-chucker
Feb 24, 2026
Merged

[#570] Add preRelease build type to distribute release build with Chucker#627
hoangnguyen92dn merged 6 commits intodevelopfrom
feature/570-add-pre-release-build-type-to-distribute-release-build-with-chucker

Conversation

@hoangnguyen92dn
Copy link
Copy Markdown
Contributor

@hoangnguyen92dn hoangnguyen92dn commented Feb 9, 2026

#570

What happened 👀

  • Add preRelease build type to template-compose and sample-compose
  • Update proguard rules
  • Update Github workflow
  • Minor code clean up

Insight 📝

I updated to disable minifying and proguard rules on modules, switching to use consumer-pro rules and enable minify in :app module to avoid build failed due to the code is obfuscated before building the :app module

SCR-20260209-oeef

Proof Of Work 📹

Screen.Recording.2026-02-09.at.17.46.44.mov

Summary by CodeRabbit

  • New Features

    • Added a pre-release build variant for testing prior to production.
  • Chores

    • Deployment pipeline now publishes pre-release artifacts for staging and production.
    • Consolidated obfuscation/minification configuration to consumer-level rules and simplified module ProGuard files.
    • Adjusted diagnostic logging to be enabled for non-release builds and disabled for release builds.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 9, 2026

📝 Walkthrough

Walkthrough

Adds a new "preRelease" build type and dependency configuration across templates and samples, updates CI to build/deploy preRelease APKs, adjusts ProGuard/consumer rules, changes OkHttp logging gating to BUILD_TYPE-based checks, and applies minor Kotlin style/error-handling tweaks.

Changes

Cohort / File(s) Summary
CI/CD Pipeline
.cicdtemplate/.github/workflows/deploy_staging_and_production_to_firebase_app_distribution.yml
CI switched to build assembleStagingPreRelease / assembleProductionPreRelease and updated Firebase artifact paths to preRelease APK locations.
Build type constants & dependency extension
sample-compose/buildSrc/src/main/java/Configurations.kt, template-compose/buildSrc/src/main/java/BuildTypes.kt, sample-compose/buildSrc/src/main/java/DependencyHandlerExt.kt, template-compose/buildSrc/src/main/java/DependencyHandlerExt.kt
Added PRERELEASE/preRelease constant and preReleaseImplementation(...) DependencyHandler extension to support the new variant.
Gradle build files (app & data modules)
sample-compose/app/build.gradle.kts, sample-compose/data/build.gradle.kts, template-compose/app/build.gradle.kts, template-compose/data/build.gradle.kts
Added preRelease buildType initialized from release, introduced preReleaseImplementation dependency configuration (variant Chucker deps), and adjusted release minify/consumerProguard settings.
ProGuard / consumer rules
sample-compose/app/proguard-rules.pro, template-compose/app/proguard-rules.pro, sample-compose/data/proguard-rules.pro, template-compose/data/proguard-rules.pro, template-compose/data/consumer-rules.pro, sample-compose/data/consumer-rules.pro
Removed some model keep rules from app proguard files, simplified module proguard notes, and added/updated consumer-rules.pro with explicit keeps/dontwarns for Retrofit/OkHttp/Okio/Moshi/coroutines.
OkHttp logging gating
sample-compose/app/src/main/java/co/nimblehq/sample/compose/di/modules/OkHttpClientModule.kt, template-compose/app/src/main/java/co/nimblehq/template/compose/di/modules/OkHttpClientModule.kt
Replaced BuildConfig.DEBUG checks with BUILD_TYPE string comparison ("release") to enable logging/chucker only for non-release build types.
Kotlin style & error handling
sample-compose/data/src/main/java/.../ResponseMapping.kt, template-compose/data/src/main/java/.../ResponseMapping.kt, sample-compose/data/src/main/java/.../repositories/RepositoryImpl.kt, template-compose/data/src/main/java/.../repositories/RepositoryImpl.kt
Switched ApiException calls to named parameters, replaced caught exception variables with _ for select catches, and removed explicit constructor keyword in RepositoryImpl declarations.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant CI as CI Workflow
participant Gradle as Gradle (assemblePreRelease)
participant Art as Artifact (APK)
participant Firebase as Firebase App Distribution

CI->>Gradle: trigger assembleStagingPreRelease / assembleProductionPreRelease
Gradle->>Art: produce staging/preRelease/.apk and production/preRelease/.apk
CI->>Firebase: upload artifacts to staging/preRelease and production/preRelease paths
Firebase-->>CI: distribution success/failure

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • ryan-conway
  • kaungkhantsoe
  • luongvo
  • minhnimble
  • toby-thanathip
  • win-than-htike
  • manh-t

Poem

🐰 I hopped through builds both near and far,
A preRelease trail beneath the star,
CI packed bundles, rules trimmed neat,
Logging gated, artifacts meet,
The rabbit dances — release smells sweet! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately describes the primary objective of the changeset: introducing a preRelease build type to distribute release builds with Chucker enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/570-add-pre-release-build-type-to-distribute-release-build-with-chucker

No actionable comments were generated in the recent review. 🎉


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai bot temporarily deployed to template-compose February 9, 2026 10:58 Inactive
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
template-compose/app/src/main/java/co/nimblehq/template/compose/di/modules/OkHttpClientModule.kt (1)

26-32: ⚠️ Potential issue | 🔴 Critical

Bug: readTimeout is only applied in non-release builds.

readTimeout(READ_TIME_OUT, TimeUnit.SECONDS) is inside the if block, so release builds will fall back to OkHttp's default 10-second read timeout instead of 30 seconds. This was likely the intended timeout for all build types and should be moved outside the conditional.

🐛 Proposed fix
     ) = OkHttpClient.Builder().apply {
         if (!BuildConfig.BUILD_TYPE.equals(BUILD_TYPE_RELEASE, ignoreCase = true)) {
             addInterceptor(HttpLoggingInterceptor().apply {
                 level = HttpLoggingInterceptor.Level.BODY
             })
             addInterceptor(chuckerInterceptor)
-            readTimeout(READ_TIME_OUT, TimeUnit.SECONDS)
         }
+        readTimeout(READ_TIME_OUT, TimeUnit.SECONDS)
     }.build()
sample-compose/app/src/main/java/co/nimblehq/sample/compose/di/modules/OkHttpClientModule.kt (1)

25-32: ⚠️ Potential issue | 🟠 Major

readTimeout is only set for non-release builds.

readTimeout(READ_TIME_OUT, ...) on line 31 is inside the if block, so release builds will use OkHttp's default timeout (10 seconds). If this is intentional, consider adding a comment. If not, move it outside the conditional.

Proposed fix (if timeout should apply to all builds)
     ) = OkHttpClient.Builder().apply {
+        readTimeout(READ_TIME_OUT, TimeUnit.SECONDS)
         if (!BuildConfig.BUILD_TYPE.equals(BUILD_TYPE_RELEASE, ignoreCase = true)) {
             addInterceptor(HttpLoggingInterceptor().apply {
                 level = HttpLoggingInterceptor.Level.BODY
             })
             addInterceptor(chuckerInterceptor)
-            readTimeout(READ_TIME_OUT, TimeUnit.SECONDS)
         }
     }.build()
🤖 Fix all issues with AI agents
In
@.cicdtemplate/.github/workflows/deploy_staging_and_production_to_firebase_app_distribution.yml:
- Line 68: Replace the incorrect APK filenames used in the workflow: change the
occurrences of "app-staging-debug.apk" to "app-staging-preRelease.apk" and
"app-production-debug.apk" to "app-production-preRelease.apk" so the Firebase
distribution step points to the actual build outputs (ensure you update both
references that currently use the "-debug.apk" names).

In `@template-compose/app/build.gradle.kts`:
- Line 1: Remove the unused import of JvmTarget at the top of the file; locate
the import statement referencing JvmTarget and delete it so the file no longer
imports JvmTarget (kotlinOptions already uses
JavaVersion.VERSION_17.toString()), ensuring no other code references JvmTarget
remain.

In `@template-compose/buildSrc/src/main/java/DependencyHandlerExt.kt`:
- Around line 1-5: Add the missing extension in the sample project's buildSrc:
create a DependencyHandlerExt.kt that defines fun
DependencyHandler.preReleaseImplementation(dependencyNotation: Any): Dependency?
= add("preReleaseImplementation", dependencyNotation) so the call to
preReleaseImplementation resolves; reference the existing symbol name
preReleaseImplementation and the receiver type DependencyHandler when adding the
file.

In `@template-compose/data/consumer-rules.pro`:
- Around line 34-36: The comment about Chucker/Gson proguard rules is dangling —
either add the actual keep/dontwarn rules referenced or remove the comment; to
fix, update the consumer-rules.pro by appending the recommended Chucker/Gson
rules (e.g., keep rules for Chucker UI classes and Gson TypeAdapter/reflective
access rules and appropriate -dontwarn entries as in the Chucker issue and Gson
proguard example) or delete the three-line comment block entirely so there are
no misleading references to missing proguard rules; look for the "Chucker" and
"Gson" mentions in the file to place or remove the rules.
- Line 22: Fix the typo in the comment string "NewRelic instrucmentation" by
changing "instrucmentation" to "instrumentation" to read "NewRelic
instrumentation"; update the comment where that text appears (the line
containing the NewRelic comment) so documentation/readme strings are correct.
- Around line 31-32: The ProGuard keep rules currently reference the wrong
package (com.jfc.template.core.network.*); update the two keep entries so they
point to the real model packages (e.g.
co.nimblehq.template.compose.data.network.request.** { *; } and
co.nimblehq.template.compose.data.network.response.** { *; }) so your
request/response model classes are preserved; replace the existing lines
referencing com.jfc.template.core.network.request/response with the corrected
co.nimblehq... package names in the same keep rule format.
🧹 Nitpick comments (6)
sample-compose/app/src/main/java/co/nimblehq/sample/compose/di/modules/OkHttpClientModule.kt (1)

16-16: Consider reusing the BuildTypes.RELEASE constant instead of a hardcoded string.

The "release" value is already defined as BuildType.RELEASE in Configurations.kt. While buildSrc constants aren't directly accessible at runtime, you could reference BuildTypes.RELEASE if it were made available, or at minimum add a comment noting the coupling. This avoids silent breakage if the release build type name ever changes.

template-compose/app/build.gradle.kts (1)

67-69: Consider whether isDebuggable = false is intended for preRelease.

Since preRelease is initWith(release), it inherits isDebuggable = false, isMinifyEnabled = true, and isShrinkResources = true. This means the preRelease APK distributed to testers will behave almost identically to the release build (just with Chucker added). If the intent is to give testers a debuggable build with Chucker, you may want to override isDebuggable = true. If the current behavior is intentional (near-release fidelity), a brief comment would help clarify.

template-compose/data/consumer-rules.pro (1)

8-11: Redundant keep rules — retrofit2.** already covers retrofit2.Retrofit.

Line 8 keeps all classes in retrofit2.**, making the specific keep on line 11 redundant. Similarly, line 24 (okhttp3.**) makes line 28 (okhttp3.Headers) redundant.

template-compose/data/build.gradle.kts (2)

1-1: Unused import: JvmTarget is not referenced anywhere in this file.

kotlinOptions on line 40 uses JavaVersion.VERSION_17.toString(), not JvmTarget.

-import org.jetbrains.kotlin.gradle.dsl.JvmTarget
-
 plugins {

16-22: consumerProguardFiles("consumer-rules.pro") is declared in both defaultConfig (line 16) and the release block (line 22).

The defaultConfig declaration already applies to all build types. The duplicate in the release block will cause the consumer rules to be applied twice during release builds. Remove one of them — typically keeping only the defaultConfig one is sufficient.

Proposed fix
     buildTypes {
         release {
             isMinifyEnabled = false
-            consumerProguardFiles("consumer-rules.pro")
         }
sample-compose/data/build.gradle.kts (1)

13-19: Same duplication: consumerProguardFiles in both defaultConfig and release.

Same issue as in template-compose/data/build.gradle.kts — the defaultConfig declaration (line 13) already applies to all variants.

Proposed fix
         getByName(BuildType.RELEASE) {
             isMinifyEnabled = false
-            consumerProguardFiles("consumer-rules.pro")
         }

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 9, 2026

14 Warnings
⚠️ Uh oh! Your project is under 80% coverage!
⚠️ template-compose/gradle/libs.versions.toml#L10 - A newer version of androidx.compose:compose-bom than 2025.02.00 is available: 2026.01.01
⚠️ template-compose/gradle/libs.versions.toml#L12 - A newer version of androidx.navigation:navigation-compose than 2.5.3 is available: 2.9.7
⚠️ template-compose/gradle/libs.versions.toml#L13 - A newer version of androidx.core:core-ktx than 1.15.0 is available: 1.17.0
⚠️ template-compose/gradle/libs.versions.toml#L14 - A newer version of androidx.datastore:datastore-preferences than 1.1.3 is available: 1.2.0
⚠️ template-compose/gradle/libs.versions.toml#L17 - A newer version of com.android.application than 8.8.2 is available: 9.0.0
⚠️ template-compose/gradle/libs.versions.toml#L17 - A newer version of com.android.library than 8.8.2 is available: 9.0.0
⚠️ template-compose/gradle/libs.versions.toml#L19 - A newer version of androidx.hilt:hilt-navigation-compose than 1.2.0 is available: 1.3.0
⚠️ template-compose/gradle/libs.versions.toml#L25 - A newer version of org.jetbrains.kotlinx:kotlinx-coroutines-core than 1.7.3 is available: 1.10.2
⚠️ template-compose/gradle/libs.versions.toml#L25 - A newer version of org.jetbrains.kotlinx:kotlinx-coroutines-test than 1.7.3 is available: 1.10.2
⚠️ template-compose/gradle/libs.versions.toml#L28 - A newer version of androidx.lifecycle:lifecycle-runtime-compose than 2.8.7 is available: 2.10.0
⚠️ template-compose/gradle/libs.versions.toml#L28 - A newer version of androidx.lifecycle:lifecycle-runtime-ktx than 2.8.7 is available: 2.10.0
⚠️ template-compose/gradle/libs.versions.toml#L35 - A newer version of androidx.security:security-crypto than 1.0.0 is available: 1.1.0
⚠️ template-compose/gradle/libs.versions.toml#L36 - A newer version of androidx.test:core-ktx than 1.6.1 is available: 1.7.0

Kover report for template-compose:

🧛 Template - Compose Unit Tests Code Coverage: 73.20%

Coverage of Modified Files:

File Coverage
RepositoryImpl.kt 100.00%
ResponseMapping.kt 95.00%

Modified Files Not Found In Coverage Report:

BuildTypes.kt
Configurations.kt
DependencyHandlerExt.kt
DependencyHandlerExt.kt
OkHttpClientModule.kt
OkHttpClientModule.kt
build.gradle.kts
build.gradle.kts
build.gradle.kts
build.gradle.kts
consumer-rules.pro
consumer-rules.pro
deploy_staging_and_production_to_firebase_app_distribution.yml
proguard-rules.pro
proguard-rules.pro
proguard-rules.pro
proguard-rules.pro

Codebase cunningly covered by count Shroud 🧛

Generated by 🚫 Danger

@hoangnguyen92dn hoangnguyen92dn force-pushed the feature/570-add-pre-release-build-type-to-distribute-release-build-with-chucker branch from 732cf9d to fcd7e54 Compare February 10, 2026 03:01
@coderabbitai coderabbitai bot temporarily deployed to template-compose February 10, 2026 03:06 Inactive
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@sample-compose/data/consumer-rules.pro`:
- Line 22: Typo in the comment "# Keep classes for NewRelic instrucmentation":
change "instrucmentation" to "instrumentation" so the line reads "# Keep classes
for NewRelic instrumentation"; update that exact comment string in
sample-compose/data/consumer-rules.pro.
- Line 30: Update the broken URL in the comment string
"https://medium0.com/androiddevelopers/practical-proguard-rules-examples-5640a3907dc9"
to the correct host (replace medium0.com with medium.com) so the comment reads
"https://medium.com/androiddevelopers/practical-proguard-rules-examples-5640a3907dc9".
- Around line 34-36: Add the missing ProGuard rules for Chucker and Gson by
adding the appropriate -keep and -dontwarn entries referenced in the Gson
example and Chucker issue: include -keep rules for Chucker
model/collector/okhttp classes (e.g., classes under
com.github.chuckerteam.chucker.**), and add -keep for Gson reflective model
usage (e.g., com.google.gson.** and model classes serialized/deserialized via
Gson) plus any necessary -dontwarn entries for Gson and Chucker to silence
unused-annotation/okhttp warnings; place these rules in the
sample-compose/data/consumer-rules.pro where the Chucker/Gson comment block
currently exists so the preRelease build preserves the required classes and
avoids the Chucker log-item click crash.
🧹 Nitpick comments (1)
sample-compose/data/consumer-rules.pro (1)

8-12: Redundant keep rules due to broad wildcard on line 8.

-keep class retrofit2.** { *; } already covers retrofit2.Retrofit, making line 11 redundant. Similarly, -keep class okhttp3.** { *; } on line 24 will cover okhttp3.HttpUrl (line 12) and okhttp3.Headers (line 28).

Consider removing the specific per-class rules that are already subsumed by the broad wildcard keeps, or if the intent is to document why each class is kept, convert the narrower rules to comments.

@hoangnguyen92dn hoangnguyen92dn force-pushed the feature/570-add-pre-release-build-type-to-distribute-release-build-with-chucker branch from fcd7e54 to 001c336 Compare February 10, 2026 04:13
@coderabbitai coderabbitai bot temporarily deployed to template-compose February 10, 2026 04:16 Inactive
@hoangnguyen92dn hoangnguyen92dn merged commit d3fe052 into develop Feb 24, 2026
5 of 6 checks passed
@hoangnguyen92dn hoangnguyen92dn deleted the feature/570-add-pre-release-build-type-to-distribute-release-build-with-chucker branch February 24, 2026 07:01
This was referenced Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants