From 89fdfeba9277298e78abf47cfcf41561360a63d8 Mon Sep 17 00:00:00 2001 From: pakka-papad <76241334+pakka-papad@users.noreply.github.com> Date: Tue, 21 May 2024 11:58:12 +0530 Subject: [PATCH 01/19] Added: Read storage permission check in song extractor --- .../pakka_papad/data/music/SongExtractor.kt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/src/main/java/com/github/pakka_papad/data/music/SongExtractor.kt b/app/src/main/java/com/github/pakka_papad/data/music/SongExtractor.kt index 9342258..7bd9824 100644 --- a/app/src/main/java/com/github/pakka_papad/data/music/SongExtractor.kt +++ b/app/src/main/java/com/github/pakka_papad/data/music/SongExtractor.kt @@ -1,11 +1,14 @@ package com.github.pakka_papad.data.music +import android.Manifest import android.content.ContentUris import android.content.Context +import android.content.pm.PackageManager import android.media.MediaMetadataRetriever import android.net.Uri import android.os.Build import android.provider.MediaStore +import androidx.core.content.ContextCompat import com.github.pakka_papad.data.ZenCrashReporter import com.github.pakka_papad.data.daos.AlbumArtistDao import com.github.pakka_papad.data.daos.AlbumDao @@ -78,6 +81,17 @@ class SongExtractor( } } + private fun checkReadStoragePermission(): Boolean { + return ContextCompat.checkSelfPermission( + context, + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + Manifest.permission.READ_MEDIA_AUDIO + } else { + Manifest.permission.READ_EXTERNAL_STORAGE + } + ) == PackageManager.PERMISSION_GRANTED + } + private val projection = arrayOf( MediaStore.Audio.Media._ID, MediaStore.Audio.Media.TITLE, @@ -90,6 +104,7 @@ class SongExtractor( ) fun resolveSong(location: String): Song? { + if (!checkReadStoragePermission()) return null val selection = MediaStore.Audio.Media.DATA + " LIKE ?" val selectionArgs = arrayOf(location) val cursor = context.contentResolver.query( @@ -136,6 +151,7 @@ class SongExtractor( } suspend fun extract(folderPath: String? = null): List { + if (!checkReadStoragePermission()) return emptyList() val selection = MediaStore.Audio.Media.DATA + " LIKE ?" val selectionArgs = folderPath?.let { arrayOf("$it%") @@ -190,6 +206,7 @@ class SongExtractor( } fun extractMini(folderPath: String? = null): List { + if (!checkReadStoragePermission()) return emptyList() val projectionForMini = arrayOf( MediaStore.Audio.Media._ID, MediaStore.Audio.Media.TITLE, @@ -240,6 +257,7 @@ class SongExtractor( val scanStatus = _scanStatus.receiveAsFlow() fun scanForMusic() { + if (!checkReadStoragePermission()) return scope.launch { _scanStatus.send(ScanStatus.ScanStarted) val blacklistedSongLocations = blacklistDao From 230cfd8b228a087ceed13731042c875496cadf2a Mon Sep 17 00:00:00 2001 From: pakka-papad <76241334+pakka-papad@users.noreply.github.com> Date: Sun, 29 Sep 2024 18:52:45 +0530 Subject: [PATCH 02/19] Added: Read storage permission check in HomeFragment --- .../github/pakka_papad/home/HomeFragment.kt | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/github/pakka_papad/home/HomeFragment.kt b/app/src/main/java/com/github/pakka_papad/home/HomeFragment.kt index 2965997..a0d7d2b 100644 --- a/app/src/main/java/com/github/pakka_papad/home/HomeFragment.kt +++ b/app/src/main/java/com/github/pakka_papad/home/HomeFragment.kt @@ -1,8 +1,12 @@ package com.github.pakka_papad.home +import android.Manifest import android.app.PendingIntent import android.content.Intent +import android.net.Uri +import android.os.Build import android.os.Bundle +import android.provider.Settings import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -34,8 +38,10 @@ import androidx.compose.material3.LocalAbsoluteTonalElevation import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold import androidx.compose.material3.SheetValue +import androidx.compose.material3.SnackbarDuration import androidx.compose.material3.SnackbarHost import androidx.compose.material3.SnackbarHostState +import androidx.compose.material3.SnackbarResult import androidx.compose.material3.rememberBottomSheetScaffoldState import androidx.compose.material3.rememberStandardBottomSheetState import androidx.compose.material3.surfaceColorAtElevation @@ -64,6 +70,7 @@ import androidx.media3.exoplayer.ExoPlayer import androidx.navigation.NavController import androidx.navigation.fragment.findNavController import com.github.pakka_papad.Constants +import com.github.pakka_papad.R import com.github.pakka_papad.Screens import com.github.pakka_papad.components.BottomSheet import com.github.pakka_papad.components.Snackbar @@ -74,6 +81,9 @@ import com.github.pakka_papad.nowplaying.PlayerHelper import com.github.pakka_papad.nowplaying.Queue import com.github.pakka_papad.player.ZenBroadcastReceiver import com.github.pakka_papad.ui.theme.ZenTheme +import com.google.accompanist.permissions.ExperimentalPermissionsApi +import com.google.accompanist.permissions.isGranted +import com.google.accompanist.permissions.rememberPermissionState import com.google.accompanist.systemuicontroller.rememberSystemUiController import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.delay @@ -93,7 +103,7 @@ class HomeFragment : Fragment() { @OptIn( ExperimentalMaterial3Api::class, ExperimentalAnimationApi::class, - ExperimentalMaterialApi::class + ExperimentalMaterialApi::class, ExperimentalPermissionsApi::class ) override fun onCreateView( inflater: LayoutInflater, @@ -188,6 +198,32 @@ class HomeFragment : Fragment() { snackbarHostState.showSnackbar(message) } + val readStoragePermissionState = + rememberPermissionState( + permission = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + Manifest.permission.READ_MEDIA_AUDIO + } else { + Manifest.permission.READ_EXTERNAL_STORAGE + } + ) + + LaunchedEffect(key1 = readStoragePermissionState) { + if (readStoragePermissionState.status.isGranted) return@LaunchedEffect + val snackbarResult = snackbarHostState.showSnackbar( + context.getString(R.string.grant_access_to_read_storage), + context.getString(R.string.settings), + true, + SnackbarDuration.Indefinite + ) + if (snackbarResult != SnackbarResult.ActionPerformed) return@LaunchedEffect + Intent( + Settings.ACTION_APPLICATION_DETAILS_SETTINGS, + Uri.fromParts("package", context.packageName, null) + ).apply { + startActivity(this) + } + } + val bottomBarYOffset by remember { derivedStateOf { val progress = if (swipeableState.progress.from == 0) { From 71169a14e5b467ed4cd9db7d31594b49f596c6e4 Mon Sep 17 00:00:00 2001 From: pakka-papad <76241334+pakka-papad@users.noreply.github.com> Date: Sun, 29 Sep 2024 19:10:44 +0530 Subject: [PATCH 03/19] Added: ci.yaml --- .github/ci.yaml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/ci.yaml diff --git a/.github/ci.yaml b/.github/ci.yaml new file mode 100644 index 0000000..7819090 --- /dev/null +++ b/.github/ci.yaml @@ -0,0 +1,24 @@ +name: CI + +on: + push: + branches: [main, dev] + pull_request: + branches: [main, dev] + +jobs: + unit-test: + name: Perform Unit Testing + runs-on: ubuntu-latest + steps: + - name: Checkout the code + uses: actions/checkout@v2 + + - name: Run tests + uses: ./gradlew test + + - name: Upload test report + uses: actions.upload-artifact@v2 + with: + name: unit_test_report + path: app/build/reports/test/testDebugUnitTest/ \ No newline at end of file From 1ad7f00cda541beebc7505bd55deed126b1e7e07 Mon Sep 17 00:00:00 2001 From: pakka-papad <76241334+pakka-papad@users.noreply.github.com> Date: Sun, 29 Sep 2024 19:14:59 +0530 Subject: [PATCH 04/19] Added: ci.yaml --- .github/{ => workflows}/ci.yaml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{ => workflows}/ci.yaml (100%) diff --git a/.github/ci.yaml b/.github/workflows/ci.yaml similarity index 100% rename from .github/ci.yaml rename to .github/workflows/ci.yaml From 828f2c31010b58d9598845ca4e657c935afa2298 Mon Sep 17 00:00:00 2001 From: pakka-papad <76241334+pakka-papad@users.noreply.github.com> Date: Sun, 29 Sep 2024 19:18:47 +0530 Subject: [PATCH 05/19] Updated: ci.yaml --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7819090..85f4d47 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,7 +15,7 @@ jobs: uses: actions/checkout@v2 - name: Run tests - uses: ./gradlew test + run: ./gradlew test - name: Upload test report uses: actions.upload-artifact@v2 From b95aa95834fdb5a85a2683eb60660ffd5faec3ed Mon Sep 17 00:00:00 2001 From: pakka-papad <76241334+pakka-papad@users.noreply.github.com> Date: Sun, 29 Sep 2024 19:21:44 +0530 Subject: [PATCH 06/19] Updated: ci.yaml --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 85f4d47..70de1c6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,7 +18,7 @@ jobs: run: ./gradlew test - name: Upload test report - uses: actions.upload-artifact@v2 + uses: actions/upload-artifact@v2 with: name: unit_test_report path: app/build/reports/test/testDebugUnitTest/ \ No newline at end of file From 9a93fb7a7e82f11014a8da76b447727bffc4b30d Mon Sep 17 00:00:00 2001 From: pakka-papad <76241334+pakka-papad@users.noreply.github.com> Date: Sun, 29 Sep 2024 19:23:11 +0530 Subject: [PATCH 07/19] Updated: ci.yaml --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 70de1c6..4b12c66 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,7 +18,7 @@ jobs: run: ./gradlew test - name: Upload test report - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: unit_test_report path: app/build/reports/test/testDebugUnitTest/ \ No newline at end of file From ea95d853819c0143afe480833b613e053df0c6fd Mon Sep 17 00:00:00 2001 From: pakka-papad <76241334+pakka-papad@users.noreply.github.com> Date: Sun, 29 Sep 2024 19:25:10 +0530 Subject: [PATCH 08/19] Updated: ci.yaml --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4b12c66..263a1be 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout the code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Run tests run: ./gradlew test From 68dab0554f6084a2e9fcc7b5f61fe4f62f079dc9 Mon Sep 17 00:00:00 2001 From: pakka-papad <76241334+pakka-papad@users.noreply.github.com> Date: Sun, 29 Sep 2024 19:27:26 +0530 Subject: [PATCH 09/19] Updated: ci.yaml --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 263a1be..115120e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout the code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Run tests run: ./gradlew test From 26e31212d4b0d5ee6bcd4ce8921b175a571f8f54 Mon Sep 17 00:00:00 2001 From: pakka-papad <76241334+pakka-papad@users.noreply.github.com> Date: Sun, 29 Sep 2024 19:50:06 +0530 Subject: [PATCH 10/19] Updated: ci.yaml --- .github/workflows/ci.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 115120e..333d5e6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,7 +14,10 @@ jobs: - name: Checkout the code uses: actions/checkout@v4 - - name: Run tests + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Run unit tests run: ./gradlew test - name: Upload test report From 2bc080c2b66f7d211ee02b7bd246ae7c37c2ef4b Mon Sep 17 00:00:00 2001 From: pakka-papad <76241334+pakka-papad@users.noreply.github.com> Date: Wed, 2 Oct 2024 18:29:58 +0530 Subject: [PATCH 11/19] Updated: ci.yaml --- .github/workflows/ci.yaml | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 333d5e6..f5643cc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,11 +14,38 @@ jobs: - name: Checkout the code uses: actions/checkout@v4 + - name: Setup JDK + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: 17 + cache: 'gradle' + + - name: Load Google Service file + env: + DATA: ${{ secrets.GOOGLE_SERVICES_JSON }} + run: echo $DATA | base64 -di > app/google-services.json + + - name: Setup Local properties + env: + STORE_FILE: ${{ secrets.STORE_FILE }} + IR_STORE_FILE: ${{ secrets.IR_STORE_FILE }} + run: echo $STORE_FILE | base64 -di > keys/store_key.jks && \ + echo $IR_STORE_FILE | base64 -di > keys/ir_store_key.jks && \ + echo 'STORE_FILE=keys/store_key.jks' > ./local.properties && \ + echo 'STORE_PASSWORD=${{ secrets.STORE_PASSWORD }}' > ./local.properties && \ + echo 'KEY_ALIAS=${{ secrets.KEY_ALIAS }}' > ./local.properties && \ + echo 'KEY_PASSWORD=${{ secrets.KEY_PASSWORD }}' > ./local.properties && \ + echo 'IR_STORE_FILE=keys/ir_store_key.jks' > ./local.properties && \ + echo 'IR_STORE_PASSWORD=${{ secrets.IR_STORE_PASSWORD }}' > ./local.properties && \ + echo 'IR_KEY_ALIAS=${{ secrets.IR_KEY_ALIAS }}' > ./local.properties && \ + echo 'IR_KEY_PASSWORD=${{ secrets.IR_KEY_PASSWORD }}' > ./local.properties + - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Run unit tests - run: ./gradlew test + run: ./gradlew testDebug - name: Upload test report uses: actions/upload-artifact@v4 From 3b9bea7a2aa547555a39f5b41f3d52f9585ea1f9 Mon Sep 17 00:00:00 2001 From: pakka-papad <76241334+pakka-papad@users.noreply.github.com> Date: Wed, 2 Oct 2024 18:32:07 +0530 Subject: [PATCH 12/19] Updated: ci.yaml --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f5643cc..2cf60f8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,7 +15,7 @@ jobs: uses: actions/checkout@v4 - name: Setup JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: 17 From e7a98e1050153def75d971e80c126175b240504b Mon Sep 17 00:00:00 2001 From: pakka-papad <76241334+pakka-papad@users.noreply.github.com> Date: Wed, 2 Oct 2024 18:41:32 +0530 Subject: [PATCH 13/19] Updated: ci.yaml --- .github/workflows/ci.yaml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2cf60f8..ae57667 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -30,15 +30,16 @@ jobs: env: STORE_FILE: ${{ secrets.STORE_FILE }} IR_STORE_FILE: ${{ secrets.IR_STORE_FILE }} - run: echo $STORE_FILE | base64 -di > keys/store_key.jks && \ - echo $IR_STORE_FILE | base64 -di > keys/ir_store_key.jks && \ - echo 'STORE_FILE=keys/store_key.jks' > ./local.properties && \ - echo 'STORE_PASSWORD=${{ secrets.STORE_PASSWORD }}' > ./local.properties && \ - echo 'KEY_ALIAS=${{ secrets.KEY_ALIAS }}' > ./local.properties && \ - echo 'KEY_PASSWORD=${{ secrets.KEY_PASSWORD }}' > ./local.properties && \ - echo 'IR_STORE_FILE=keys/ir_store_key.jks' > ./local.properties && \ - echo 'IR_STORE_PASSWORD=${{ secrets.IR_STORE_PASSWORD }}' > ./local.properties && \ - echo 'IR_KEY_ALIAS=${{ secrets.IR_KEY_ALIAS }}' > ./local.properties && \ + run: mkdir keys && + echo $STORE_FILE | base64 -di > keys/store_key.jks && + echo $IR_STORE_FILE | base64 -di > keys/ir_store_key.jks && + echo 'STORE_FILE=keys/store_key.jks' > ./local.properties && + echo 'STORE_PASSWORD=${{ secrets.STORE_PASSWORD }}' > ./local.properties && + echo 'KEY_ALIAS=${{ secrets.KEY_ALIAS }}' > ./local.properties && + echo 'KEY_PASSWORD=${{ secrets.KEY_PASSWORD }}' > ./local.properties && + echo 'IR_STORE_FILE=keys/ir_store_key.jks' > ./local.properties && + echo 'IR_STORE_PASSWORD=${{ secrets.IR_STORE_PASSWORD }}' > ./local.properties && + echo 'IR_KEY_ALIAS=${{ secrets.IR_KEY_ALIAS }}' > ./local.properties && echo 'IR_KEY_PASSWORD=${{ secrets.IR_KEY_PASSWORD }}' > ./local.properties - name: Grant execute permission for gradlew From 0c5e95afa52fc825e71f0d822d5ba36079efb15e Mon Sep 17 00:00:00 2001 From: pakka-papad <76241334+pakka-papad@users.noreply.github.com> Date: Wed, 2 Oct 2024 18:55:12 +0530 Subject: [PATCH 14/19] Updated: ci.yaml --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ae57667..0fc5cbb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -33,11 +33,11 @@ jobs: run: mkdir keys && echo $STORE_FILE | base64 -di > keys/store_key.jks && echo $IR_STORE_FILE | base64 -di > keys/ir_store_key.jks && - echo 'STORE_FILE=keys/store_key.jks' > ./local.properties && + echo 'STORE_FILE=${{ github.workspace }}/keys/store_key.jks' > ./local.properties && echo 'STORE_PASSWORD=${{ secrets.STORE_PASSWORD }}' > ./local.properties && echo 'KEY_ALIAS=${{ secrets.KEY_ALIAS }}' > ./local.properties && echo 'KEY_PASSWORD=${{ secrets.KEY_PASSWORD }}' > ./local.properties && - echo 'IR_STORE_FILE=keys/ir_store_key.jks' > ./local.properties && + echo 'IR_STORE_FILE=${{ github.workspace }}/keys/ir_store_key.jks' > ./local.properties && echo 'IR_STORE_PASSWORD=${{ secrets.IR_STORE_PASSWORD }}' > ./local.properties && echo 'IR_KEY_ALIAS=${{ secrets.IR_KEY_ALIAS }}' > ./local.properties && echo 'IR_KEY_PASSWORD=${{ secrets.IR_KEY_PASSWORD }}' > ./local.properties From 61e3bc375e7321cb3cef8a0bbef1a82d535ad790 Mon Sep 17 00:00:00 2001 From: pakka-papad <76241334+pakka-papad@users.noreply.github.com> Date: Wed, 2 Oct 2024 19:14:16 +0530 Subject: [PATCH 15/19] Updated: ci.yaml --- .github/workflows/ci.yaml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0fc5cbb..09b2e77 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -32,15 +32,15 @@ jobs: IR_STORE_FILE: ${{ secrets.IR_STORE_FILE }} run: mkdir keys && echo $STORE_FILE | base64 -di > keys/store_key.jks && - echo $IR_STORE_FILE | base64 -di > keys/ir_store_key.jks && - echo 'STORE_FILE=${{ github.workspace }}/keys/store_key.jks' > ./local.properties && - echo 'STORE_PASSWORD=${{ secrets.STORE_PASSWORD }}' > ./local.properties && - echo 'KEY_ALIAS=${{ secrets.KEY_ALIAS }}' > ./local.properties && - echo 'KEY_PASSWORD=${{ secrets.KEY_PASSWORD }}' > ./local.properties && - echo 'IR_STORE_FILE=${{ github.workspace }}/keys/ir_store_key.jks' > ./local.properties && - echo 'IR_STORE_PASSWORD=${{ secrets.IR_STORE_PASSWORD }}' > ./local.properties && - echo 'IR_KEY_ALIAS=${{ secrets.IR_KEY_ALIAS }}' > ./local.properties && - echo 'IR_KEY_PASSWORD=${{ secrets.IR_KEY_PASSWORD }}' > ./local.properties + echo $IR_STORE_FILE | base64 -di > keys/ir_store_key.jks && + echo 'STORE_FILE=${{ github.workspace }}/keys/store_key.jks + STORE_PASSWORD=${{ secrets.STORE_PASSWORD }} + KEY_ALIAS=${{ secrets.KEY_ALIAS }} + KEY_PASSWORD=${{ secrets.KEY_PASSWORD }} + IR_STORE_FILE=${{ github.workspace }}/keys/ir_store_key.jks + IR_STORE_PASSWORD=${{ secrets.IR_STORE_PASSWORD }} + IR_KEY_ALIAS=${{ secrets.IR_KEY_ALIAS }} + IR_KEY_PASSWORD=${{ secrets.IR_KEY_PASSWORD }}' > ./local.properties - name: Grant execute permission for gradlew run: chmod +x gradlew From fc9635d655820ed7e6c7a24331a090a7fb4ce915 Mon Sep 17 00:00:00 2001 From: pakka-papad <76241334+pakka-papad@users.noreply.github.com> Date: Wed, 2 Oct 2024 19:18:38 +0530 Subject: [PATCH 16/19] Updated: ci.yaml --- .github/workflows/ci.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 09b2e77..bfa3f7e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -33,14 +33,14 @@ jobs: run: mkdir keys && echo $STORE_FILE | base64 -di > keys/store_key.jks && echo $IR_STORE_FILE | base64 -di > keys/ir_store_key.jks && - echo 'STORE_FILE=${{ github.workspace }}/keys/store_key.jks - STORE_PASSWORD=${{ secrets.STORE_PASSWORD }} - KEY_ALIAS=${{ secrets.KEY_ALIAS }} - KEY_PASSWORD=${{ secrets.KEY_PASSWORD }} - IR_STORE_FILE=${{ github.workspace }}/keys/ir_store_key.jks - IR_STORE_PASSWORD=${{ secrets.IR_STORE_PASSWORD }} - IR_KEY_ALIAS=${{ secrets.IR_KEY_ALIAS }} - IR_KEY_PASSWORD=${{ secrets.IR_KEY_PASSWORD }}' > ./local.properties + echo $'STORE_FILE=${{ github.workspace }}/keys/store_key.jks\n + STORE_PASSWORD=${{ secrets.STORE_PASSWORD }}\n + KEY_ALIAS=${{ secrets.KEY_ALIAS }}\n + KEY_PASSWORD=${{ secrets.KEY_PASSWORD }}\n + IR_STORE_FILE=${{ github.workspace }}/keys/ir_store_key.jks\n + IR_STORE_PASSWORD=${{ secrets.IR_STORE_PASSWORD }}\n + IR_KEY_ALIAS=${{ secrets.IR_KEY_ALIAS }}\n + IR_KEY_PASSWORD=${{ secrets.IR_KEY_PASSWORD }}\n' > ./local.properties - name: Grant execute permission for gradlew run: chmod +x gradlew From 180b1554b0f43afce58256bd7f0db5be5505ae5a Mon Sep 17 00:00:00 2001 From: pakka-papad <76241334+pakka-papad@users.noreply.github.com> Date: Wed, 2 Oct 2024 21:02:56 +0530 Subject: [PATCH 17/19] Updated: unit-test.yml Added: build-apk.yml --- .github/workflows/build-apk.yml | 60 ++++++++++++++++++++ .github/workflows/{ci.yaml => unit-test.yml} | 8 +-- 2 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/build-apk.yml rename .github/workflows/{ci.yaml => unit-test.yml} (94%) diff --git a/.github/workflows/build-apk.yml b/.github/workflows/build-apk.yml new file mode 100644 index 0000000..60899b1 --- /dev/null +++ b/.github/workflows/build-apk.yml @@ -0,0 +1,60 @@ +name: build-apk + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build: + name: Build IR apk + runs-on: ubuntu-latest + needs: [unit-test] + + steps: + - name: Checkout the code + uses: actions/checkout@v4 + + - name: Setup JDK + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 17 + cache: 'gradle' + + - name: Load Google Service file + env: + DATA: ${{ secrets.GOOGLE_SERVICES_JSON }} + run: echo $DATA | base64 -di > app/google-services.json + + - name: Setup Local properties + env: + STORE_FILE: ${{ secrets.STORE_FILE }} + IR_STORE_FILE: ${{ secrets.IR_STORE_FILE }} + run: mkdir keys && + echo $STORE_FILE | base64 -di > keys/store_key.jks && + echo $IR_STORE_FILE | base64 -di > keys/ir_store_key.jks && + echo $'STORE_FILE=${{ github.workspace }}/keys/store_key.jks\n + STORE_PASSWORD=${{ secrets.STORE_PASSWORD }}\n + KEY_ALIAS=${{ secrets.KEY_ALIAS }}\n + KEY_PASSWORD=${{ secrets.KEY_PASSWORD }}\n + IR_STORE_FILE=${{ github.workspace }}/keys/ir_store_key.jks\n + IR_STORE_PASSWORD=${{ secrets.IR_STORE_PASSWORD }}\n + IR_KEY_ALIAS=${{ secrets.IR_KEY_ALIAS }}\n + IR_KEY_PASSWORD=${{ secrets.IR_KEY_PASSWORD }}\n' > ./local.properties + + - name: Setup Gradle + uses: gradle/gradle-build-action@v3 + + - name: Build apk + run: ./gradlew assembleInternalRelease + + - name: Rename apk + run: mv ./app/build/outputs/apk/internalRelease/app-internalRelease.apk ./app/build/outputs/apk/internalRelease/zen-music-ir-build-${{ github.run_number }}.apk + + - name: Upload apk + uses: actions/upload-artifact@v4 + with: + name: zen-music-ir-build-${{ github.run_number }}.apk + path: app/build/outputs/apk/internalRelease/ diff --git a/.github/workflows/ci.yaml b/.github/workflows/unit-test.yml similarity index 94% rename from .github/workflows/ci.yaml rename to .github/workflows/unit-test.yml index bfa3f7e..b9cc335 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/unit-test.yml @@ -1,4 +1,4 @@ -name: CI +name: unit-test on: push: @@ -7,7 +7,7 @@ on: branches: [main, dev] jobs: - unit-test: + test: name: Perform Unit Testing runs-on: ubuntu-latest steps: @@ -42,8 +42,8 @@ jobs: IR_KEY_ALIAS=${{ secrets.IR_KEY_ALIAS }}\n IR_KEY_PASSWORD=${{ secrets.IR_KEY_PASSWORD }}\n' > ./local.properties - - name: Grant execute permission for gradlew - run: chmod +x gradlew + - name: Setup Gradle + uses: gradle/gradle-build-action@v3 - name: Run unit tests run: ./gradlew testDebug From 5d168d411b71c24b64d231107483ee8cd2584087 Mon Sep 17 00:00:00 2001 From: pakka-papad <76241334+pakka-papad@users.noreply.github.com> Date: Wed, 2 Oct 2024 21:05:45 +0530 Subject: [PATCH 18/19] Updated: unit-test.yml Updated: build-apk.yml --- .github/workflows/build-apk.yml | 3 +++ .github/workflows/unit-test.yml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/build-apk.yml b/.github/workflows/build-apk.yml index 60899b1..6d9919b 100644 --- a/.github/workflows/build-apk.yml +++ b/.github/workflows/build-apk.yml @@ -44,6 +44,9 @@ jobs: IR_KEY_ALIAS=${{ secrets.IR_KEY_ALIAS }}\n IR_KEY_PASSWORD=${{ secrets.IR_KEY_PASSWORD }}\n' > ./local.properties + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Setup Gradle uses: gradle/gradle-build-action@v3 diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index b9cc335..83bdac7 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -42,6 +42,9 @@ jobs: IR_KEY_ALIAS=${{ secrets.IR_KEY_ALIAS }}\n IR_KEY_PASSWORD=${{ secrets.IR_KEY_PASSWORD }}\n' > ./local.properties + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Setup Gradle uses: gradle/gradle-build-action@v3 From 9f9a7095ccdfc5c423fbbc0162662ae236ad7588 Mon Sep 17 00:00:00 2001 From: pakka-papad <76241334+pakka-papad@users.noreply.github.com> Date: Wed, 2 Oct 2024 21:13:52 +0530 Subject: [PATCH 19/19] Updated: unit-test.yml Updated: build-apk.yml --- .github/workflows/build-apk.yml | 2 +- .github/workflows/unit-test.yml | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-apk.yml b/.github/workflows/build-apk.yml index 6d9919b..113d138 100644 --- a/.github/workflows/build-apk.yml +++ b/.github/workflows/build-apk.yml @@ -48,7 +48,7 @@ jobs: run: chmod +x gradlew - name: Setup Gradle - uses: gradle/gradle-build-action@v3 + uses: gradle/actions/setup-gradle@v4 - name: Build apk run: ./gradlew assembleInternalRelease diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 83bdac7..d146357 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -46,13 +46,7 @@ jobs: run: chmod +x gradlew - name: Setup Gradle - uses: gradle/gradle-build-action@v3 + uses: gradle/actions/setup-gradle@v4 - name: Run unit tests - run: ./gradlew testDebug - - - name: Upload test report - uses: actions/upload-artifact@v4 - with: - name: unit_test_report - path: app/build/reports/test/testDebugUnitTest/ \ No newline at end of file + run: ./gradlew testDebug \ No newline at end of file