Skip to content

Commit 1f0d257

Browse files
authored
Merge pull request #16 from shinhyo/env-improvements
env-improvements
2 parents 53afd26 + ba5b3aa commit 1f0d257

File tree

10 files changed

+917
-43
lines changed

10 files changed

+917
-43
lines changed

.github/workflows/CD.yaml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: CD
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 30
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Set up JDK 17
20+
uses: actions/setup-java@v4
21+
with:
22+
distribution: 'zulu'
23+
java-version: 17
24+
25+
- name: Validate Gradle Wrapper
26+
uses: gradle/wrapper-validation-action@v3
27+
28+
- name: Set release version
29+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
30+
31+
- name: Copy CI gradle.properties
32+
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
33+
34+
- name: chmod cache key
35+
run: chmod +x ./scripts/checksum.sh
36+
37+
- name: Generate cache key
38+
run: ./scripts/checksum.sh app checksum.txt
39+
40+
- name: Cache Gradle
41+
uses: actions/cache@v3
42+
with:
43+
path: |
44+
~/.gradle/caches/modules-*
45+
~/.gradle/caches/jars-*
46+
~/.gradle/caches/build-cache-*
47+
~/.gradle/wrapper/
48+
~/.gradle/caches/transforms-*
49+
key: gradle-${{ hashFiles('checksum.txt') }}
50+
restore-keys: |
51+
gradle-
52+
53+
- name: Setup Gradle
54+
uses: gradle/actions/setup-gradle@v3
55+
56+
- name: Build Release APK
57+
run: ./gradlew assembleRelease --no-daemon --stacktrace
58+
59+
- name: Prepare APK for Release
60+
run: |
61+
mkdir -p release
62+
cp app/build/outputs/apk/release/app-release.apk release/BreakingBad-${{ env.RELEASE_VERSION }}.apk
63+
64+
- name: Generate changelog
65+
id: changelog
66+
uses: metcalfc/[email protected]
67+
with:
68+
myToken: ${{ secrets.GITHUB_TOKEN }}
69+
70+
- name: Create GitHub Release
71+
uses: softprops/action-gh-release@v1
72+
with:
73+
files: release/BreakingBad-${{ env.RELEASE_VERSION }}.apk
74+
name: Release ${{ env.RELEASE_VERSION }}
75+
body: |
76+
${{ steps.changelog.outputs.changelog }}
77+
draft: false
78+
prerelease: false
79+
env:
80+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81+
82+
- name: Delete checksum.txt after build
83+
if: always()
84+
run: rm -f checksum.txt

.github/workflows/Build.yaml renamed to .github/workflows/CI.yaml

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build
1+
name: CI
22

33
on:
44
pull_request:
@@ -10,10 +10,9 @@ concurrency:
1010
cancel-in-progress: true
1111

1212
jobs:
13-
build:
13+
spotless:
1414
runs-on: ubuntu-latest
15-
timeout-minutes: 30
16-
15+
timeout-minutes: 10
1716
steps:
1817
- name: Checkout
1918
uses: actions/checkout@v4
@@ -42,21 +41,60 @@ jobs:
4241
~/.gradle/caches/modules-*
4342
~/.gradle/caches/jars-*
4443
~/.gradle/caches/build-cache-*
44+
~/.gradle/wrapper/
45+
~/.gradle/caches/transforms-*
4546
key: gradle-${{ hashFiles('checksum.txt') }}
47+
restore-keys: |
48+
gradle-
4649
4750
- name: Setup Gradle
48-
uses: gradle/gradle-build-action@v3
51+
uses: gradle/actions/setup-gradle@v3
4952

5053
- name: Check Spotless
51-
run: ./gradlew spotlessCheck --init-script gradle/init.gradle.kts --no-configuration-cache --stacktrace
54+
run: ./gradlew spotlessCheck --init-script gradle/init.gradle.kts --no-configuration-cache --no-daemon --stacktrace
55+
56+
tests:
57+
runs-on: ubuntu-latest
58+
timeout-minutes: 20
59+
steps:
60+
- name: Checkout
61+
uses: actions/checkout@v4
62+
63+
- name: Set up JDK 17
64+
uses: actions/setup-java@v4
65+
with:
66+
distribution: 'zulu'
67+
java-version: 17
68+
69+
- name: chmod cache key
70+
run: chmod +x ./scripts/checksum.sh
71+
72+
- name: Generate cache key
73+
run: ./scripts/checksum.sh app checksum.txt
74+
75+
- uses: actions/cache@v3
76+
with:
77+
path: |
78+
~/.gradle/caches/modules-*
79+
~/.gradle/caches/jars-*
80+
~/.gradle/caches/build-cache-*
81+
~/.gradle/wrapper/
82+
~/.gradle/caches/transforms-*
83+
key: gradle-${{ hashFiles('checksum.txt') }}
84+
restore-keys: |
85+
gradle-
86+
87+
- name: Copy CI gradle.properties
88+
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
89+
90+
- name: Setup Gradle
91+
uses: gradle/actions/setup-gradle@v3
5292

