Skip to content

Commit

Permalink
Setup checking tests on ci
Browse files Browse the repository at this point in the history
  • Loading branch information
egorikftp committed Oct 10, 2024
1 parent d24031b commit d7c3250
Show file tree
Hide file tree
Showing 17 changed files with 115 additions and 96 deletions.
34 changes: 33 additions & 1 deletion .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ "develop" ]

jobs:
build:
android-test:
runs-on: ubuntu-latest

steps:
Expand All @@ -21,8 +21,40 @@ jobs:
java-version: 17
cache: gradle

- name: Copy google-services.json
run: echo ${{ secrets.GOOGLE_JSON }} | base64 --decode > app/android/google-services.json

- name: Make secrets.properties
run: echo ${{ secrets.SECRETS_PROPERTIES }} | base64 --decode > secrets.properties

- name: Spotless check
run: ./gradlew spotlessCheck

- name: Run Android tests
run: ./gradlew testDebugUnitTest

- name: Build Android app
run: ./gradlew app:android:assembleDebug

- name: Build UI Demo app
run: ./gradlew app:ui-demo:assembleDebug

# ios-test:
# runs-on: macos-latest
#
# steps:
# - name: Checkout
# uses: actions/checkout@v4
#
# - name: set up JDK 17
# uses: actions/setup-java@v4
# with:
# distribution: temurin
# java-version: 17
# cache: gradle
#
# - name: Make secrets.properties
# run: echo ${{ secrets.SECRETS_PROPERTIES }} | base64 --decode > secrets.properties
#
# - name: Run iOS tests
# run: ./gradlew iosSimulatorArm64Test
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ In case bug and suggestions, please create issue.

### Useful gradle commands

Check dependency updates: `./gradlew dependencyUpdates`
Update code style: `./gradlew spotlessApply`

Run compose metrics: `./gradlew app:android:assembleRelease -PenableComposeCompilerReports=true`
Check code style: `./gradlew spotlessCheck`

Run compose metrics: `./gradlew app:android:assembleRelease -PenableComposeCompilerReports=true`

Generate kmp buildconfig: `./gradlew :kmp:shared:components:generateBuildKonfig`

Expand All @@ -46,4 +48,4 @@ Build app release: `./gradlew app:android:assembleRelease`

Pods:
remove pod: `pod deintegrate`
init pod: `pod install`
init pod: `pod install`
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ minSdk = "23" # Android 6.0
targetSdk = "34"

agp = "8.7.0"
coil = "3.0.0-rc01"
coil = "3.0.0-alpha10"
decompose = "3.1.0"
essenty = "2.1.0"
kotlinx-serialization = "1.7.3"
Expand All @@ -24,7 +24,7 @@ androidx-datastore = "androidx.datastore:datastore-preferences:1.1.1"
androidx-datastore-core = "androidx.datastore:datastore-preferences-core:1.1.1"
androidx-media = "androidx.media:media:1.7.0"

balloon-compose = "com.github.skydoves:balloon-compose:1.6.8"
balloon-compose = "com.github.skydoves:balloon-compose:1.6.7"

coil = { module = "io.coil-kt.coil3:coil-compose", version.ref = "coil" }
coil-network-ktor = "io.coil-kt.coil3:coil-network-ktor:3.0.0-alpha08"
Expand Down Expand Up @@ -100,4 +100,4 @@ spotless = "com.diffplug.spotless:7.0.0.BETA2"
# Project conventional plugins
grodnoroads-application = { id = "grodnoroads.application", version = "unspecified" }
grodnoroads-kmp-compose = { id = "grodnoroads.kmp.compose", version = "unspecified" }
grodnoroads-kmp-library = { id = "grodnoroads.kmp.library", version = "unspecified" }
grodnoroads-kmp-library = { id = "grodnoroads.kmp.library", version = "unspecified" }
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.runtime.setValue
import com.egoriku.grodnoroads.foundation.core.rememberMutableState
import com.egoriku.grodnoroads.location.LatLng
import com.egoriku.grodnoroads.maps.compose.core.Marker
import com.egoriku.grodnoroads.maps.compose.core.remove
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,12 @@ import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.BottomSheetDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.SheetState
import androidx.compose.material3.contentColorFor
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.unit.Dp
import com.egoriku.grodnoroads.foundation.theme.tonalElevation
import com.egoriku.grodnoroads.foundation.common.ui.bottomsheet.ModalBottomSheet

