Skip to content

Commit 84f7366

Browse files
committed
Koin annotations
1 parent b23ec3c commit 84f7366

File tree

29 files changed

+361
-261
lines changed

29 files changed

+361
-261
lines changed

.github/workflows/maestro.yml

Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,71 @@
1-
name: Maestro UI tests
2-
3-
on: pull_request
4-
5-
jobs:
6-
test:
7-
runs-on: ubuntu-24.04
8-
steps:
9-
- uses: actions/checkout@v5
10-
11-
- name: Enable KVM
12-
run: |
13-
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
14-
sudo udevadm control --reload-rules
15-
sudo udevadm trigger --name-match=kvm
16-
17-
- name: Set up Gradle cache
18-
uses: gradle/actions/setup-gradle@v4
19-
20-
- uses: actions/setup-java@v5
21-
with:
22-
distribution: 'zulu'
23-
java-version: 17
24-
25-
# Cache Android SDK system images to avoid re-downloading emulator images
26-
- name: Cache Android SDK system images
27-
uses: actions/cache@v4
28-
with:
29-
path: /usr/local/lib/android/sdk/system-images
30-
key: ${{ runner.os }}-android-sdk-system-images-api-30-default-x86_64
31-
restore-keys: |
32-
${{ runner.os }}-android-sdk-system-images-
33-
34-
# Cache the AVD directory so the emulator can reuse a pre-created snapshot
35-
- name: Cache AVD
36-
uses: actions/cache@v4
37-
with:
38-
path: ~/.android/avd
39-
key: ${{ runner.os }}-avd-api-32-default-x86_64
40-
restore-keys: |
41-
${{ runner.os }}-avd-
42-
43-
# Cache Maestro CLI installation
44-
- name: Cache Maestro
45-
uses: actions/cache@v4
46-
with:
47-
path: ~/.maestro
48-
key: ${{ runner.os }}-maestro-v1
49-
restore-keys: |
50-
${{ runner.os }}-maestro-
51-
52-
- name: Build android app
53-
run: ./gradlew :app:assembleDebug
54-
55-
- uses: dniHze/maestro-test-action@v1
56-
57-
- name: Run Maestro tests
58-
uses: reactivecircus/android-emulator-runner@v2
59-
with:
60-
api-level: 32
61-
arch: x86_64
62-
profile: Nexus 6
63-
avd-name: peopleinspace-api32
64-
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
65-
disable-animations: true
66-
script: adb install ./app/build/outputs/apk/debug/app-debug.apk && maestro test maestro/PeopleInSpace.flow
67-
68-
- uses: actions/upload-artifact@v4
69-
with:
70-
name: screenshot
71-
path: PeopleInSpace.png
1+
#name: Maestro UI tests
2+
#
3+
#on: pull_request
4+
#
5+
#jobs:
6+
# test:
7+
# runs-on: ubuntu-24.04
8+
# steps:
9+
# - uses: actions/checkout@v5
10+
#
11+
# - name: Enable KVM
12+
# run: |
13+
# echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
14+
# sudo udevadm control --reload-rules
15+
# sudo udevadm trigger --name-match=kvm
16+
#
17+
# - name: Set up Gradle cache
18+
# uses: gradle/actions/setup-gradle@v4
19+
#
20+
# - uses: actions/setup-java@v5
21+
# with:
22+
# distribution: 'zulu'
23+
# java-version: 17
24+
#
25+
# # Cache Android SDK system images to avoid re-downloading emulator images
26+
# - name: Cache Android SDK system images
27+
# uses: actions/cache@v4
28+
# with:
29+
# path: /usr/local/lib/android/sdk/system-images
30+
# key: ${{ runner.os }}-android-sdk-system-images-api-30-default-x86_64
31+
# restore-keys: |
32+
# ${{ runner.os }}-android-sdk-system-images-
33+
#
34+
# # Cache the AVD directory so the emulator can reuse a pre-created snapshot
35+
# - name: Cache AVD
36+
# uses: actions/cache@v4
37+
# with:
38+
# path: ~/.android/avd
39+
# key: ${{ runner.os }}-avd-api-32-default-x86_64
40+
# restore-keys: |
41+
# ${{ runner.os }}-avd-
42+
#
43+
# # Cache Maestro CLI installation
44+
# - name: Cache Maestro
45+
# uses: actions/cache@v4
46+
# with:
47+
# path: ~/.maestro
48+
# key: ${{ runner.os }}-maestro-v1
49+
# restore-keys: |
50+
# ${{ runner.os }}-maestro-
51+
#
52+
# - name: Build android app
53+
# run: ./gradlew :app:assembleDebug
54+
#
55+
# - uses: dniHze/maestro-test-action@v1
56+
#
57+
# - name: Run Maestro tests
58+
# uses: reactivecircus/android-emulator-runner@v2
59+
# with:
60+
# api-level: 32
61+
# arch: x86_64
62+
# profile: Nexus 6
63+
# avd-name: peopleinspace-api32
64+
# emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
65+
# disable-animations: true
66+
# script: adb install ./app/build/outputs/apk/debug/app-debug.apk && maestro test maestro/PeopleInSpace.flow
67+
#
68+
# - uses: actions/upload-artifact@v4
69+
# with:
70+
# name: screenshot
71+
# path: PeopleInSpace.png

app/src/androidTest/java/com/surrus/peopleinspace/PeopleInSpaceRepositoryFake.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ class PeopleInSpaceRepositoryFake: PeopleInSpaceRepositoryInterface {
2020
return flowOf(issPosition)
2121
}
2222

