Skip to content

Commit

Permalink
Merge pull request #14 from shinhyo/feat_core_testing
Browse files Browse the repository at this point in the history
Feat core testing
  • Loading branch information
shinhyo authored Aug 27, 2024
2 parents a5c42ef + 9743344 commit 8f9c6ab
Show file tree
Hide file tree
Showing 81 changed files with 928 additions and 316 deletions.
30 changes: 25 additions & 5 deletions .github/workflows/Build.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name: Build

on:
push:
pull_request:
branches:
- develop
pull_request:

concurrency:
group: build-${{ github.ref }}
Expand All @@ -13,7 +12,7 @@ concurrency:
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 60
timeout-minutes: 30

steps:
- name: Checkout
Expand Down Expand Up @@ -51,9 +50,30 @@ jobs:
- name: Check Spotless
run: ./gradlew spotlessCheck --init-script gradle/init.gradle.kts --no-configuration-cache --stacktrace

- name: Upload build reports
- name: UnitTest
run: |
./gradlew testDebugUnitTest --stacktrace
- name: Check Kover
run: |
./gradlew koverXmlReportDebug
- name: Display local test coverage
uses: madrapps/jacoco-report@v1.6.1
with:
title: test coverage report
min-coverage-overall: 40
min-coverage-changed-files: 60
update-comment: true
skip-if-no-changes: true
continue-on-error: false
paths: |
${{ github.workspace }}/feature/**/build/reports/kover/reportDebug.xml
token: ${{ secrets.GITHUB_TOKEN }}

