Skip to content

Commit

Permalink
Setup CI for test and lint check (#2)
Browse files Browse the repository at this point in the history
* Add GitHub actions
  • Loading branch information
cp-radhika-s authored Jan 11, 2024
1 parent 65e3f85 commit 2551520
Show file tree
Hide file tree
Showing 43 changed files with 154 additions and 245 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Android Build

on: [ push ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: set up JDK 17
uses: actions/setup-java@v2
with:
distribution: adopt
java-version: 17

- name: Retrieve the secret and decode it to a file
env:
GOOGLE_SERVICES_JSON_BASE64: ${{ secrets.GOOGLE_SERVICES_JSON_BASE64 }}
DEBUG_KEYSTORE_BASE64: ${{ secrets.DEBUG_KEYSTORE_BASE64 }}

run: |
echo $GOOGLE_SERVICES_JSON_BASE64 | base64 -di > app/google-services.json
echo $DEBUG_KEYSTORE_BASE64 | base64 -di > app/debug.keystore
- name: Build with Gradle
run: ./gradlew build

- name: Run Tests with Gradle
run: ./gradlew test

- name: Run Lint check
run: ./gradlew ktlintCheck
16 changes: 9 additions & 7 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
id("com.google.dagger.hilt.android")
id("kotlin-kapt")
id("com.google.gms.google-services")
id("org.jlleitschuh.gradle.ktlint")
}

android {
Expand Down Expand Up @@ -32,7 +33,6 @@ android {
}
}


buildTypes {
release {
isMinifyEnabled = true
Expand Down Expand Up @@ -69,6 +69,9 @@ android {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
ktlint {
debug = true
}
}

dependencies {
Expand All @@ -84,7 +87,7 @@ dependencies {
implementation("androidx.navigation:navigation-compose:2.7.6")
implementation("androidx.hilt:hilt-navigation-compose:1.1.0")

//Test
// Test
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
Expand All @@ -102,20 +105,19 @@ dependencies {
implementation("com.google.dagger:hilt-android:$hilt")
kapt("com.google.dagger:hilt-compiler:$hilt")

//DataStore
// DataStore
implementation("androidx.datastore:datastore-preferences:1.0.0")

// Firebase
implementation(platform("com.google.firebase:firebase-bom:32.7.0"))
implementation("com.google.firebase:firebase-auth")
implementation("com.google.android.gms:play-services-auth:20.7.0")


//Timber
// Timber
implementation("com.jakewharton.timber:timber:5.0.1")

//country-picker
// country-picker
implementation("com.canopas.jetcountrypicker:jetcountrypicker:1.0.9")

implementation(project(":data"))
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ class CatchMeApplication : Application() {
super.onCreate()
Timber.plant(Timber.DebugTree())
}
}
}
4 changes: 1 addition & 3 deletions app/src/main/java/com/canopas/catchme/di/AppDataProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,4 @@ class AppDataProvider {
@Provides
@Singleton
fun provideAppDispatcher() = AppDispatcher()


}
}
2 changes: 1 addition & 1 deletion app/src/main/java/com/canopas/catchme/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ class MainActivity : ComponentActivity() {
}
}
}
}
}
2 changes: 0 additions & 2 deletions app/src/main/java/com/canopas/catchme/ui/MainApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ fun MainApp() {
IntroScreen()
}
slideComposable(AppDestinations.signIn.path) {

val result = navController.currentBackStackEntry
?.savedStateHandle?.get<Int>(KEY_RESULT)
result?.let {
Expand Down Expand Up @@ -102,7 +101,6 @@ fun AppRouter(navController: NavHostController, navActions: SharedFlow<NavAction
}
}
}

}
}
}
3 changes: 0 additions & 3 deletions app/src/main/java/com/canopas/catchme/ui/MainViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import com.canopas.catchme.data.storage.UserPreferences
import com.canopas.catchme.ui.navigation.AppDestinations
import com.canopas.catchme.ui.navigation.AppNavigator
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
import javax.inject.Inject

Expand All @@ -31,4 +29,3 @@ class MainViewModel @Inject constructor(
}
}
}

17 changes: 10 additions & 7 deletions app/src/main/java/com/canopas/catchme/ui/component/AppBanner.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ fun AppBanner(msg: String, onDismiss: (() -> Unit)? = {}) {
properties = PopupProperties(
dismissOnBackPress = false,
dismissOnClickOutside = false
), onDismissRequest = { onDismiss?.invoke() }
),
onDismissRequest = { onDismiss?.invoke() }
) {

AnimatedVisibility(
visible = show,
enter = fadeIn() + slideInVertically(
initialOffsetY = { -it }),
exit = slideOutVertically(targetOffsetY = { -it }),
initialOffsetY = { -it }
),
exit = slideOutVertically(targetOffsetY = { -it })
) {
Box(
modifier = Modifier
Expand All @@ -58,14 +59,16 @@ fun AppBanner(msg: String, onDismiss: (() -> Unit)? = {}) {
.background(
color = AppTheme.colorScheme.primary
)
.padding(16.dp), contentAlignment = Alignment.CenterStart
.padding(16.dp),
contentAlignment = Alignment.CenterStart
) {
Text(
text = msg,
style = AppTheme.appTypography.label1.copy(color = AppTheme.colorScheme.onPrimary),
maxLines = 4, overflow = TextOverflow.Ellipsis
maxLines = 4,
overflow = TextOverflow.Ellipsis
)
}
}
}
}
}
6 changes: 3 additions & 3 deletions app/src/main/java/com/canopas/catchme/ui/component/AppLogo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fun AppLogo(colorTint: Color = colorScheme.primary) {
style = AppTheme.appTypography.logo
.copy(
color = colorTint,
fontFamily = KalamBoldFont,
),
fontFamily = KalamBoldFont
)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ import com.canopas.catchme.ui.theme.AppTheme