@OptIn(ExperimentalMaterial3Api::class)
@Composable
Expand All @@ -28,12 +23,7 @@ fun <T> ModalBottomSheet(
modifier: Modifier = Modifier,
sheetState: SheetState = rememberModalBottomSheetState(),
shape: Shape = BottomSheetDefaults.ExpandedShape,
containerColor: Color = BottomSheetDefaults.ContainerColor,
contentColor: Color = contentColorFor(containerColor),
tonalElevation: Dp = MaterialTheme.tonalElevation,
scrimColor: Color = BottomSheetDefaults.ScrimColor,
dragHandle: @Composable (() -> Unit)? = { BottomSheetDefaults.DragHandle() },
windowInsets: WindowInsets = WindowInsets(0, 0, 0, 0),
content: @Composable ColumnScope.(T) -> Unit
) {
if (data != null) {
Expand All @@ -44,12 +34,7 @@ fun <T> ModalBottomSheet(
onDismissRequest = onDismissRequest,
sheetState = sheetState,
shape = shape,
containerColor = containerColor,
contentColor = contentColor,
tonalElevation = tonalElevation,
scrimColor = scrimColor,
dragHandle = dragHandle,
windowInsets = windowInsets
dragHandle = dragHandle
) {
Column(modifier = Modifier.padding(bottom = bottomPadding)) {
content(data)
Expand Down
5 changes: 1 addition & 4 deletions kmp/features/settings/changelog/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import com.egoriku.grodnoroads.extension.applyTargets
import com.egoriku.grodnoroads.extension.commonDependencies
import com.egoriku.grodnoroads.extension.commonTestDependencies

plugins {
alias(libs.plugins.grodnoroads.kmp.library)
Expand All @@ -21,6 +20,7 @@ kotlin {
implementation(projects.kmp.compose.foundation.uikit)
implementation(projects.kmp.compose.resources)
implementation(projects.kmp.shared.crashlytics)
implementation(projects.kmp.shared.formatter)
implementation(projects.kmp.libraries.coroutines)
implementation(projects.kmp.libraries.extensions)

Expand All @@ -32,8 +32,5 @@ kotlin {
implementation(libs.mvikotlin.extensions)
implementation(libs.mvikotlin.main)
}
commonTestDependencies {
implementation(libs.kotlin.test)
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import com.egoriku.grodnoroads.extensions.common.ResultOf
import com.egoriku.grodnoroads.settings.changelog.data.dto.ChangelogDTO
import com.egoriku.grodnoroads.settings.changelog.domain.model.ReleaseNotes
import com.egoriku.grodnoroads.settings.changelog.domain.repository.ChangelogRepository
import com.egoriku.grodnoroads.settings.changelog.domain.util.DateFormatter
import com.egoriku.grodnoroads.shared.formatter.ChangelogFormatter
import dev.gitlive.firebase.firestore.Direction
import dev.gitlive.firebase.firestore.FirebaseFirestore
import kotlin.time.Duration.Companion.seconds
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.IO
import kotlinx.coroutines.withContext
Expand All @@ -15,8 +16,6 @@ internal class ChangelogRepositoryImpl(
private val firestore: FirebaseFirestore
) : ChangelogRepository {

private val formatter = DateFormatter()

override suspend fun load() = withContext(Dispatchers.IO) {
runCatching {
val changelog = firestore
Expand All @@ -33,7 +32,9 @@ internal class ChangelogRepositoryImpl(
versionCode = it.code,
versionName = it.name,
notes = it.notes.replace("\\n", "\n"),
releaseDate = formatter.formatTime(it.releaseDate.seconds)
releaseDate = ChangelogFormatter.format(
timestamp = it.releaseDate.seconds.seconds.inWholeMilliseconds
)
)
}
)
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ class DateTimeTest {
@Test
fun formatTest() {
assertEquals(
"8:06",
DateTime.formatToTime((8.hours + 6.minutes).inWholeMilliseconds)
expected = "8:06",
actual = DateTime.formatToTime((8.hours + 6.minutes).inWholeMilliseconds)
)
assertEquals(
"17:09",
DateTime.formatToTime((17.hours + 9.minutes).inWholeMilliseconds)
expected = "17:09",
actual = DateTime.formatToTime((17.hours + 9.minutes).inWholeMilliseconds)
)

val date = LocalDateTime(
Expand All @@ -36,8 +36,8 @@ class DateTimeTest {
second = 12
).toInstant(TimeZone.UTC).toEpochMilliseconds()
assertEquals(
"17:09",
DateTime.formatToTime(date)
expected = "17:09",
actual = DateTime.formatToTime(date)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ actual typealias PlatformLatLng = com.google.android.gms.maps.model.LatLng

fun PlatformLatLng.toLatLng() = LatLng(this)

actual class LatLng actual constructor(val platform: PlatformLatLng) {
actual data class LatLng actual constructor(val platform: PlatformLatLng) {
actual val latitude: Double
get() = platform.latitude

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fun CValue<CLLocationCoordinate2D>.toLatLng() = LatLng(IOSLatLng(this))
class IOSLatLng(val cValue: CValue<CLLocationCoordinate2D>)

@OptIn(ExperimentalForeignApi::class)
actual class LatLng actual constructor(private val platform: PlatformLatLng) {
actual data class LatLng actual constructor(private val platform: PlatformLatLng) {
actual val latitude: Double
get() = platform.cValue.useContents { latitude }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import kotlinx.datetime.toLocalDateTime

object CameraFormatter {

private var defaultTimeZone = TimeZone.of("Europe/Minsk")
private val defaultTimeZone = TimeZone.of("Europe/Minsk")
private val dateTimeFormat = LocalDateTime.Format {
dayOfMonth()
char('.')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.egoriku.grodnoroads.shared.formatter

import kotlinx.datetime.Instant
import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.TimeZone
import kotlinx.datetime.format
import kotlinx.datetime.format.MonthNames
import kotlinx.datetime.format.Padding
import kotlinx.datetime.format.char
import kotlinx.datetime.toLocalDateTime

object ChangelogFormatter {

private val defaultTimeZone = TimeZone.of("Europe/Minsk")
private val dayMonthYearFormatter = LocalDateTime.Format {
dayOfMonth(padding = Padding.NONE)
char(' ')
monthName(MonthNames.ENGLISH_FULL)
char(',')
char(' ')
year()
}

fun format(timestamp: Long): String =
Instant.fromEpochMilliseconds(timestamp)
.toLocalDateTime(defaultTimeZone)
.format(dayMonthYearFormatter)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.egoriku.grodnoroads.shared.formatter

import kotlin.test.Test
import kotlin.test.assertEquals
import kotlinx.datetime.LocalDate
import kotlinx.datetime.TimeZone
import kotlinx.datetime.atStartOfDayIn

class ChangelogFormatterTest {

@Test
fun formatterTest() {
assertEquals(
expected = "10 March, 2023",
actual = ChangelogFormatter.format(1678395600000)
)
assertEquals(
expected = "5 January, 2023",
actual = ChangelogFormatter.format(
timestamp = LocalDate(
year = 2023,
monthNumber = 1,
dayOfMonth = 5
).atStartOfDayIn(TimeZone.UTC).toEpochMilliseconds()
)
)
}
}

0 comments on commit d7c3250

Please sign in to comment.