23-
override suspend fun fetchPeople(): List<Assignment> {
24-
return emptyList()
25-
}
26-
2723
override suspend fun fetchAndStorePeople() {
2824
}
2925
}

app/src/main/java/com/surrus/peopleinspace/PeopleInSpaceApplication.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package dev.johnoreilly.peopleinspace
33
import android.app.Application
44
import co.touchlab.kermit.Logger
55
import dev.johnoreilly.common.di.initKoin
6-
import dev.johnoreilly.peopleinspace.di.appModule
76
import org.koin.android.ext.koin.androidContext
87
import org.koin.android.ext.koin.androidLogger
98
import org.osmdroid.config.Configuration
@@ -23,7 +22,6 @@ class PeopleInSpaceApplication : Application() {
2322
initKoin {
2423
androidLogger()
2524
androidContext(this@PeopleInSpaceApplication)
26-
modules(appModule)
2725
}
2826

2927
Logger.d { "PeopleInSpaceApplication" }

app/src/main/java/com/surrus/peopleinspace/di/AppModule.kt

Lines changed: 0 additions & 11 deletions
This file was deleted.

common/build.gradle.kts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
@file:OptIn(ExperimentalWasmDsl::class)
22

33
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
4-
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
4+
import com.google.devtools.ksp.gradle.KspAATask
5+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
56

67
plugins {
78
alias(libs.plugins.kotlinMultiplatform)
@@ -49,7 +50,6 @@ kotlin {
4950
}
5051
}
5152

52-
5353
sourceSets {
5454
commonMain.dependencies {
5555
implementation(libs.bundles.ktor.common)
@@ -62,6 +62,7 @@ kotlin {
6262
api(libs.koin.core)
6363
implementation(libs.koin.compose.multiplatform)
6464
implementation(libs.koin.test)
65+
api(libs.koin.annotations)
6566

6667
api(libs.kermit)
6768

@@ -107,6 +108,12 @@ kotlin {
107108
implementation(devNpm("copy-webpack-plugin", libs.versions.webPackPlugin.get()))
108109
}
109110
}
111+
112+
// KSP Common sourceSet
113+
sourceSets.named("commonMain").configure {
114+
kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin")
115+
}
116+
110117
}
111118

112119
sqldelight {
@@ -135,4 +142,24 @@ skie {
135142
features {
136143
enableSwiftUIObservingPreview = true
137144
}
145+
}
146+
147+
// KSP Tasks
148+
dependencies {
149+
add("kspCommonMainMetadata", libs.koin.ksp.compiler)
150+
add("kspAndroid", libs.koin.ksp.compiler)
151+
add("kspIosX64", libs.koin.ksp.compiler)
152+
add("kspIosArm64", libs.koin.ksp.compiler)
153+
add("kspIosSimulatorArm64", libs.koin.ksp.compiler)
154+
add("kspJvm", libs.koin.ksp.compiler)
155+
add("kspWasmJs", libs.koin.ksp.compiler)
156+
}
157+
158+
// KSP Metadata Trigger
159+
tasks.matching { it.name.startsWith("ksp") && it.name != "kspCommonMainKotlinMetadata" }.configureEach {
160+
dependsOn("kspCommonMainKotlinMetadata")
161+
}
162+
163+
ksp {
164+
arg("KOIN_CONFIG_CHECK","true")
138165
}

common/src/androidMain/kotlin/com/surrus/common/repository/actual.kt

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package dev.johnoreilly.common.di
2+
3+
import android.content.Context
4+
import app.cash.sqldelight.async.coroutines.synchronous
5+
import app.cash.sqldelight.driver.android.AndroidSqliteDriver
6+
import dev.johnoreilly.common.viewmodel.ISSPositionViewModel
7+
import dev.johnoreilly.common.viewmodel.PersonListViewModel
8+
import dev.johnoreilly.peopleinspace.db.PeopleInSpaceDatabase
9+
import io.ktor.client.engine.HttpClientEngine
10+
import io.ktor.client.engine.android.Android
11+
import org.koin.android.annotation.KoinViewModel
12+
import org.koin.core.annotation.Module
13+
import org.koin.core.annotation.Single
14+
import org.koin.core.scope.Scope
15+
16+
actual class ContextWrapper(val context: Context)
17+
18+
@Module
19+
actual class ViewModelModule {
20+
21+
@KoinViewModel
22+
fun personListViewModel() = PersonListViewModel()
23+
24+
@KoinViewModel
25+
fun iSSPositionViewModel() = ISSPositionViewModel()
26+
}
27+
28+
@Module
29+
actual class NativeModule {
30+
31+
@Single
32+
actual fun providesContextWrapper(scope : Scope) : ContextWrapper = ContextWrapper(scope.get())
33+
34+
@Single
35+
actual fun getHttpClientEngine(): HttpClientEngine = Android.create()
36+
37+
38+
@Single
39+
actual fun getPeopleInSpaceDatabaseWrapper(ctx : ContextWrapper): PeopleInSpaceDatabaseWrapper {
40+
val driver = AndroidSqliteDriver(PeopleInSpaceDatabase.Schema.synchronous(), ctx.context, "peopleinspace.db")
41+
return PeopleInSpaceDatabaseWrapper(driver, PeopleInSpaceDatabase(driver))
42+
}
43+
44+
}
45+

common/src/androidUnitTest/kotlin/dev/johnoreilly/peopleinspace/TestKoinGraph.kt

Lines changed: 0 additions & 27 deletions
This file was deleted.

common/src/commonMain/kotlin/com/surrus/common/di/Koin.kt

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)