5393
- name: UnitTest
54-
run: |
55-
./gradlew testDebugUnitTest --stacktrace
94+
run: ./gradlew testDebugUnitTest --no-daemon --stacktrace
5695

5796
- name: Check Kover
58-
run: |
59-
./gradlew koverXmlReportDebug
97+
run: ./gradlew koverXmlReportDebug --no-daemon
6098

6199
- name: Display local test coverage
62100
uses: madrapps/[email protected]
@@ -69,11 +107,4 @@ jobs:
69107
continue-on-error: false
70108
paths: |
71109
${{ github.workspace }}/feature/**/build/reports/kover/reportDebug.xml
72-
token: ${{ secrets.GITHUB_TOKEN }}
73-
74-
- name: Upload lint reports
75-
if: always()
76-
uses: actions/upload-artifact@v3
77-
with:
78-
name: build-reports
79-
path: app/build/reports
110+
token: ${{ secrets.GITHUB_TOKEN }}

app/src/main/assets/character.json

Lines changed: 684 additions & 0 deletions
Large diffs are not rendered by default.

build-logic/convention/build.gradle.kts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
12
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
23

34
plugins {
@@ -12,8 +13,8 @@ java {
1213
targetCompatibility = JavaVersion.VERSION_17
1314
}
1415
tasks.withType<KotlinCompile>().configureEach {
15-
kotlinOptions {
16-
jvmTarget = JavaVersion.VERSION_17.toString()
16+
compilerOptions {
17+
jvmTarget.set(JvmTarget.JVM_17)
1718
}
1819
}
1920

build-logic/convention/src/main/kotlin/brba.android.application.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ extensions.configure<ApplicationExtension> {
3232

3333
buildTypes {
3434
getByName("debug") {
35-
isDebuggable = false
35+
isDebuggable = true
3636
}
3737

3838
getByName("release") {

build-logic/convention/src/main/kotlin/io/github/shinhyo/brba/buildlogic/AndroidCompose.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ internal fun Project.configureAndroidCompose() {
2626
}
2727

2828
extensions.configure<ComposeCompilerGradlePluginExtension> {
29-
enableStrongSkippingMode = true
3029
includeSourceInformation = true
3130
}
3231
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright 2025 shinhyo
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.github.shinhyo.brba.core.network
17+
18+
import android.content.Context
19+
import dagger.hilt.android.qualifiers.ApplicationContext
20+
import io.github.shinhyo.brba.core.network.model.CharacterResponse
21+
import kotlinx.coroutines.delay
22+
import kotlinx.serialization.json.Json
23+
import timber.log.Timber
24+
import javax.inject.Inject
25+
import javax.inject.Singleton
26+
27+
/**
28+
* NOTE: This is a sample app.
29+
* The actual network implementation can be replaced with a local data source
30+
* for testing or demo purposes without real network calls.
31+
*/
32+
@Singleton
33+
class LocalDataSource @Inject constructor(
34+
@ApplicationContext private val context: Context,
35+
) : NetworkDataSource {
36+
private val jsonParser = Json { ignoreUnknownKeys = true }
37+
38+
override suspend fun getCharacter(): List<CharacterResponse> {
39+
simulateNetworkDelay()
40+
return readCharactersFromAsset()
41+
}
42+
43+
override suspend fun getCharacter(id: Long): List<CharacterResponse> {
44+
simulateNetworkDelay()
45+
return readCharactersFromAsset().filter { it.charId == id }
46+
}
47+
48+
private suspend fun simulateNetworkDelay() {
49+
// Simulate random network delay (up to 500ms) for sample app
50+
delay((0..500).random().toLong())
51+
}
52+
53+
private fun readCharactersFromAsset(): List<CharacterResponse> {
54+
val assetManager = context.assets
55+
val inputStream = assetManager.open("character.json")
56+
val json = inputStream.bufferedReader().use { it.readText() }
57+
return try {
58+
jsonParser.decodeFromString(json)
59+
} catch (e: Exception) {
60+
Timber.e(e, "Failed to parse character.json")
61+
emptyList()
62+
}
63+
}
64+
}

core/network/src/main/kotlin/io/github/shinhyo/brba/core/network/di/NetworkModule.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,26 @@ import dagger.Binds
1919
import dagger.Module
2020
import dagger.hilt.InstallIn
2121
import dagger.hilt.components.SingletonComponent
22+
import io.github.shinhyo.brba.core.network.LocalDataSource
2223
import io.github.shinhyo.brba.core.network.NetworkDataSource
23-
import io.github.shinhyo.brba.core.network.retrofit.RetrofitNetwork
2424

2525
@Module
2626
@InstallIn(SingletonComponent::class)
2727
interface NetworkModule {
2828

29+
/**
30+
* NOTE: This is a sample app.
31+
*
32+
* The actual network implementation can be replaced with a local data source
33+
* for testing or demo purposes without real network calls.
34+
*/
35+
// @Binds
36+
// fun bindNetworkDataSource(
37+
// network: RetrofitNetwork,
38+
// ): NetworkDataSource
39+
2940
@Binds
3041
fun bindNetworkDataSource(
31-
network: RetrofitNetwork,
42+
network: LocalDataSource,
3243
): NetworkDataSource
3344
}

gradle/libs.versions.toml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
[versions]
22
versionCode = "1"
33
versionName = "1.0.0"
4-
compileSdkVer = "34"
5-
targetSdkVer = "34"
4+
compileSdkVer = "35"
5+
targetSdkVer = "35"
66
minSdkVer = "28"
77

8-
androidGradlePlugin = "8.5.2"
9-
androidTools = "31.6.0"
8+
androidGradlePlugin = "8.10.0"
9+
androidTools = "31.10.0"
1010

1111
# https://github.com/JetBrains/kotlin/releases
12-
kotlin = "2.0.20"
12+
kotlin = "2.1.21"
1313
# https://github.com/google/ksp/releases
14-
ksp = "2.0.20-1.0.25"
15-
androidDesugarJdkLibs = "2.1.2"
14+
ksp = "2.1.21-2.0.1"
15+
androidDesugarJdkLibs = "2.1.5"
1616

17-
kotlinxCoroutines = "1.8.1"
17+
kotlinxCoroutines = "1.10.1"
1818
kotlinxSerializationJson = "1.7.1"
1919

20-
androidxCore = "1.13.1"
20+
androidxCore = "1.16.0"
2121
androidxCoreSplashscreen = "1.0.1"
2222
androidxAppCompat = "1.7.0"
23-
androidxActivity = "1.9.2"
24-
androidxStartup = "1.1.1"
23+
androidxActivity = "1.10.1"
24+
androidxStartup = "1.2.0"
2525
androidxHiltNavigationCompose = "1.2.0"
26-
androidxLifecycle = "2.8.5"
27-
androidxDataStore = "1.1.1"
26+
androidxLifecycle = "2.9.0"
27+
androidxDataStore = "1.1.7"
2828

29-
androidxComposeBom = "2024.09.00"
29+
androidxComposeBom = "2025.05.01"
3030
androidxComposeMaterial3 = "1.1.2"
3131

32-
hilt = "2.51.1"
32+
hilt = "2.56"
3333
hiltExt = "1.0.0"
3434

35-
androidxNavigation = "2.8.0"
35+
androidxNavigation = "2.9.0"
3636

3737
junit4 = "4.13.2"
3838
androidxTestCore = "1.6.1"
@@ -45,13 +45,13 @@ timber = "5.0.1"
4545
okhttp = "4.12.0"
4646
retrofit = "2.11.0"
4747
retrofitKotlinxSerializationJson = "1.0.0"
48-
room = "2.6.1"
48+
room = "2.7.1"
4949
turbine = "1.1.0"
5050
junit = "1.2.1"
5151
material = "1.12.0"
5252
haze = "0.7.2"
5353
mockk = "1.13.9"
54-
kover = "0.8.3"
54+
kover = "0.9.1"
5555

5656
[libraries]
5757

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Tue Jun 25 15:56:57 KST 2024
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)