Skip to content

Commit

Permalink
Fix Gradle Error & Refactor Multiple Activity to Single Activity (#1750)
Browse files Browse the repository at this point in the history
* Fix Gradle Error & Refactor Multiple Activity to Single Activity

* Fixed Build Error

* Fixed CI Workflow Usage

* Fixed CI Workflow Usage

* Fixed CI Workflow

* Fixing CI Workflow Usage

* Fixing CI Workflow Usage

* CI - Rename dependency check job to dependency guard

* CI - Trigger workflow on pull requests

* CI - Updated CI Workflow Usage
  • Loading branch information
niyajali authored Aug 23, 2024
1 parent a1bcbe5 commit a12b843
Show file tree
Hide file tree
Showing 155 changed files with 4,302 additions and 2,936 deletions.
238 changes: 112 additions & 126 deletions .github/workflows/master_dev_ci.yml
Original file line number Diff line number Diff line change
@@ -1,158 +1,144 @@
name: Mobile-Wallet CI[Master/Dev]

on:
pull_request:
push:
branches:
- 'dev'
- 'master'
- 'payment_hub'
branches: [ dev, master, payment_hub ]
pull_request:

concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build APK
setup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

# Set up JDK
- name: Set Up JDK 17
uses: actions/setup-java@v1
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- uses: gradle/actions/setup-gradle@v4

# Install NDK
#- name: Install NDK
# run: echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;20.0.5594570" --sdk_root=${ANDROID_SDK_ROOT}

# Update Gradle Permission
- name: Change gradlew Permission
run: chmod +x gradlew

# Turing off detekt check until migration finished
# - name: Check Dependency Guard
# id: dependencyguard_verify
# continue-on-error: true
# run: ./gradlew dependencyGuard
#
# - name: Prevent updating Dependency Guard baselines if this is a fork
# id: checkfork_dependencyguard
# continue-on-error: false
# if: steps.dependencyguard_verify.outcome == 'failure' && github.event.pull_request.head.repo.full_name != github.repository
# run: |
# echo "::error::Dependency Guard failed, please update baselines with: ./gradlew dependencyGuardBaseline" && exit 1

# Build App
- name: Build with Gradle
run: ./gradlew assemble

# Upload Built APK
- name: Upload Build Artifacts
uses: actions/upload-artifact@v2.2.0
- name: Cache Gradle and build outputs
uses: actions/cache@v4
with:
name: mobile-wallet
path: mifospay/build/outputs/apk/debug/

# Turing off detekt check until migration finished
# lintCheck:
# name: Static Analysis
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
#
# # Setup JDK 17
# - name: Setup JDK 17
# uses: actions/setup-java@v1
# with:
# java-version: 17
#
# - name: Detekt For All Modules
# run: ./gradlew detekt

pmd:
name: PMD
path: |
~/.gradle/caches
~/.gradle/wrapper
build
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle-

checks:
needs: setup
runs-on: ubuntu-latest
strategy:
matrix:
check: [ build_logic, spotless, detekt ]
steps:
- uses: actions/checkout@v2

# Setup JDK 17
- name: Setup JDK 17
uses: actions/setup-java@v1
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17

- uses: actions/checkout@v4
- name: PMD Check[MifosPay]
run: ./gradlew mifospay:pmd

- name: Upload PMD Report[MifosPay]
uses: actions/upload-artifact@v3.1.3
if: failure()
- name: Run ${{ matrix.check }}
id: run_check
run: |
if [ "${{ matrix.check }}" = "build_logic" ]; then
./gradlew check -p build-logic
elif [ "${{ matrix.check }}" = "spotless" ]; then
./gradlew spotlessCheck --no-configuration-cache --no-daemon
elif [ "${{ matrix.check }}" = "detekt" ]; then
./gradlew detekt
fi
- name: Upload Detekt Reports
if: ${{ matrix.check }} == 'detekt' && steps.run_check.outcome == 'success'
uses: actions/upload-artifact@v4
with:
name: PMD Report[MifosPay]
path: mifospay/build/reports/

- name: PMD Check[Core:Datastore]
run: ./gradlew core:datastore:pmd

- name: PMD Check[Core:Data]
run: ./gradlew core:data:pmd

- name: PMD Check[Core:DesignSystem]
run: ./gradlew core:designsystem:pmd

- name: PMD Check[Core:Common]
run: ./gradlew core:common:pmd

- name: PMD Check[Core:Network]
run: ./gradlew core:network:pmd

- name: PMD Check[Core:Model]
run: ./gradlew core:model:pmd
name: detekt-reports
path: |
**/build/reports/detekt/detekt.md
- name: PMD Check[Feature:Auth]
run: ./gradlew feature:auth:pmd
checkstyle:
name: Checkstyle
dependency_guard:
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

# Setup JDK 17
- name: Setup JDK 17
uses: actions/setup-java@v1
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17

- uses: actions/checkout@v2
- name: Checkstyle[MifosPay]
run: ./gradlew mifospay:checkstyle

- name: Upload Checkstyle Report[MifosPay]
uses: actions/upload-artifact@v2.2.0
if: failure()
- name: Check Dependency Guard
id: dependencyguard_verify
continue-on-error: true
run: ./gradlew dependencyGuard

- name: Prevent updating Dependency Guard baselines if this is a fork
id: checkfork_dependencyguard
continue-on-error: false
if: steps.dependencyguard_verify.outcome == 'failure' && github.event.pull_request.head.repo.full_name != github.repository
run: |
echo "::error::Dependency Guard failed, please update baselines with: ./gradlew dependencyGuardBaseline" && exit 1
# Runs if previous job failed
- name: Generate new Dependency Guard baselines if verification failed and it's a PR
id: dependencyguard_baseline
if: steps.dependencyguard_verify.outcome == 'failure' && github.event_name == 'pull_request'
run: |
./gradlew dependencyGuardBaseline
- name: Push new Dependency Guard baselines if available
uses: stefanzweifel/git-auto-commit-action@v5
if: steps.dependencyguard_baseline.outcome == 'success'
with:
name: Checkstyle Report[MifosPay]
path: mifospay/build/reports/
file_pattern: '**/dependencies/*.txt'
disable_globbing: true
commit_message: "🤖 Updates baselines for Dependency Guard"

- name: Static Analysis[Core:Datastore]
run: ./gradlew core:datastore:checkstyle

- name: Static Analysis[Core:Data]
run: ./gradlew core:data:checkstyle
tests_and_lint:
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- name: Run tests
run: |
./gradlew testDemoDebug
- name: Upload reports
if: always()
uses: actions/upload-artifact@v4
with:
name: test-and-lint-reports
path: |
**/build/test-results/test*UnitTest/**.xml
- name: Static Analysis[Core:DesignSystem]
run: ./gradlew core:designsystem:checkstyle
build:
needs: [ checks, tests_and_lint ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17

- name: Static Analysis[Core:Common]
run: ./gradlew core:common:checkstyle
- name: Build APKs
run: ./gradlew :app:assemble

- name: Static Analysis[Core:Network]
run: ./gradlew core:network:checkstyle
- name: Check badging
run: ./gradlew :app:checkProdReleaseBadging

- name: Static Analysis[Core:Model]
run: ./gradlew core:model:checkstyle
- name: Upload APKs
uses: actions/upload-artifact@v4
with:
name: APKs
path: '**/build/outputs/apk/**/*.apk'

- name: Static Analysis[Feature:Auth]
run: ./gradlew feature:auth:checkstyle
11 changes: 1 addition & 10 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ val detektFormatting = libs.detekt.formatting
val twitterComposeRules = libs.twitter.detekt.compose
val ktlintVersion = "1.0.1"

val reportMerge by tasks.registering(io.gitlab.arturbosch.detekt.report.ReportMergeTask::class) {
output.set(rootProject.layout.buildDirectory.file("reports/detekt/merge.html")) // or "reports/detekt/merge.sarif"
}

subprojects {
apply {
Expand All @@ -49,7 +46,7 @@ subprojects {
tasks.withType<io.gitlab.arturbosch.detekt.Detekt>().configureEach {
config.from(rootProject.files("config/detekt/detekt.yml"))
reports.xml.required.set(true)
finalizedBy(reportMerge)
reports.html.required.set(true)
}

extensions.configure<com.diffplug.gradle.spotless.SpotlessExtension> {
Expand Down Expand Up @@ -77,12 +74,6 @@ subprojects {
}
}

reportMerge {
input.from(tasks.withType<io.gitlab.arturbosch.detekt.Detekt>().map {
it.htmlReportFile }
)
}

dependencies {
detektPlugins(detektFormatting)
detektPlugins(twitterComposeRules)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,21 @@ import org.mifospay.core.datastore.PreferencesHelper
import javax.inject.Inject

class AuthenticationUserRepository @Inject constructor(
preferencesHelper: PreferencesHelper,
private val preferencesHelper: PreferencesHelper,
) : UserDataRepository {

override val userData: Flow<UserData> = flow {
emit(
UserData(
isAuthenticated = !preferencesHelper.token.isNullOrBlank(),
isAuthenticated = !preferencesHelper.token.isNullOrEmpty(),
userName = preferencesHelper.username,
// user = preferencesHelper.user,
clientId = preferencesHelper.clientId,
),
)
}

override fun logOut() {
preferencesHelper.clear()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ interface UserDataRepository {
* Stream of [UserData]
*/
val userData: Flow<UserData>

fun logOut(): Unit
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ fun MifosLoadingWheel(
animationSpec = infiniteRepeatable(
animation = keyframes {
durationMillis = ROTATION_TIME / 2
progressLineColor at ROTATION_TIME / NUM_OF_LINES / 2 with LinearEasing
baseLineColor at ROTATION_TIME / NUM_OF_LINES with LinearEasing
progressLineColor at ROTATION_TIME / NUM_OF_LINES / 2 using LinearEasing
baseLineColor at ROTATION_TIME / NUM_OF_LINES using LinearEasing
},
repeatMode = RepeatMode.Restart,
initialStartOffset = StartOffset(ROTATION_TIME / NUM_OF_LINES / 2 * index),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
package org.mifospay.core.designsystem.component

import androidx.compose.foundation.layout.RowScope
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
Expand All @@ -22,6 +20,7 @@ import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import org.mifospay.core.designsystem.icon.MifosIcons

@OptIn(ExperimentalMaterial3Api::class)
@Composable
Expand All @@ -42,7 +41,7 @@ fun MifosTopBar(
navigationIcon = {
IconButton(onClick = { backPress.invoke() }) {
Icon(
imageVector = Icons.Filled.ArrowBack,
imageVector = MifosIcons.ArrowBack,
contentDescription = "Back",
tint = MaterialTheme.colorScheme.onSurface,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,9 @@ private val DarkDefaultColorScheme = darkColorScheme(
scrim = md_theme_dark_scrim,
)

@Suppress("UnusedParameter")
@Composable
fun MifosTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
// Dynamic color is available on Android 12+
dynamicColor: Boolean = true,
content: @Composable () -> Unit,
) {
// Color scheme
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fun ExpiryDateInput(
onDone: () -> Unit,
modifier: Modifier = Modifier,
) {
val (a, b, c) = FocusRequester.createRefs()
val (b, c) = FocusRequester.createRefs()
Row(
modifier = modifier
.fillMaxWidth()
Expand Down
Loading

0 comments on commit a12b843

Please sign in to comment.