Skip to content

Commit

Permalink
feat: Fixed Release Build Issue (#2712)
Browse files Browse the repository at this point in the history
* feat: Fixed Release Build

* Generated DependencyGuard Baseline

* Updated DependencyGuard Baseline

* Updated DependencyGuard Baseline
  • Loading branch information
niyajali authored Sep 26, 2024
1 parent 9d9a35c commit adb579e
Show file tree
Hide file tree
Showing 33 changed files with 237 additions and 239 deletions.
28 changes: 0 additions & 28 deletions .github/workflows/master_dev_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,34 +175,6 @@ jobs:
- name: Build APKs
run: ./gradlew :androidApp:assembleDebug

- name: Check badging
id: badging_verify
continue-on-error: true
run: ./gradlew :androidApp:checkReleaseBadging

- name: Prevent updating release badging if this is a fork
id: checkfork_badging
if: steps.badging_verify.outcome == 'failure' && github.event.pull_request.head.repo.full_name != github.repository
run: |
echo "::error::Release Badging failed, please update badging with: ./gradlew updateReleaseBadging" && exit 1
# Runs if previous job failed
- name: Generate new release badging if verification failed and it's a PR
id: generate_badging
if: steps.checkfork_badging.outcome == 'failure' && github.event_name == 'pull_request'
run: |
./gradlew updateReleaseBadging
- name: Push new release badging if available
uses: stefanzweifel/git-auto-commit-action@v5
if: steps.generate_badging.outcome == 'success'
with:
file_pattern: 'androidApp/release-badging.txt'
disable_globbing: true
commit_message: "🤖 Updates release badging"

- name: Upload APKs
uses: actions/upload-artifact@v4
with:
Expand Down
30 changes: 20 additions & 10 deletions .github/workflows/release_to_internal_or_beta.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
name: On Push
name: Internal Or Beta Release

on:
workflow_dispatch:
inputs:
beta:
description: 'true if this is a beta release'
release_type:
required: false
default: 'false'
default: 'internal'
description: Please select the release type
type: choice
options:
- internal
- beta
push:
branches:
- master
- development

env:
SUPPLY_UPLOAD_MAX_RETRIES: 5
Expand Down Expand Up @@ -72,15 +76,15 @@ jobs:
path: ./**/*.apk

- name: Create Version File
if: github.event.inputs.beta == 'true'
if: github.event.inputs.release_type == 'beta'
shell: bash
env:
VERSION_CODE: ${{ steps.rel_number.outputs.version-code }}
run: |
echo $VERSION_CODE > ./androidApp/build/outputs/version_code.txt
- name: Create Github Pre-Release
if: github.event.inputs.beta == 'true'
if: github.event.inputs.release_type == 'beta'
uses: softprops/[email protected]
with:
tag_name: ${{ steps.rel_number.outputs.version }}
Expand Down Expand Up @@ -117,6 +121,12 @@ jobs:
ruby-version: '3.2'
bundler-cache: true

- name: Install Fastlane
run: |
gem install bundler:2.2.27
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

Expand Down Expand Up @@ -148,8 +158,8 @@ jobs:
./gradlew :androidApp:bundleRelease
- name: Deploy to Play Store Internal
run: bundle exec fastlane android internal
run: bundle exec fastlane android deploy_internal

- name: Promote Internal to Beta
if: github.event.inputs.beta == 'true'
run: bundle exec fastlane android beta
if: github.event.inputs.release_type == 'beta'
run: bundle exec fastlane android promote_to_beta
10 changes: 7 additions & 3 deletions .github/workflows/release_to_production.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: Production Deploy
name: Promote Beta to Production Play Store

on:
workflow_dispatch:
release:
types: [ released ]

env:
SUPPLY_UPLOAD_MAX_RETRIES: 5
Expand All @@ -20,6 +18,12 @@ jobs:
ruby-version: '3.2'
bundler-cache: true

- name: Install Fastlane
run: |
gem install bundler:2.2.27
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- uses: ./.github/actions/inflate-secrets
name: Inflate Secrets
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/weekly_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ jobs:
github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'onPush.yml',
ref: 'master',
workflow_id: 'release_to_internal_or_beta.yml',
ref: 'development',
inputs: {
"beta": "true",
"release_type": "beta",
},
})
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
source "https://rubygems.org"

