Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into fix_issue_2938
Browse files Browse the repository at this point in the history
  • Loading branch information
madhavbhavsar authored Feb 20, 2024
2 parents 1f12d6f + bd7b890 commit b1c38af
Show file tree
Hide file tree
Showing 37 changed files with 3,640 additions and 57 deletions.
62 changes: 31 additions & 31 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,34 @@ jobs:
- name: Run unit tests
run: ./gradlew testDebugUnitTest

code_coverage:
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout GIT
uses: actions/checkout@v4

- name: Setup Java SDK
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '18'

- name: Enable Gradle Wrapper caching (optimization)
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Code Coverage
run: ./gradlew koverHtmlReport

- name: Upload Code Coverage report
uses: actions/upload-artifact@v4
with:
name: code-coverage-report
path: app/build/artifacts/reports/kover/coverageResults/*
# code_coverage:
# needs: test
# runs-on: ubuntu-latest
# steps:
# - name: Checkout GIT
# uses: actions/checkout@v4
#
# - name: Setup Java SDK
# uses: actions/setup-java@v4
# with:
# distribution: 'adopt'
# java-version: '18'
#
# - name: Enable Gradle Wrapper caching (optimization)
# uses: actions/cache@v4
# with:
# path: |
# ~/.gradle/caches
# ~/.gradle/wrapper
# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
# restore-keys: |
# ${{ runner.os }}-gradle-
#
# - name: Code Coverage
# run: ./gradlew koverHtmlReport
#
# - name: Upload Code Coverage report
# uses: actions/upload-artifact@v4
# with:
# name: code-coverage-report
# path: app/build/artifacts/reports/kover/coverageResults/*
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ android {

matchingFallbacks.add("release")

isDebuggable = true
isDebuggable = false
isDefault = false

signingConfig = signingConfigs.getByName("debug")
Expand Down
2 changes: 2 additions & 0 deletions config/detekt/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1117,3 +1117,5 @@ IvyExplicit:
active: true
NoImplicitFunctionReturnType:
active: true
UnnecessaryPassThroughClass:
active: true
6 changes: 5 additions & 1 deletion docs/CI-Troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ If this job is failing this means that your changes break an existing unit test.

## Compose Stability

This GitHub Action checks whether your `@Composable` functions are stable (i.e. "restartable" and "skippable"). If it fails it means that some of your composables are unstable. That causes unnecessary recompositions which can lead to lost frames and laggy UI/UX especially when animation or scrolling. You must fix that! To fix it, open the failing working and see the output from report - it tells you which `@Composable` functions are unstable and what parameters cause that.
This GitHub Action checks whether your `@Composable` functions are stable (i.e. "restartable" and "skippable"). If it fails it means that some of your composables are unstable. That causes unnecessary recompositions which can lead to lost frames and laggy UI/UX especially when animation or scrolling. You must fix that! To fix it, open the failing working and see the output from the report - it tells you which `@Composable` functions are unstable and what parameters cause that.

**Fixing Stability issues:**
1. Read https://developer.android.com/jetpack/compose/performance/stability/fix
2. https://developer.android.com/jetpack/compose/performance/stability

**Compose Stability baseline** (not recommended)
```
Expand Down
4 changes: 4 additions & 0 deletions docs/resources/YouTube-Videos.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
- [Domain Modeling Made Functional](https://youtu.be/2JB1_e5wZmU) [Scott Wlaschin]
- [The Grug Brained Developer - reaction](https://www.youtube.com/watch?v=0KFiDK9r4UI) [ThePrimeTime]

## Math

- [Categories for the Working Hacker](https://youtu.be/gui_SE8rJUM?si=nBHmCInfNI65q2x7) [Philip Wadler]

## Kotlin Flows

- [Kotlin Flows in Practice](https://www.youtube.com/watch?v=fSB6_KE95bU) [Android Developers]
Expand Down
16 changes: 8 additions & 8 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[versions]
kotlin = "1.9.22"
kotlin-coroutines = "1.7.3"
kotlin-coroutines = "1.8.0"
ktor = "2.3.8"
arrow = "1.2.1"
kotest = "5.8.0"
# https://developer.android.com/jetpack/androidx/releases/compose
compose = "1.6.0"
compose = "1.6.1"
# https://developer.android.com/jetpack/androidx/releases/compose-kotlin
compose-compiler = "1.5.8" # It's used! Use compatible with Kotlin one
compose-material3 = "1.2.0"
Expand Down Expand Up @@ -38,7 +38,7 @@ kotlin-coroutines-googleplay-temp = { module = "org.jetbrains.kotlinx:kotlinx-co
kotlinx-collections-immutable = { module = "org.jetbrains.kotlinx:kotlinx-collections-immutable", version.ref = "kotlinx-collections" }

# KotlinX Serialization
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version = "1.6.2" }
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version = "1.6.3" }
kotlinx-serialization-plugin = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin" }

# Ktor
Expand Down Expand Up @@ -101,11 +101,11 @@ hilt-compiler = { module = "com.google.dagger:hilt-android-compiler", version.re
hilt-gradle-plugin = { module = "com.google.dagger:hilt-android-gradle-plugin", version.ref = "hilt" }

# Google
google-services-plugin = { module = "com.google.gms:google-services", version = "4.4.0" }
google-playservices-auth = { module = "com.google.android.gms:play-services-auth", version = "20.7.0" }
google-services-plugin = { module = "com.google.gms:google-services", version = "4.4.1" }
google-playservices-auth = { module = "com.google.android.gms:play-services-auth", version = "21.0.0" }
google-play-core = { module = "com.google.android.play:core", version = "1.10.3" }
google-play-core-ktx = { module = "com.google.android.play:core-ktx", version = "1.8.1" }
firebase-crashlytics = { module = "com.google.firebase:firebase-crashlytics", version = "18.6.1" }
firebase-crashlytics = { module = "com.google.firebase:firebase-crashlytics", version = "18.6.2" }
firebase-crashlytics-gradle-plugin = { module = "com.google.firebase:firebase-crashlytics-gradle", version = "2.9.9" }

# AndroidX
Expand Down Expand Up @@ -133,7 +133,7 @@ detekt-gradle-plugin = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plu
detekt-ruleset-compiler = { module = "com.braisgabin.detekt:kotlin-compiler-wrapper", version = "0.0.4" }
detekt-ruleset-ktlint = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detekt" }
detekt-ruleset-compose = { module = "io.nlopez.compose.rules:detekt", version = "0.3.11" }
detekt-ruleset-ivy-explicit = { module = "com.github.Ivy-Apps:detekt-explicit", version = "v0.0.5" }
detekt-ruleset-ivy-explicit = { module = "com.github.Ivy-Apps:detekt-explicit", version = "v0.0.7" }
slack-lint-compose = { module = "com.slack.lint.compose:compose-lint-checks", version = "1.3.1" }

# KSP
Expand Down Expand Up @@ -223,4 +223,4 @@ opencsv = [

[plugins]
gradleWrapperUpgrade = { id = "org.gradle.wrapper-upgrade", version = "0.11.4" }
koverPlugin = { id = "org.jetbrains.kotlinx.kover", version = "0.7.5" }
koverPlugin = { id = "org.jetbrains.kotlinx.kover", version = "0.7.6" }
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.content.Context
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
import com.ivy.data.db.dao.write.WriteAccountDao
Expand All @@ -30,6 +31,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import javax.inject.Inject

@Stable
@SuppressLint("StaticFieldLeak")
@HiltViewModel
class AccountsViewModel @Inject constructor(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.ivy.attributions

import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import com.ivy.domain.ComposeViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@Stable
@HiltViewModel
class AttributionsViewModel @Inject constructor(
private val attributionsProvider: AttributionsProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ivy.balance

import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableDoubleStateOf
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
Expand All @@ -16,6 +17,7 @@ import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject

@Stable
@HiltViewModel
class BalanceViewModel @Inject constructor(
private val plannedPaymentsLogic: PlannedPaymentsLogic,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ivy.budgets

import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableDoubleStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
Expand Down Expand Up @@ -35,6 +36,7 @@ import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.launch
import javax.inject.Inject

@Stable
@HiltViewModel
class BudgetViewModel @Inject constructor(
private val sharedPrefs: SharedPrefs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import com.ivy.wallet.ui.theme.modal.edit.CategoryModal
import com.ivy.wallet.ui.theme.modal.edit.CategoryModalData
import com.ivy.wallet.ui.theme.toComposeColor
import com.ivy.wallet.ui.theme.wallet.AmountCurrencyB1
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import java.util.UUID

Expand Down Expand Up @@ -428,7 +429,7 @@ private fun CategoryHeader(
@Suppress("UnusedParameter")
@Composable
fun BoxWithConstraintsScope.SortModal(
items: List<SortOrder>,
items: ImmutableList<SortOrder>,
visible: Boolean,
initialType: SortOrder,
dismiss: () -> Unit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ivy.categories

import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
import com.ivy.base.legacy.Transaction
Expand Down Expand Up @@ -31,6 +32,7 @@ import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.launch
import javax.inject.Inject

@Stable
@HiltViewModel
class CategoriesViewModel @Inject constructor(
private val categoryCreator: CategoryCreator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ivy.contributors

import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
import com.ivy.domain.ComposeViewModel
Expand All @@ -10,6 +11,7 @@ import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.launch
import javax.inject.Inject

@Stable
@HiltViewModel
class ContributorsViewModel @Inject constructor(
private val ivyWalletRepositoryDataSource: IvyWalletRepositoryDataSource
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ivy.transaction

import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableDoubleStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
Expand Down Expand Up @@ -58,6 +59,7 @@ import java.time.LocalTime
import java.util.UUID
import javax.inject.Inject

@Stable
@HiltViewModel
class EditTransactionViewModel @Inject constructor(
private val loanDao: LoanDao,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ivy.exchangerates

import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
import com.ivy.data.db.dao.read.ExchangeRatesDao
Expand All @@ -22,6 +23,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import javax.inject.Inject

@Stable
@HiltViewModel
class ExchangeRatesViewModel @Inject constructor(
private val exchangeRatesDao: ExchangeRatesDao,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.ivy.features
import android.annotation.SuppressLint
import android.content.Context
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.lifecycle.viewModelScope
import com.ivy.domain.ComposeViewModel
import com.ivy.domain.features.Features
Expand All @@ -14,6 +15,7 @@ import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import javax.inject.Inject

@Stable
@SuppressLint("StaticFieldLeak")
@HiltViewModel
class FeaturesViewModel @Inject constructor(
Expand Down
2 changes: 2 additions & 0 deletions screen/home/src/main/java/com/ivy/home/HomeViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ivy.home

import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
import com.ivy.base.legacy.Theme
Expand Down Expand Up @@ -56,6 +57,7 @@ import kotlinx.coroutines.launch
import java.math.BigDecimal
import javax.inject.Inject

@Stable
@HiltViewModel
class HomeViewModel @Inject constructor(
private val ivyContext: IvyWalletCtx,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ivy.loans.loan

import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
import com.ivy.base.legacy.SharedPrefs
Expand Down Expand Up @@ -37,6 +38,7 @@ import kotlinx.coroutines.launch
import java.util.UUID
import javax.inject.Inject

@Stable
@HiltViewModel
class LoanViewModel @Inject constructor(
private val loanRecordDao: LoanRecordDao,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ivy.loans.loandetails

import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableDoubleStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
Expand Down Expand Up @@ -49,6 +50,7 @@ import kotlinx.coroutines.launch
import java.util.UUID
import javax.inject.Inject

@Stable
@HiltViewModel
class LoanDetailsViewModel @Inject constructor(
private val loanDao: LoanDao,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ivy.onboarding.viewmodel

import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.compose.runtime.State
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
Expand Down Expand Up @@ -43,6 +44,7 @@ import kotlinx.coroutines.launch
import timber.log.Timber
import javax.inject.Inject

@Stable
@HiltViewModel
class OnboardingViewModel @Inject constructor(
private val ivyContext: IvyWalletCtx,
Expand Down
Loading

0 comments on commit b1c38af

Please sign in to comment.