From 4000aecc9fd78f4b62d9400647031d0e3f60d4f7 Mon Sep 17 00:00:00 2001 From: Stepan Lavrentev <40560660+stepanLav@users.noreply.github.com> Date: Fri, 19 Jul 2024 11:22:52 +0300 Subject: [PATCH] Fix. Build instrumental tests (#1595) * fix: OOM while build * fix: temp fix for build test * feat: change build flow * ci: add trigger for PR * chore: update references --- .github/scripts/run_balances_test.sh | 2 +- .github/workflows/android_build.yml | 8 ++++++ .github/workflows/balances_test.yml | 24 ++-------------- .github/workflows/pull_request.yml | 1 + .../nova/core_db/dao/ChainDaoTest.kt | 3 +- .../nova/core_db/dao/Helpers.kt | 28 ++++++++++++++----- gradle.properties | 2 +- 7 files changed, 37 insertions(+), 31 deletions(-) diff --git a/.github/scripts/run_balances_test.sh b/.github/scripts/run_balances_test.sh index b37d36cb11..b7b826519e 100644 --- a/.github/scripts/run_balances_test.sh +++ b/.github/scripts/run_balances_test.sh @@ -5,7 +5,7 @@ adb devices adb -s emulator-5554 install app/debug/app-debug.apk # Install instrumental tests -adb -s emulator-5554 install test-app/androidTest/debug/app-debug-androidTest.apk +adb -s emulator-5554 install app/androidTest/debug/app-debug-androidTest.apk # Run tests adb logcat -c && diff --git a/.github/workflows/android_build.yml b/.github/workflows/android_build.yml index eed33645ad..5791001749 100644 --- a/.github/workflows/android_build.yml +++ b/.github/workflows/android_build.yml @@ -27,6 +27,10 @@ on: required: false type: string default: "apk" + build-debug-tests: + required: false + type: boolean + default: false secrets: ACALA_PROD_AUTH_TOKEN: required: true @@ -174,6 +178,10 @@ jobs: if: ${{ !startsWith(inputs.gradlew-command, 'false') }} run: ./gradlew ${{ inputs.gradlew-command }} + - name: ๐Ÿ— Build debug tests + if: ${{ inputs.build-debug-tests }} + run: ./gradlew assembleDebugAndroidTest + - name: ๐Ÿงน Delete key after building if: ${{ !startsWith(inputs.keystore-file-name, 'false') }} run: rm ./app/${{ inputs.keystore-file-name }} diff --git a/.github/workflows/balances_test.yml b/.github/workflows/balances_test.yml index 859bd094b0..f2b74f7ccf 100644 --- a/.github/workflows/balances_test.yml +++ b/.github/workflows/balances_test.yml @@ -6,26 +6,18 @@ on: - cron: '0 */8 * * *' jobs: - develop-build: + build-app: uses: novasamatech/nova-wallet-android/.github/workflows/android_build.yml@develop with: branch: ${{github.head_ref}} gradlew-command: assembleDebug upload-name: develop-apk run-tests: false - secrets: inherit - - test-build: - uses: novasamatech/nova-wallet-android/.github/workflows/android_build.yml@develop - with: - branch: ${{github.head_ref}} - gradlew-command: assembleDebugAndroidTest - upload-name: test-apk - run-tests: false + build-debug-tests: true secrets: inherit run-tests: - needs: [develop-build, test-build] + needs: [build-app] runs-on: macos-13 steps: - uses: actions/checkout@v4 @@ -40,16 +32,6 @@ jobs: run: | ls -laR app - - name: Download instrumential test artifact - uses: actions/download-artifact@v4 - with: - name: test-apk - path: test-app - - - name: Debug path - run: | - ls -laR test-app - - name: Add permissions run: chmod +x .github/scripts/run_balances_test.sh diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 00d072f6e4..2966c038f2 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -10,4 +10,5 @@ jobs: with: branch: ${{github.head_ref}} gradlew-command: assembleDevelop + build-debug-tests: true secrets: inherit diff --git a/core-db/src/androidTest/java/io/novafoundation/nova/core_db/dao/ChainDaoTest.kt b/core-db/src/androidTest/java/io/novafoundation/nova/core_db/dao/ChainDaoTest.kt index b3976326bf..e3bf83bc0b 100644 --- a/core-db/src/androidTest/java/io/novafoundation/nova/core_db/dao/ChainDaoTest.kt +++ b/core-db/src/androidTest/java/io/novafoundation/nova/core_db/dao/ChainDaoTest.kt @@ -118,7 +118,8 @@ class ChainDaoTest : DaoTest(AppDatabase::chainDao) { assetsDiff = emptyDiff(), nodesDiff = emptyDiff(), explorersDiff = emptyDiff(), - externalApisDiff = emptyDiff() + externalApisDiff = emptyDiff(), + nodeSelectionPreferencesDiff = emptyDiff() ) val chainsFromDb = dao.getJoinChainInfo() diff --git a/core-db/src/androidTest/java/io/novafoundation/nova/core_db/dao/Helpers.kt b/core-db/src/androidTest/java/io/novafoundation/nova/core_db/dao/Helpers.kt index da7c2ba6da..cf8bf4ecc1 100644 --- a/core-db/src/androidTest/java/io/novafoundation/nova/core_db/dao/Helpers.kt +++ b/core-db/src/androidTest/java/io/novafoundation/nova/core_db/dao/Helpers.kt @@ -6,9 +6,12 @@ import io.novafoundation.nova.core_db.model.CurrencyLocal import io.novafoundation.nova.core_db.model.chain.AssetSourceLocal import io.novafoundation.nova.core_db.model.chain.account.ChainAccountLocal import io.novafoundation.nova.core_db.model.chain.ChainAssetLocal +import io.novafoundation.nova.core_db.model.chain.ChainExplorerLocal +import io.novafoundation.nova.core_db.model.chain.ChainExternalApiLocal import io.novafoundation.nova.core_db.model.chain.ChainLocal import io.novafoundation.nova.core_db.model.chain.ChainNodeLocal import io.novafoundation.nova.core_db.model.chain.JoinedChainInfo +import io.novafoundation.nova.core_db.model.chain.NodeSelectionPreferencesLocal import io.novafoundation.nova.core_db.model.chain.account.MetaAccountLocal fun createTestChain( @@ -28,8 +31,17 @@ fun createTestChain( assetOf(assetId = it, symbol = it.toString()) } } - - return JoinedChainInfo(chain, nodes, assets, explorers = emptyList(), externalApis = emptyList()) + val explorers = emptyList() + val externalApis = emptyList() + + return JoinedChainInfo( + chain, + NodeSelectionPreferencesLocal(chain.id, autoBalanceEnabled = true, selectedNodeUrl = null), + nodes, + assets, + explorers, + externalApis + ) } fun chainOf( @@ -52,7 +64,8 @@ fun chainOf( supportProxy = false, swap = "", hasSubstrateRuntime = true, - nodeSelectionStrategy = ChainLocal.NodeSelectionStrategyLocal.ROUND_ROBIN + nodeSelectionStrategy = ChainLocal.NodeSelectionStrategyLocal.ROUND_ROBIN, + source = ChainLocal.Source.CUSTOM, ) fun ChainLocal.nodeOf( @@ -61,7 +74,8 @@ fun ChainLocal.nodeOf( name = "Test", url = link, chainId = id, - orderId = 0 + orderId = 0, + source = ChainNodeLocal.Source.CUSTOM, ) fun ChainLocal.assetOf( @@ -90,7 +104,7 @@ suspend fun ChainDao.addChains(chains: List) { nodesDiff = addedDiff(chains.flatMap(JoinedChainInfo::nodes)), explorersDiff = addedDiff(chains.flatMap(JoinedChainInfo::explorers)), externalApisDiff = addedDiff(chains.flatMap(JoinedChainInfo::externalApis)), - nodeSelectionPreferencesDiff = nodeSelectionPreferencesDiff + nodeSelectionPreferencesDiff = emptyDiff() ) } @@ -103,7 +117,7 @@ suspend fun ChainDao.removeChain(joinedChainInfo: JoinedChainInfo) { nodesDiff = removedDiff(joinedChainInfo.nodes), explorersDiff = removedDiff(joinedChainInfo.explorers), externalApisDiff = removedDiff(joinedChainInfo.externalApis), - nodeSelectionPreferencesDiff = nodeSelectionPreferencesDiff + nodeSelectionPreferencesDiff = emptyDiff() ) } @@ -114,7 +128,7 @@ suspend fun ChainDao.updateChain(joinedChainInfo: JoinedChainInfo) { nodesDiff = updatedDiff(joinedChainInfo.nodes), explorersDiff = updatedDiff(joinedChainInfo.explorers), externalApisDiff = updatedDiff(joinedChainInfo.externalApis), - nodeSelectionPreferencesDiff = nodeSelectionPreferencesDiff + nodeSelectionPreferencesDiff = emptyDiff() ) } diff --git a/gradle.properties b/gradle.properties index 828c450395..65c2df377a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,6 +12,6 @@ # org.gradle.parallel=true #Fri Feb 16 12:00:34 MSK 2024 org.gradle.parallel=true -org.gradle.jvmargs=-Xmx3096M -Dkotlin.daemon.jvm.options\="-Xmx3096M" +org.gradle.jvmargs=-Xmx4096M -Dkotlin.daemon.jvm.options\="-Xmx4096M" android.useAndroidX=true android.enableJetifier=true