- name: Upload lint reports
if: always()
uses: actions/upload-artifact@v3
with:
name: build-reports
path: app/build/reports
path: app/build/reports
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ build/
app/build
build
/.kotlin
/htmlReport/*
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<p align="center">
<a href='https://developer.android.com'><img src='http://img.shields.io/badge/platform-android-green.svg'/></a>
<a href="https://kotlinlang.org/docs/whatsnew1920.html"><img src = "https://shields.io/badge/kotlin-2.0.10-blue" /></a>
<a href="https://developer.android.com/jetpack/compose/bom"><img src = "https://img.shields.io/badge/jetpack%20compose-2024.06.00-brightgreen" /></a>
<a href="https://kotlinlang.org/docs/whatsnew1920.html"><img src = "https://shields.io/badge/kotlin-2.0.20-blue" /></a>
<a href="https://developer.android.com/jetpack/compose/bom"><img src = "https://img.shields.io/badge/jetpack%20compose-2024.08.00-brightgreen" /></a>
<a href="https://opensource.org/licenses/Apache-2.0"><img src="https://img.shields.io/badge/license-Apache%202.0-blue.svg"/></a>
</p>

Expand All @@ -24,9 +24,13 @@
- Room - Create, store, and manage persistent data backed by a SQLite database.
- ViewModel - Store and manage UI-related data in a lifecycle conscious.
- App Startup - initialize components at app startup.
- Clean Architecture (nowinandroid)
- Clean Architecture (multi module)
- MVVM pattern
- Kotlin Coroutines & Flows
- Kotlin
- Coroutines
- Flows
- Serialization
- [Type Safety Navigation](https://developer.android.com/guide/navigation/design/type-safety)
- Material Design 3
- [Material Theme Builder](https://material-foundation.github.io/material-theme-builder/)
- Single Activity
Expand All @@ -37,6 +41,7 @@
- [Timber](https://github.com/JakeWharton/timber)
- [Haze](https://github.com/chrisbanes/haze)
- [SharedElement](https://developer.android.com/guide/fragments/animate#shared)
- [Kover](https://github.com/Kotlin/kotlinx-kover)

## Multi Module

Expand Down
1 change: 1 addition & 0 deletions build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ dependencies {
compileOnly(libs.compose.gradlePlugin)
compileOnly(libs.kotlin.gradlePlugin)
compileOnly(libs.ksp.gradlePlugin)
compileOnly(libs.kover.gradlePlugin)
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ extensions.configure<ApplicationExtension> {
add("implementation", findLibrary("timber"))
add("implementation", findLibrary("coil.kt"))
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import io.github.shinhyo.brba.buildlogic.androidExtension
import io.github.shinhyo.brba.buildlogic.configureKoverAndroid
import io.github.shinhyo.brba.buildlogic.findLibrary

with(pluginManager) {
apply("brba.android.library.compose")
apply("org.jetbrains.kotlin.plugin.serialization")
}

configureKoverAndroid()

androidExtension.apply {

dependencies {
Expand All @@ -13,6 +17,8 @@ androidExtension.apply {
add("implementation", project(":core:common"))
add("implementation", project(":core:domain"))

add("implementation", findLibrary("kotlinx.serialization.json"))

add("implementation", findLibrary("coil.kt.compose"))

add("implementation", findLibrary("androidx.compose.material3"))
Expand All @@ -24,6 +30,8 @@ androidExtension.apply {
add("implementation", findLibrary("androidx.hilt.navigation.compose"))
add("implementation", findLibrary("androidx.lifecycle.runtimeCompose"))
add("implementation", findLibrary("androidx.lifecycle.viewModelCompose"))

add("testImplementation", project(":core:testing"))
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package io.github.shinhyo.brba.buildlogic

import kotlinx.kover.gradle.plugin.dsl.KoverProjectExtension
import org.gradle.api.Project
import org.gradle.kotlin.dsl.assign
import org.gradle.kotlin.dsl.configure

internal fun Project.configureKoverAndroid() {
pluginManager.apply("org.jetbrains.kotlinx.kover")

extensions.configure<KoverProjectExtension> {

// useJacoco()

reports {
filters {
includes {
classes("*ViewModel*")
}
excludes {
classes("*_Factory*", "*_HiltModules*")
}
}

variant("debug") {
html {
onCheck = true
}

xml {
onCheck = true
}
}

}

}

}


2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.serialization) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.hilt) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.kover) apply false
}

apply(from = File("gradle/projectDependencyGraph.gradle"))
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,9 @@ private fun Preview() {
status = "Presumed dead",
nickname = "Heisenberg",
portrayed = "",
category = "Breaking Bad",
category = listOf("Breaking Bad"),
ratio = 1.2f,
isFavorite = true,
ctime = null,
),
animatedVisibilityScope = it,
onCharacterClick = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.material3.Card
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
Expand Down Expand Up @@ -78,10 +77,9 @@ fun SharedTransitionScope.BrbaCharacterRow(
),
)

Spacer(modifier = Modifier.width(4.dp))

Column(
modifier = Modifier
.padding(horizontal = 8.dp, vertical = 8.dp)
.weight(1f),
) {
Text(
Expand All @@ -92,9 +90,7 @@ fun SharedTransitionScope.BrbaCharacterRow(
modifier = Modifier
.fillMaxWidth(),
)

Spacer(modifier = Modifier.height(2.dp))

Text(
text = character.nickname,
style = MaterialTheme.typography.bodyLarge,
Expand All @@ -108,7 +104,6 @@ fun SharedTransitionScope.BrbaCharacterRow(
Box(
contentAlignment = Alignment.BottomEnd,
modifier = Modifier
.padding(horizontal = 4.dp, vertical = 4.dp)
.fillMaxSize(),
) {
BrbaIconFavorite(
Expand All @@ -135,10 +130,9 @@ private fun Preview() {
status = "Presumed dead",
nickname = "Heisenberg, Heisenberg, Heisenberg, Heisenberg",
portrayed = "",
category = "Breaking Bad",
category = listOf("Breaking Bad"),
ratio = 1.5f,
isFavorite = true,
ctime = null,
),
animatedVisibilityScope = it,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Copyright 2024 shinhyo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.shinhyo.brba.core.ui

import android.content.res.Configuration
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.github.shinhyo.brba.core.theme.BrbaPreviewTheme

@Composable
fun BrbaChips(
modifier: Modifier = Modifier,
chipList: List<String>,
) {
FlowRow(
modifier = modifier.fillMaxWidth(),
) {
chipList.forEach { chip ->
Box(
modifier = Modifier
.padding(4.dp)
.clip(RoundedCornerShape(16.dp))
.border(
width = 1.dp,
color = MaterialTheme.colorScheme.tertiary,
shape = RoundedCornerShape(16.dp),
)
.background(MaterialTheme.colorScheme.onTertiary)
.padding(horizontal = 12.dp, vertical = 6.dp),
) {
Text(
text = chip,
style = MaterialTheme.typography.labelSmall,
color = MaterialTheme.colorScheme.tertiary,
)
}
}
}
}

@Preview
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
@Composable
private fun Preview() {
BrbaPreviewTheme {
BrbaChips(
chipList = listOf(
"Breaking Bad1",
"Breaking Bad3",
"Breaking Bad3",
"Breaking Bad3",
"Breaking Bad3",
"Breaking Bad3",
"Breaking Bad5",
"Better Call Saul6",
),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import dev.chrisbanes.haze.HazeDefaults
import dev.chrisbanes.haze.HazeState
import dev.chrisbanes.haze.hazeChild
import io.github.shinhyo.brba.core.designsystem.R
import io.github.shinhyo.brba.core.theme.BrbaPreviewTheme

@Composable
fun BrbaTopAppBar(
Expand All @@ -46,7 +47,7 @@ fun BrbaTopAppBar(
Text(
text = title ?: LocalContext.current.getString(R.string.top_bar_title),
color = MaterialTheme.colorScheme.primary,
style = MaterialTheme.typography.displaySmall,
style = MaterialTheme.typography.headlineMedium,
fontWeight = FontWeight.Bold,
modifier = Modifier,
)
Expand All @@ -69,8 +70,10 @@ fun BrbaTopAppBar(
@Preview(showBackground = true)
@Composable
private fun Preview() {
BrbaTopAppBar(
title = "Title",
hazeState = HazeState(),
)
BrbaPreviewTheme {
BrbaTopAppBar(
title = "Title",
hazeState = HazeState(),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ package io.github.shinhyo.brba.core.model
import java.util.Date

data class BrbaCharacter(
val charId: Long = -1,
val charId: Long,
val name: String = "",
val birthday: String = "",
val img: String = "",
val status: String = "",
val nickname: String = "",
val portrayed: String = "",
val category: String = "",
val category: List<String> = listOf(),
val description: String = "",
val ratio: Float = 1f,
val isFavorite: Boolean = false,
val ctime: Date? = null,
val ctime: Date = Date(),
)
Loading

0 comments on commit 8f9c6ab

Please sign in to comment.