Skip to content

Commit d1bcbc2

Browse files
authored
chore(ci): optimize build performance with config cache, R8 full mode, and lint restructuring (#990)
* fix(onramp): stub ResolvedUserFlags to fix ClassCastException in tests MockK relaxed mocks cannot properly handle the generic computed property ResolvedFlag<Boolean>.effectiveValue, returning a mock Object instead of a Boolean. Explicitly stub requireCoinbaseEmailVerification with a real ResolvedFlag to avoid the cast failure. Signed-off-by: Brandon McAnsh <git@bmcreations.dev> * chore(ci): optimize build performance with config cache, R8 full mode, and lint restructuring - Persist Gradle configuration cache between CI runs (~4 min saved) - Enable R8 full mode and bump JVM heap to 6g - Move lint from release builds to PR CI (lintDebug) - Skip R8/shrink on PR CI via skipExpensiveReleaseTasks property - Remove dead Voyager keep rule from proguard-rules.pro Signed-off-by: Brandon McAnsh <git@bmcreations.dev> --------- Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent 1850058 commit d1bcbc2

7 files changed

Lines changed: 36 additions & 10 deletions

File tree

.github/workflows/build-fcash2-upload-android.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ jobs:
5252
- name: Gradle build cache
5353
uses: actions/cache@v4
5454
with:
55-
path: ~/.gradle/caches/build-cache-1
55+
path: |
56+
~/.gradle/caches/build-cache-1
57+
.gradle/configuration-cache
5658
key: gradle-build-cache-${{ hashFiles('**/*.gradle.kts', 'gradle.properties') }}
5759
restore-keys: |
5860
gradle-build-cache-
@@ -105,7 +107,9 @@ jobs:
105107
- name: Gradle build cache
106108
uses: actions/cache@v4
107109
with:
108-
path: ~/.gradle/caches/build-cache-1
110+
path: |
111+
~/.gradle/caches/build-cache-1
112+
.gradle/configuration-cache
109113
key: gradle-build-cache-${{ hashFiles('**/*.gradle.kts', 'gradle.properties') }}
110114
restore-keys: |
111115
gradle-build-cache-

.github/workflows/ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ jobs:
2929
- name: Gradle build cache
3030
uses: actions/cache@v4
3131
with:
32-
path: ~/.gradle/caches/build-cache-1
32+
path: |
33+
~/.gradle/caches/build-cache-1
34+
.gradle/configuration-cache
3335
key: gradle-build-cache-${{ hashFiles('**/*.gradle.kts', 'gradle.properties') }}
3436
restore-keys: |
3537
gradle-build-cache-

apps/flipcash/app/build.gradle.kts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ fun gitVersionCode(): Int {
2727
val contributorsSigningConfig = ContributorsSignatory(rootDir)
2828
val appNamespace = "${Gradle.flipcashNamespace}.app.android"
2929

30+
val skipExpensiveReleaseTasks = providers.gradleProperty("skipExpensiveReleaseTasks")
31+
.orElse("false").get().toBooleanStrict()
32+
3033
android {
3134
// static namespace
3235
namespace = appNamespace
@@ -65,8 +68,8 @@ android {
6568
buildTypes {
6669
getByName("release") {
6770
resValue("string", "applicationId", appNamespace)
68-
isMinifyEnabled = true
69-
isShrinkResources = true
71+
isMinifyEnabled = !skipExpensiveReleaseTasks
72+
isShrinkResources = !skipExpensiveReleaseTasks
7073
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
7174
}
7275
getByName("debug") {
@@ -92,6 +95,10 @@ android {
9295
}
9396
}
9497

98+
lint {
99+
checkReleaseBuilds = false
100+
}
101+
95102
compileOptions {
96103
sourceCompatibility(libs.versions.android.java.get())
97104
targetCompatibility(libs.versions.android.java.get())

apps/flipcash/app/proguard-rules.pro

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
# Preserve source file names and line numbers for stack traces (call site tracking, Bugsnag)
77
-keepattributes SourceFile,LineNumberTable
88

9-
# Keep screen names
10-
-keepnames class * implements cafe.adriel.voyager.core.screen.Screen
11-
129
# Keep AppRoute class names for analytics screen tracking
1310
-keepnames class com.flipcash.app.core.AppRoute
1411
-keepnames class com.flipcash.app.core.AppRoute$**

apps/flipcash/shared/onramp/coinbase/src/test/kotlin/com/flipcash/app/onramp/CoinbaseOnRampControllerTest.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ package com.flipcash.app.onramp
33
import com.coinbase.onramp.api.CoinbaseApi
44
import com.coinbase.onramp.data.OnRampApiConfig
55
import com.flipcash.app.featureflags.FeatureFlagController
6+
import com.flipcash.app.userflags.FieldOverride
7+
import com.flipcash.app.userflags.ResolvedFlag
8+
import com.flipcash.app.userflags.ResolvedUserFlags
69
import com.flipcash.app.userflags.UserFlagsCoordinator
710
import com.flipcash.services.models.UserProfile
811
import com.flipcash.services.user.UserManager
@@ -22,6 +25,7 @@ import io.mockk.mockkStatic
2225
import io.mockk.slot
2326
import io.mockk.unmockkStatic
2427
import kotlinx.coroutines.ExperimentalCoroutinesApi
28+
import kotlinx.coroutines.flow.MutableStateFlow
2529
import kotlinx.coroutines.test.runTest
2630
import kotlinx.serialization.json.JsonArray
2731
import kotlinx.serialization.json.JsonObject
@@ -78,6 +82,14 @@ class CoinbaseOnRampControllerTest {
7882

7983
every { webViewChannelDetector.detect() } returns null
8084

85+
val resolvedFlags = mockk<ResolvedUserFlags>(relaxed = true) {
86+
every { requireCoinbaseEmailVerification } returns ResolvedFlag(
87+
serverValue = true,
88+
override = FieldOverride.None,
89+
)
90+
}
91+
every { userFlags.resolvedFlags } returns MutableStateFlow(resolvedFlags)
92+
8193
controller = CoinbaseOnRampController(
8294
jwtProvider = jwtProvider,
8395
onRampApiEndpoint = onRampApiEndpoint,

fastlane/Fastfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ platform :android do
1919
desc "Runs all the tests for Flipcash"
2020
lane :flipcash_tests do
2121
gradle(
22-
task: "generateEmojiList flipcashTestDebug",
22+
task: "generateEmojiList flipcashTestDebug lintDebug",
2323
properties: {
2424
"skipCoverage" => ENV.fetch("SKIP_COVERAGE", "false")
2525
}

gradle.properties

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# http://www.gradle.org/docs/current/userguide/build_environment.html
77
# Specifies the JVM arguments used for the daemon process.
88
# The setting is particularly useful for tweaking memory settings.
9-
org.gradle.jvmargs=-Xmx4g -XX:+HeapDumpOnOutOfMemoryError -XX:+UseParallelGC -XX:MaxMetaspaceSize=1024m -Dkotlin.daemon.jvm.options=-XX:MaxMetaspaceSize=1g -Dlint.nullness.ignore-deprecated=true
9+
org.gradle.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError -XX:+UseParallelGC -XX:MaxMetaspaceSize=1024m -Dkotlin.daemon.jvm.options=-XX:MaxMetaspaceSize=1g -Dlint.nullness.ignore-deprecated=true
1010
# When configured, Gradle will run in incubating parallel mode.
1111
# This option should only be used with decoupled projects. More details, visit
1212
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
@@ -41,3 +41,7 @@ android.experimental.enableTestFixturesKotlinSupport=true
4141
android.suppressUnsupportedOptionWarnings=android.suppressUnsupportedOptionWarnings,android.experimental.enableTestFixturesKotlinSupport
4242
android.uniquePackageNames=false
4343
android.dependency.useConstraints=false
44+
# R8 full mode: enables more aggressive optimizations (class merging,
45+
# enum unboxing, constant propagation). Produces smaller, faster output
46+
# and can also reduce R8's own processing time.
47+
android.enableR8.fullMode=true

0 commit comments

Comments
 (0)