diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 9183edc32b..fd6a02b2eb 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -41,14 +41,4 @@ _💡 Tip: Attach screenshots and screen recordings. It helps a lot!_ Check **[Ivy Wallet Issues](https://github.com/Ivy-Apps/ivy-wallet/issues)**. - Closes #{ISSUE_NUMBER} -_Replace `{ISSUE_NUMBER}` with the id/number of the issue that you've fixed._ - -## Final Steps - -Test your build again with the **app-demo.apk** generated by the `APK workflow`. This is an important step because it applies code obfuscation and R8 that often produces runtime exceptions which make the app crash. - -> We don't have QA, you are the QA! That's why we require so much testing. - -If everything still works fines, comment and tag **@ILIYANGERMANOV**. He'll try to merge your PR whenever possible. - -**Thank you for your contribution! 🎉** \ No newline at end of file +_Replace `{ISSUE_NUMBER}` with the id/number of the issue that you've fixed._ \ No newline at end of file diff --git a/.github/workflows/apk.yml b/.github/workflows/apk.yml index 8c67d74dd9..7c55e35fb5 100644 --- a/.github/workflows/apk.yml +++ b/.github/workflows/apk.yml @@ -3,6 +3,8 @@ name: APK on: # Triggers the workflow on push or pull request events push: + branches: + - main pull_request: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 12b810015a..c25b6d6cc7 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -4,6 +4,8 @@ name: Lint on: # Triggers the workflow on push or pull request events push: + branches: + - main pull_request: @@ -43,6 +45,7 @@ jobs: run: ./gradlew detekt - name: Upload Detekt Release report to GitHub + if: always() uses: actions/upload-artifact@v3 with: name: detekt-report.html @@ -54,6 +57,7 @@ jobs: run: ./gradlew lintRelease - name: Upload Lint Release report to GitHub + if: always() uses: actions/upload-artifact@v3 with: name: lint-release-report.html diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f1be40c55e..4cd55aff98 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,6 +4,8 @@ name: Unit tests on: # Triggers the workflow on push or pull request events push: + branches: + - main pull_request: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2b0d923ac7..4988294159 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,6 +6,8 @@ You can do that by cliking this badge: 👉 [![Fork Ivy Wallet](https://img.shie **[How To Fork Guide by GitHub](https://docs.github.com/en/get-started/quickstart/fork-a-repo)** +After you've cloned your Ivy Wallet fork make sure to initialize the project using **[the initialization instructions in the README](./README.md#initialize-the-project)**. + ## 2. Pick an issue What do you want to work on? How do you want to contribute? diff --git a/README.md b/README.md index ddfb4eddc4..0e1764c7ba 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,20 @@ Ivy Wallet's biggest advantage is its UI/UX, simplicity, and customization that - The latest **Android Studio Hedgehog** or above (for easy install use [JetBrains Toolbox](https://www.jetbrains.com/toolbox-app/)) +### Initialize the project + +**1. Fork and clone the repo** + +**2. Make the initialization script executable:** +``` +chmod +x scripts/init.sh +``` + +**3. Run the initialization script:** +``` +./scripts/init.sh +``` + ## Learning Materials Ivy Wallet is a great place to code and learn. That's why we're also linking great learning materials (books, articles, videos), check them in **[docs/resources 📚](docs/resources/)**. diff --git a/app/src/main/java/com/ivy/wallet/ui/settings/SettingsViewModel.kt b/app/src/main/java/com/ivy/wallet/ui/settings/SettingsViewModel.kt index 543df2b7da..d4657eafa0 100644 --- a/app/src/main/java/com/ivy/wallet/ui/settings/SettingsViewModel.kt +++ b/app/src/main/java/com/ivy/wallet/ui/settings/SettingsViewModel.kt @@ -103,7 +103,9 @@ class SettingsViewModel @Inject constructor( viewModelScope.launch { TestIdlingResource.increment() - val settings = ioThread { settingsDao.findFirst() } + val settings = ioThread { + settingsDao.findFirst() + } _nameLocalAccount.value = settings.name diff --git a/app/src/main/java/com/ivy/wallet/ui/test/TestScreen.kt b/app/src/main/java/com/ivy/wallet/ui/test/TestScreen.kt index c1096c0533..ee10c8c204 100644 --- a/app/src/main/java/com/ivy/wallet/ui/test/TestScreen.kt +++ b/app/src/main/java/com/ivy/wallet/ui/test/TestScreen.kt @@ -39,18 +39,12 @@ fun BoxWithConstraintsScope.TestScreen(screen: Test) { UI( user = user, - - onSyncCategories = viewModel::syncCategories, - onTestWorker = viewModel::testWorker, ) } @Composable private fun BoxWithConstraintsScope.UI( user: User?, - - onSyncCategories: () -> Unit, - onTestWorker: () -> Unit, ) { var chooseIconModalVisible by remember { mutableStateOf(false) @@ -88,9 +82,6 @@ private fun Preview() { IvyWalletPreview { UI( user = null, - - onSyncCategories = {}, - onTestWorker = {} ) } } \ No newline at end of file diff --git a/app/src/main/java/com/ivy/wallet/ui/test/TestViewModel.kt b/app/src/main/java/com/ivy/wallet/ui/test/TestViewModel.kt index 9ffc67ce67..346e29ee78 100644 --- a/app/src/main/java/com/ivy/wallet/ui/test/TestViewModel.kt +++ b/app/src/main/java/com/ivy/wallet/ui/test/TestViewModel.kt @@ -4,10 +4,7 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.ivy.frp.test.TestIdlingResource -import com.ivy.wallet.backup.github.GitHubClient import com.ivy.wallet.domain.data.core.User -import com.ivy.wallet.domain.deprecated.logic.notification.TransactionReminderLogic -import com.ivy.wallet.domain.deprecated.sync.item.CategorySync import com.ivy.wallet.io.network.IvySession import com.ivy.wallet.io.persistence.dao.UserDao import com.ivy.wallet.utils.asLiveData @@ -18,11 +15,8 @@ import javax.inject.Inject @HiltViewModel class TestViewModel @Inject constructor( - private val categorySync: CategorySync, private val userDao: UserDao, private val ivySession: IvySession, - private val transactionReminderLogic: TransactionReminderLogic, - private val gitHubClient: GitHubClient, ) : ViewModel() { private val _user = MutableLiveData() @@ -40,20 +34,4 @@ class TestViewModel @Inject constructor( TestIdlingResource.decrement() } } - - fun syncCategories() { - viewModelScope.launch { - TestIdlingResource.increment() - - ioThread { - categorySync.sync() - } - - TestIdlingResource.decrement() - } - } - - fun testWorker() { - transactionReminderLogic.testNow() - } } \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/ivy.lint.gradle.kts b/buildSrc/src/main/kotlin/ivy.lint.gradle.kts index 60cdd96480..a8da9cbeae 100644 --- a/buildSrc/src/main/kotlin/ivy.lint.gradle.kts +++ b/buildSrc/src/main/kotlin/ivy.lint.gradle.kts @@ -6,11 +6,17 @@ plugins { } configure { - source.setFrom(projectDir) + val filesToCheck: String? = System.getProperty("detekt.filesToCheck") + if (!filesToCheck.isNullOrEmpty()) { + source.setFrom(filesToCheck.split(",")) + } else { + source.setFrom(projectDir) + } config.setFrom("$rootDir/config/detekt/config.yml") baseline = file("$rootDir/config/detekt/baseline.yml") } + tasks.register("detektFormat") { autoCorrect = true } diff --git a/config/detekt/baseline.yml b/config/detekt/baseline.yml index aee0e0cd45..30683fbf02 100644 --- a/config/detekt/baseline.yml +++ b/config/detekt/baseline.yml @@ -4355,6 +4355,7 @@ NoConsecutiveBlankLines:WrapContentRow.kt$ NoConsecutiveBlankLines:build.gradle.kts$ NoConsecutiveBlankLines:dependencies.kt$ + NoConsecutiveBlankLines:ivy.lint.gradle.kts$ NoEmptyClassBody:AccountsUpdatedEvent.kt$AccountsUpdatedEvent${ } NoEmptyFirstLineInMethodBlock:AccountCharts.kt$ NoEmptyFirstLineInMethodBlock:AccountModal.kt$ @@ -4625,7 +4626,7 @@ PackageName:MoreMenu.kt$package com.ivy.design.l4_patterns PackageName:Onboarding.kt$package com.ivy.design.l5_concept PackageName:PieChart.kt$package com.ivy.design.l3_ivyComponents.chart - PackageName:PluginSpecBuilders.kt$package gradle.kotlin.dsl.plugins._cbc4edcb0c3d88134f29766b2a7d4f41 + PackageName:PluginSpecBuilders.kt$package gradle.kotlin.dsl.plugins._fe0b42ce1102c239397a785329863d5f PackageName:ProgressBar.kt$package com.ivy.design.l3_ivyComponents.percentage PackageName:ReorderModal.kt$package com.ivy.design.l4_patterns PackageName:ScreenTitle.kt$package com.ivy.design.l3_ivyComponents @@ -4692,7 +4693,7 @@ PackageNaming:MoreMenu.kt$package com.ivy.design.l4_patterns PackageNaming:Onboarding.kt$package com.ivy.design.l5_concept PackageNaming:PieChart.kt$package com.ivy.design.l3_ivyComponents.chart - PackageNaming:PluginSpecBuilders.kt$package gradle.kotlin.dsl.plugins._cbc4edcb0c3d88134f29766b2a7d4f41 + PackageNaming:PluginSpecBuilders.kt$package gradle.kotlin.dsl.plugins._fe0b42ce1102c239397a785329863d5f PackageNaming:ProgressBar.kt$package com.ivy.design.l3_ivyComponents.percentage PackageNaming:ReorderModal.kt$package com.ivy.design.l4_patterns PackageNaming:ScreenTitle.kt$package com.ivy.design.l3_ivyComponents @@ -5224,8 +5225,6 @@ UnusedParameter:SettingsScreen.kt$onLogin: () -> Unit UnusedParameter:SettingsScreen.kt$screen: Settings UnusedParameter:Shapes.kt$modifier: Modifier = Modifier - UnusedParameter:TestScreen.kt$onSyncCategories: () -> Unit - UnusedParameter:TestScreen.kt$onTestWorker: () -> Unit UnusedParameter:TestScreen.kt$screen: Test UnusedParameter:Title.kt$initialTransactionId: UUID? UnusedParameter:WalletCharts.kt$baseCurrencyCode: String @@ -5430,7 +5429,6 @@ UnusedPrivateProperty:SearchScreen.kt$val ivyContext = ivyWalletCtx() UnusedPrivateProperty:SearchScreen.kt$val nav = navigation() UnusedPrivateProperty:SettingsViewModel.kt$SettingsViewModel$private val exchangeRatesLogic: ExchangeRatesLogic - UnusedPrivateProperty:TestViewModel.kt$TestViewModel$private val gitHubClient: GitHubClient UnusedPrivateProperty:TransactionReminderLogic.kt$TransactionReminderLogic.Companion$private const val UNIQUE_WORK_NAME_V1 = "transaction_reminder_work" UnusedPrivateProperty:TransactionViewModel.kt$TransactionViewModel$private val saveTrnLocallyAct: SaveTrnLocallyAct UnusedPrivateProperty:UploadTrnToServerAct.kt$UploadTrnToServerAct$private val dao: TransactionDao diff --git a/git/hooks/pre-push b/git/hooks/pre-push new file mode 100755 index 0000000000..36bc5164aa --- /dev/null +++ b/git/hooks/pre-push @@ -0,0 +1,8 @@ +#!/bin/sh + +./gradlew detektFormat + +if [ $? -ne 0 ]; then + echo "Detekt found issues. Aborting push." + exit 1 +fi \ No newline at end of file diff --git a/scripts/detektFormat.sh b/scripts/detektFormat.sh new file mode 100755 index 0000000000..7ed3705b04 --- /dev/null +++ b/scripts/detektFormat.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# Fetch changed and untracked Kotlin files +CHANGED_FILES=$(git diff --name-only HEAD | grep '\.kt[s]*$' | tr '\n' ',') + +if [ -z "$CHANGED_FILES" ]; then + echo "No Kotlin files have changed." + exit 0 +fi + +# Run detektFormat only on those files +./gradlew detektFormat -Ddetekt.filesToCheck=$CHANGED_FILES diff --git a/scripts/init.sh b/scripts/init.sh new file mode 100755 index 0000000000..40f79ba621 --- /dev/null +++ b/scripts/init.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# scripts/init.sh + +# Define directories +HOOKS_DIR="git/hooks" +GIT_HOOKS_DIR=".git/hooks" +BASE_DIR="$(pwd)" + +# Check if the .git directory exists +if [ ! -d "$GIT_HOOKS_DIR" ]; then + echo "Error: This script should be run from the root of the git repository." + exit 1 +fi + +# Set up symbolic link for pre-push hook +ln -s -f $BASE_DIR/$HOOKS_DIR/pre-push $GIT_HOOKS_DIR/pre-push +echo "pre-push hook has been set up." + +# Ensure the pre-push hook is executable +chmod +x $GIT_HOOKS_DIR/pre-push +echo "pre-push hook is now executable." + +chmod +x /script/detektFormat.sh +echo "scripts in '/scripts' are now executable." + +echo "Repository setup complete!" \ No newline at end of file