@Composable
fun AppProgressIndicator(color: Color = AppTheme.colorScheme.primary) {

CircularProgressIndicator(
color = color,
modifier = Modifier
.height(20.dp)
.width(20.dp)
)

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ import com.canopas.catchme.ui.navigation.AppDestinations
import com.canopas.catchme.ui.navigation.AppNavigator
import com.google.android.gms.auth.api.signin.GoogleSignInAccount
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
import kotlinx.coroutines.tasks.await
import timber.log.Timber
import javax.inject.Inject

Expand Down Expand Up @@ -68,4 +66,3 @@ data class SignInMethodScreenState(
val showGoogleLoading: Boolean = false,
val error: String? = null
)

Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ private fun SignInAppBar() {
style = AppTheme.appTypography.label1.copy(color = AppTheme.colorScheme.textPrimary)
)
}
})
}
)
}

@Composable
Expand Down Expand Up @@ -129,7 +130,7 @@ private fun PhoneLoginBtn(onClick: () -> Unit) {
.fillMaxWidth(fraction = 0.8f),
shape = RoundedCornerShape(50),
colors = ButtonDefaults.buttonColors(
containerColor = AppTheme.colorScheme.primary,
containerColor = AppTheme.colorScheme.primary
)
) {
Text(
Expand All @@ -138,7 +139,6 @@ private fun PhoneLoginBtn(onClick: () -> Unit) {
textAlign = TextAlign.Center,
modifier = Modifier.padding(vertical = 6.dp)
)

}
}

Expand Down Expand Up @@ -177,7 +177,7 @@ private fun GoogleSignInBtn() {
.fillMaxWidth(fraction = 0.8f),
shape = RoundedCornerShape(50),
colors = ButtonDefaults.buttonColors(
containerColor = Color.White,
containerColor = Color.White
)
) {
if (state.showGoogleLoading) {
Expand All @@ -204,4 +204,4 @@ fun PreviewSignInView() {
CatchMeTheme {
SignInMethodsScreen()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private fun PhoneSignInAppBar(onBackPressed: () -> Unit = {}) {
@OptIn(ExperimentalComposeUiApi::class, ExperimentalMaterial3Api::class)
@Composable
private fun PhoneLoginContent(
modifier: Modifier,
modifier: Modifier
) {
val context = LocalContext.current
val manager = context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
Expand All @@ -126,8 +126,11 @@ private fun PhoneLoginContent(
val countryLanCode = manager.networkCountryIso.uppercase()
LaunchedEffect(key1 = Unit) {
val countryCode =
if (countryLanCode.isNotEmpty()) countryList(context).single { it.code == countryLanCode }.dial_code else
if (countryLanCode.isNotEmpty()) {
countryList(context).single { it.code == countryLanCode }.dial_code
} else {
countryList(context).first().dial_code
}
viewModel.onCodeChange(countryCode)
}

Expand Down Expand Up @@ -160,7 +163,6 @@ private fun PhoneLoginContent(
}
}


if (state.showCountryPicker) {
val modalBottomSheetState = rememberModalBottomSheetState(skipPartiallyExpanded = false)

Expand Down Expand Up @@ -211,7 +213,8 @@ private fun PhoneTextField() {
modifier = Modifier
.clickable(
indication = null,
interactionSource = remember { MutableInteractionSource() }) {
interactionSource = remember { MutableInteractionSource() }
) {
viewModel.showCountryPicker()
},
verticalAlignment = Alignment.CenterVertically
Expand Down Expand Up @@ -276,7 +279,6 @@ private fun PhoneTextField() {
)
}
}

}

@Composable
Expand All @@ -303,19 +305,19 @@ private fun TitleContent() {

@Composable
private fun NextBtn(enable: Boolean, isVerifying: Boolean, onClick: () -> Unit) {

Button(
onClick = onClick,
modifier = Modifier
.fillMaxWidth(fraction = 0.9f),
shape = RoundedCornerShape(50),
colors = ButtonDefaults.buttonColors(
containerColor = AppTheme.colorScheme.primary,
containerColor = AppTheme.colorScheme.primary
),
enabled = enable,
enabled = enable
) {
if (isVerifying)
if (isVerifying) {
AppProgressIndicator(color = AppTheme.colorScheme.onPrimary)
}

Text(
text = stringResource(R.string.phone_sign_in_btn_next),
Expand Down Expand Up @@ -345,4 +347,4 @@ fun textFieldColors(): TextFieldColors {
@Composable
fun PreviewPhoneSignInView() {
SignInWithPhoneScreen()
}
}
Loading

0 comments on commit 2551520

Please sign in to comment.