gem "fastlane"
gem "fastlane"
plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
eval_gemfile(plugins_path) if File.exist?(plugins_path)
24 changes: 13 additions & 11 deletions Gss.lock → Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ GEM
artifactory (3.0.17)
atomos (0.1.3)
aws-eventstream (1.3.0)
aws-partitions (1.971.0)
aws-sdk-core (3.203.0)
aws-partitions (1.979.0)
aws-sdk-core (3.209.1)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.9)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.89.0)
aws-sdk-core (~> 3, >= 3.203.0)
aws-sdk-kms (1.94.0)
aws-sdk-core (~> 3, >= 3.207.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.160.0)
aws-sdk-core (~> 3, >= 3.203.0)
aws-sdk-s3 (1.166.0)
aws-sdk-core (~> 3, >= 3.207.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
aws-sigv4 (1.9.1)
aws-sigv4 (1.10.0)
aws-eventstream (~> 1, >= 1.0.2)
babosa (1.0.4)
base64 (0.2.0)
Expand All @@ -39,7 +39,7 @@ GEM
dotenv (2.8.1)
emoji_regex (3.2.3)
excon (0.111.0)
faraday (1.10.3)
faraday (1.10.4)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
Expand All @@ -65,7 +65,7 @@ GEM
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
faraday_middleware (1.2.0)
faraday_middleware (1.2.1)
faraday (~> 1.0)
fastimage (2.3.1)
fastlane (2.222.0)
Expand Down Expand Up @@ -109,6 +109,7 @@ GEM
xcodeproj (>= 1.13.0, < 2.0.0)
xcpretty (~> 0.3.0)
xcpretty-travis-formatter (>= 0.0.3, < 2.0.0)
fastlane-plugin-increment_version_code (0.4.3)
gh_inspector (1.1.3)
google-apis-androidpublisher_v3 (0.54.0)
google-apis-core (>= 0.11.0, < 2.a)
Expand Down Expand Up @@ -152,7 +153,7 @@ GEM
httpclient (2.8.3)
jmespath (1.6.2)
json (2.7.2)
jwt (2.8.2)
jwt (2.9.1)
base64
mini_magick (4.13.2)
mini_mime (1.1.5)
Expand Down Expand Up @@ -193,7 +194,7 @@ GEM
tty-spinner (0.9.3)
tty-cursor (~> 0.7)
uber (0.1.0)
unicode-display_width (2.5.0)
unicode-display_width (2.6.0)
word_wrap (1.0.0)
xcodeproj (1.25.0)
CFPropertyList (>= 2.3.3, < 4.0)
Expand All @@ -214,6 +215,7 @@ PLATFORMS

DEPENDENCIES
fastlane
fastlane-plugin-increment_version_code

BUNDLED WITH
2.5.18
15 changes: 13 additions & 2 deletions androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md
*/
import org.mifos.mobile.dynamicVersion

/*
* Copyright 2024 Mifos Initiative
*
Expand All @@ -20,7 +31,7 @@ android {
namespace = "org.mifos.mobile"

defaultConfig {
versionName = project.version.toString()
versionName = project.dynamicVersion
versionCode = System.getenv("VERSION_CODE")?.toIntOrNull() ?: 1
applicationId = "org.mifos.mobile"
vectorDrawables.useSupportLibrary = true
Expand Down Expand Up @@ -133,4 +144,4 @@ dependencies {
androidTestImplementation(libs.hilt.android.testing)

debugApi(libs.androidx.compose.ui.tooling)
}
}
2 changes: 1 addition & 1 deletion androidApp/dependencies/releaseRuntimeClasspath.tree.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@
| | | +--- com.google.dagger:hilt-android:2.52 (*)
| | | +--- com.squareup.retrofit2:converter-gson:2.11.0 (*)
| | | +--- com.github.Raizlabs.DBFlow:dbflow:4.2.4
| | | | +--- com.github.Raizlabs.DBFlow:dbflow-core:4.2.4
| | | | \--- com.github.Raizlabs.DBFlow:dbflow-core:4.2.4
| | | | \--- com.android.support:support-annotations:26.0.1 -> androidx.annotation:annotation:1.8.1 (*)
| | | +--- com.github.Raizlabs.DBFlow:dbflow-core:4.2.4
| | | +--- io.reactivex.rxjava2:rxandroid:2.1.1
Expand Down
2 changes: 1 addition & 1 deletion androidApp/dependencies/releaseRuntimeClasspath.txt
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ co.touchlab:stately-concurrent-collections-jvm:2.0.6
co.touchlab:stately-concurrent-collections:2.0.6
co.touchlab:stately-strict-jvm:2.0.6
co.touchlab:stately-strict:2.0.6
com.github.Raizlabs.DBFlow:dbflow-core:4.2.4
com.github.Raizlabs.DBFlow:dbflow:4.2.4
com.github.Raizlabs.DBFlow:dbflow-core:4.2.4
com.google.accompanist:accompanist-pager:0.34.0
com.google.accompanist:accompanist-permissions:0.34.0
com.google.android.datatransport:transport-api:3.2.0
Expand Down
2 changes: 0 additions & 2 deletions androidApp/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,3 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

-keep class * extends com.raizlabs.android.dbflow.config.DatabaseHolder { *; }
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import org.gradle.kotlin.dsl.getByType
val Project.libs
get(): VersionCatalog = extensions.getByType<VersionCatalogsExtension>().named("libs")

val Project.dynamicVersion: String
get() = this.version.toString().split('+')[0]

inline fun Project.detektGradle(crossinline configure: DetektExtension.() -> Unit) =
extensions.configure<DetektExtension> {
configure()
Expand Down
15 changes: 10 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,15 @@ plugins {
alias(libs.plugins.jetbrainsCompose) apply false
}

tasks.register("versionFile") {
group = "publishing"
doLast {
println(project.version.toString())
project.file("version.txt").writeText(project.version.toString())
object DynamicVersion {
fun setDynamicVersion(file: File, version: String) {
val cleanedVersion = version.split('+')[0]
file.writeText(cleanedVersion)
}
}

tasks.register("versionFile") {
val file = File(projectDir, "version.txt")

DynamicVersion.setDynamicVersion(file, project.version.toString())
}
4 changes: 4 additions & 0 deletions core/data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ android {
isReturnDefaultValues = true
}
}

defaultConfig {
consumerProguardFiles("consumer-rules.pro")
}
}

dependencies {
Expand Down
21 changes: 0 additions & 21 deletions core/data/proguard-rules.pro

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ class UserAuthRepositoryImp @Inject constructor(
}

override suspend fun login(username: String, password: String): Flow<User> {
val loginPayload = LoginPayload().apply {
this.username = username
this.password = password
}
val loginPayload = LoginPayload(
username = username,
password = password,
)

return flow {
emit(dataManager.login(loginPayload))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ class UserAuthRepositoryImpTest {

@Test
fun testLogin_SuccessResponseReceivedFromDataManager_ReturnsUserSuccessfully() = runTest {
val mockLoginPayload = LoginPayload().apply {
this.username = "username"
this.password = "password"
}
val mockLoginPayload = LoginPayload(
username = "username",
password = "password",
)

Mockito.`when`(
dataManager.login(mockLoginPayload),
Expand All @@ -143,10 +143,11 @@ class UserAuthRepositoryImpTest {

@Test(expected = Exception::class)
fun testLogin_ErrorResponseReceivedFromDataManager_ReturnsError() = runTest {
val mockLoginPayload = LoginPayload().apply {
this.username = "username"
this.password = "password"
}
val mockLoginPayload = LoginPayload(
username = "username",
password = "password",
)

Mockito.`when`(
dataManager.login(mockLoginPayload),
).thenThrow(Exception("Error occurred"))
Expand Down
Loading

0 comments on commit adb579e

Please sign in to comment.