From d976b2228e8e0a6c6ed6a64a2e657c69dd205460 Mon Sep 17 00:00:00 2001 From: demn Date: Tue, 13 May 2025 17:12:29 +0300 Subject: [PATCH 1/7] feat(app): implement build flavors for mock and prod data providers, with app id suffixes --- app/build.gradle.kts | 29 +++++++++++++++++-- app/google-services.json | 21 +++++++++++++- .../main/java/me/floow/app/MainActivity.kt | 16 +++++----- app/src/mock/res/values/strings.xml | 3 ++ feature/profile/build.gradle.kts | 2 +- gradle.properties | 2 +- 6 files changed, 59 insertions(+), 14 deletions(-) create mode 100644 app/src/mock/res/values/strings.xml diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 489b59d..d175471 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -17,11 +17,10 @@ android { defaultConfig { applicationId = "me.floow.app" minSdk = 28 - targetSdk = 34 + targetSdk = 35 versionCode = 1 versionName = "1.0" - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { useSupportLibrary = true @@ -39,6 +38,30 @@ android { ) } + flavorDimensions += "data" + + productFlavors { + create("production") { + dimension = "data" + + buildConfigField( + name = "USE_MOCK_DATA", + value = "false", + type = "boolean" + ) + } + + create("mock") { + dimension = "data" + applicationIdSuffix = ".mock" + buildConfigField( + name = "USE_MOCK_DATA", + value = "true", + type = "boolean" + ) + } + } + buildTypes { release { isMinifyEnabled = true @@ -106,4 +129,4 @@ dependencies { androidTestImplementation(libs.ui.test.junit4) debugImplementation(libs.ui.tooling) debugImplementation(libs.ui.test.manifest) -} \ No newline at end of file +} diff --git a/app/google-services.json b/app/google-services.json index 03b6b11..fcfdc7f 100644 --- a/app/google-services.json +++ b/app/google-services.json @@ -23,7 +23,26 @@ "other_platform_oauth_client": [] } } + }, + { + "client_info": { + "mobilesdk_app_id": "1:291755427997:android:a5bdc8e67ad57b441a2c74", + "android_client_info": { + "package_name": "me.floow.app.mock" + } + }, + "oauth_client": [], + "api_key": [ + { + "current_key": "AIzaSyDtGUu5IMFTc5-PW5Ta2LkPmlCrolVUOdo" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [] + } + } } ], "configuration_version": "1" -} \ No newline at end of file +} diff --git a/app/src/main/java/me/floow/app/MainActivity.kt b/app/src/main/java/me/floow/app/MainActivity.kt index c05c322..7d20b2b 100644 --- a/app/src/main/java/me/floow/app/MainActivity.kt +++ b/app/src/main/java/me/floow/app/MainActivity.kt @@ -14,6 +14,7 @@ import me.floow.chatssearch.di.usersearchModule import kotlinx.coroutines.CoroutineName import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch +import me.floow.app.BuildConfig.* import me.floow.app.di.apiModule import me.floow.app.di.appModule import me.floow.app.di.authModule @@ -49,15 +50,14 @@ class MainActivity : ComponentActivity() { startKoin { androidContext(this@MainActivity) - val mockDependencies = false // TODO: make build flavors with and without mocks - - if (!mockDependencies) { + @Suppress("KotlinConstantConditions") + if (USE_MOCK_DATA) { modules( appModule, apiModule, - authModule, + mockAuthModule, databaseModule, - dataModule, + mockDataModule, domainModule, mockModule, loginModule, @@ -69,9 +69,9 @@ class MainActivity : ComponentActivity() { modules( appModule, apiModule, - mockAuthModule, + authModule, databaseModule, - mockDataModule, + dataModule, domainModule, mockModule, loginModule, @@ -123,4 +123,4 @@ class MainActivity : ComponentActivity() { super.attachBaseContext(newBase?.createConfigurationContext(newConfiguration)) } -} \ No newline at end of file +} diff --git a/app/src/mock/res/values/strings.xml b/app/src/mock/res/values/strings.xml new file mode 100644 index 0000000..23c58cc --- /dev/null +++ b/app/src/mock/res/values/strings.xml @@ -0,0 +1,3 @@ + + Flow (Mock) + diff --git a/feature/profile/build.gradle.kts b/feature/profile/build.gradle.kts index 1fafe49..456f7c3 100644 --- a/feature/profile/build.gradle.kts +++ b/feature/profile/build.gradle.kts @@ -45,4 +45,4 @@ dependencies { androidTestImplementation(libs.androidx.test.ext.junit) androidTestImplementation(libs.espresso.core) -} \ No newline at end of file +} diff --git a/gradle.properties b/gradle.properties index 11a9b24..8ea0209 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,4 +21,4 @@ kotlin.code.style=official # resources declared in the library itself and none from the library's dependencies, # thereby reducing the size of the R class for that library android.nonTransitiveRClass=true -android.defaults.buildfeatures.buildconfig=true + From 832fd2d015bd47fb3bea95f6a8d3e53a3fcc92ad Mon Sep 17 00:00:00 2001 From: demn Date: Tue, 13 May 2025 17:15:10 +0300 Subject: [PATCH 2/7] ci: bump actions/upload-artifact to v3 --- .github/workflows/android.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 40e6b29..c9aa2de 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -26,7 +26,7 @@ jobs: - name: Build with Gradle run: ./gradlew build - name: Upload artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: android-app path: app/build/outputs/apk/debug/app-debug.apk From 041a8a874ef17da9bebd9566aaf4eca944f77cdd Mon Sep 17 00:00:00 2001 From: demn Date: Tue, 13 May 2025 17:17:02 +0300 Subject: [PATCH 3/7] ci: bump actions/upload-artifact to v4 --- .github/workflows/android.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index c9aa2de..92a8b1d 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -26,7 +26,7 @@ jobs: - name: Build with Gradle run: ./gradlew build - name: Upload artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: android-app path: app/build/outputs/apk/debug/app-debug.apk From 0414d78fb5be174564ea22a9e6572a29869d319f Mon Sep 17 00:00:00 2001 From: demn Date: Tue, 13 May 2025 17:37:15 +0300 Subject: [PATCH 4/7] fix(app): use mock GOOGLE_CLIENT_ID before prod backend auth impl --- app/build.gradle.kts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index d175471..03ed029 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -26,15 +26,15 @@ android { useSupportLibrary = true } - val secretsFile = project.rootProject.file("secrets.properties") - val secretsProperties = Properties() - secretsProperties.load(secretsFile.inputStream()) +// val secretsFile = project.rootProject.file("secrets.properties") +// val secretsProperties = Properties() +// secretsProperties.load(secretsFile.inputStream()) - val googleClientId = secretsProperties.getProperty("googleClientId") ?: "" +// val googleClientId = secretsProperties.getProperty("googleClientId") ?: "" buildConfigField( type = "String", name = "GOOGLE_CLIENT_ID", - value = googleClientId + value = "BUILD_TYPE" // mock ) } From 2ccd34a4788ba63ed97f51aff9e7f92305009b20 Mon Sep 17 00:00:00 2001 From: demn Date: Tue, 13 May 2025 17:38:02 +0300 Subject: [PATCH 5/7] git(shared): add .gitignore --- feature/shared/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 feature/shared/.gitignore diff --git a/feature/shared/.gitignore b/feature/shared/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/feature/shared/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file From 68724ac2f241b5e8218945ca0c0f7cf573b0c810 Mon Sep 17 00:00:00 2001 From: demn Date: Tue, 13 May 2025 17:52:54 +0300 Subject: [PATCH 6/7] ci: add all possible upload artifacts --- .github/workflows/android.yml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 92a8b1d..9aadb7a 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -25,8 +25,23 @@ jobs: run: chmod +x gradlew - name: Build with Gradle run: ./gradlew build - - name: Upload artifact + - name: Upload artifact (mock debug) uses: actions/upload-artifact@v4 with: name: android-app - path: app/build/outputs/apk/debug/app-debug.apk + path: app/build/outputs/apk/mock/debug/app-mock-debug.apk + - name: Upload artifact (mock release) + uses: actions/upload-artifact@v4 + with: + name: android-app + path: app/build/outputs/apk/mock/release/app-mock-release.apk + - name: Upload artifact (prod debug) + uses: actions/upload-artifact@v4 + with: + name: android-app + path: app/build/outputs/apk/production/release/app-production-release.apk + - name: Upload artifact (prod release) + uses: actions/upload-artifact@v4 + with: + name: android-app + path: app/build/outputs/apk/production/release/app-production-release.apk From 769e5dffe3137228aaaca9cd8922d31aee791976 Mon Sep 17 00:00:00 2001 From: demn Date: Tue, 13 May 2025 18:04:19 +0300 Subject: [PATCH 7/7] ci: change artifacts uploading way --- .github/workflows/android.yml | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 9aadb7a..4ad36b2 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -25,23 +25,8 @@ jobs: run: chmod +x gradlew - name: Build with Gradle run: ./gradlew build - - name: Upload artifact (mock debug) + - name: Upload artifacts uses: actions/upload-artifact@v4 with: name: android-app - path: app/build/outputs/apk/mock/debug/app-mock-debug.apk - - name: Upload artifact (mock release) - uses: actions/upload-artifact@v4 - with: - name: android-app - path: app/build/outputs/apk/mock/release/app-mock-release.apk - - name: Upload artifact (prod debug) - uses: actions/upload-artifact@v4 - with: - name: android-app - path: app/build/outputs/apk/production/release/app-production-release.apk - - name: Upload artifact (prod release) - uses: actions/upload-artifact@v4 - with: - name: android-app - path: app/build/outputs/apk/production/release/app-production-release.apk + path: app/build/outputs/apk/*/*/*.apk